mirror of
https://github.com/metabarcoding/obitools4.git
synced 2025-06-29 16:20:46 +00:00
Beginning of the documentation
This commit is contained in:
33
doc/_book/book_assets/gitbook-2.6.7/js/plugin-clipboard.js
Normal file
33
doc/_book/book_assets/gitbook-2.6.7/js/plugin-clipboard.js
Normal file
@ -0,0 +1,33 @@
|
||||
gitbook.require(["gitbook", "jQuery"], function(gitbook, $) {
|
||||
|
||||
var copyButton = '<button type="button" class="copy-to-clipboard-button" title="Copy to clipboard" aria-label="Copy to clipboard"><i class="fa fa-copy"></i></button>';
|
||||
var clipboard;
|
||||
|
||||
gitbook.events.bind("page.change", function() {
|
||||
|
||||
if (!ClipboardJS.isSupported()) return;
|
||||
|
||||
// the page.change event is thrown twice: before and after the page changes
|
||||
if (clipboard) {
|
||||
// clipboard is already defined but we are on the same page
|
||||
if (clipboard._prevPage === window.location.pathname) return;
|
||||
// clipboard is already defined and url path change
|
||||
// we can deduct that we are before page changes
|
||||
clipboard.destroy(); // destroy the previous events listeners
|
||||
clipboard = undefined; // reset the clipboard object
|
||||
return;
|
||||
}
|
||||
|
||||
$(copyButton).prependTo("div.sourceCode");
|
||||
|
||||
clipboard = new ClipboardJS(".copy-to-clipboard-button", {
|
||||
text: function(trigger) {
|
||||
return trigger.parentNode.textContent;
|
||||
}
|
||||
});
|
||||
|
||||
clipboard._prevPage = window.location.pathname
|
||||
|
||||
});
|
||||
|
||||
});
|
Reference in New Issue
Block a user