|
1234567891011121314151617181920212223242526272829 |
- 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;
-
-
- if (clipboard) {
-
-
- clipboard.destroy();
- clipboard = undefined;
- return;
- }
-
- $(copyButton).prependTo("div.sourceCode");
-
- clipboard = new ClipboardJS(".copy-to-clipboard-button", {
- text: function(trigger) {
- return trigger.parentNode.textContent;
- }
- });
-
- });
-
- });
|