generated from rstudio/bookdown-demo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbook.js
28 lines (21 loc) · 801 Bytes
/
book.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
$(document).ready(function() {
// Section anchors
$('.section h1, .section h2, .section h3, .section h4, .section h5').each(function() {
anchor = '#' + $(this).parent().attr('id');
$(this).addClass("hasAnchor").prepend('<a href="' + anchor + '" class="anchor"></a>');
});
});
$(document).ready(function() {
// Copy Button
$chunks = $('pre.sourceCode > code.sourceCode');
$chunks.each(function(i, val) {
$(this).prepend("<button class=\"button copy\"><i class=\"fa fa-copy fa-2x\"></i></button>").click(function() {
var $temp = $("<textarea>");
$("body").append($temp);
var content = $(this).clone().children("button").remove().end().text();
$temp.val(content).select();
document.execCommand("copy");
$temp.remove();
});
});
});