Skip to content

Commit d791e54

Browse files
committed
patch: mistaken use of a previous js file
1 parent 7345ab0 commit d791e54

1 file changed

Lines changed: 4 additions & 10 deletions

File tree

_includes/scripts/lib/copy-to-clipboard.js

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
(function() {
2-
// This script is built on clipboard.js, cf: https://clipboardjs.com/
3-
// 1. find all code blocks defined under snippet class
42
var snippets = document.querySelectorAll('pre');
53
[].forEach.call(snippets, function(snippet) {
64
if (snippet.closest('.snippet') !== null) {
7-
snippet.firstChild.insertAdjacentHTML('beforebegin', '<button class="btn" data-clipboard-snippet><i class="far fa-copy"></i></button>');
5+
snippet.firstChild.insertAdjacentHTML('beforebegin', '<button class="btn" data-clipboard-snippet><img class="clippy" height="20" src="/assets/clippy.svg" alt="Copy to clipboard"></button>');
86
}
97
});
108
var clipboardSnippets = new ClipboardJS('[data-clipboard-snippet]', {
@@ -20,12 +18,13 @@
2018
showTooltip(e.trigger, fallbackMessage(e.action));
2119
});
2220

23-
// 2. add event listener for all created copy button
2421
var btns = document.querySelectorAll('.btn');
2522
for (var i = 0; i < btns.length; i++) {
2623
btns[i].addEventListener('mouseleave', clearTooltip);
2724
btns[i].addEventListener('blur', clearTooltip);
28-
btns[i].addEventListener('mouseenter', showToolhint);
25+
btns[i].addEventListener('mouseenter', function(e) {
26+
showTooltip(e.currentTarget, "copy to clipboard")
27+
}, false);
2928
}
3029

3130
function clearTooltip(e) {
@@ -38,11 +37,6 @@
3837
elem.setAttribute('aria-label', msg);
3938
}
4039

41-
function showToolhint(e) {
42-
e.currentTarget.setAttribute('class', 'btn tooltipped tooltipped-s');
43-
e.currentTarget.setAttribute('aria-label', 'copy to clipboard');
44-
}
45-
4640
function fallbackMessage(action) {
4741
var actionMsg = '';
4842
var actionKey = (action === 'cut' ? 'X' : 'C');

0 commit comments

Comments
 (0)