-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
- Loading branch information
There are no files selected for viewing
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
/* Styles for section anchors */ | ||
a.anchor-section::before {content: '#';font-size: 80%;} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
/* Styles for section anchors */ | ||
a.anchor-section {margin-left: 10px; visibility: hidden; color: inherit;} | ||
.hasAnchor:hover a.anchor-section {visibility: visible;} | ||
ul > li > .anchor-section {display: none;} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
document.addEventListener('DOMContentLoaded', function () { | ||
// If section divs is used, we need to put the anchor in the child header | ||
const headers = document.querySelectorAll("div.hasAnchor.section[class*='level'] > :first-child") | ||
|
||
headers.forEach(function (x) { | ||
// Add to the header node | ||
if (!x.classList.contains('hasAnchor')) x.classList.add('hasAnchor') | ||
// Remove from the section or div created by Pandoc | ||
x.parentElement.classList.remove('hasAnchor') | ||
}) | ||
}) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
div.sourceCode { | ||
position: relative; | ||
} | ||
|
||
.copy-to-clipboard-button { | ||
position: absolute; | ||
right: 0; | ||
top: 0; | ||
visibility: hidden; | ||
} | ||
|
||
.copy-to-clipboard-button:focus { | ||
outline: 0; | ||
} | ||
|
||
div.sourceCode:hover > .copy-to-clipboard-button { | ||
visibility: visible; | ||
} |
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
|
||
}); | ||
|
||
}); |