Skip to content

Commit

Permalink
add minified version of code-copy.js to resources
Browse files Browse the repository at this point in the history
  • Loading branch information
Sieboldianus committed Jul 24, 2019
1 parent 095d8aa commit d2c0991
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
(function(){'use strict';if(!document.queryCommandSupported('copy')){return;}
function flashCopyMessage(el,msg){el.textContent=msg;setTimeout(function(){el.textContent="Copy";},1000);}
function selectText(node){var selection=window.getSelection();var range=document.createRange();range.selectNodeContents(node);selection.removeAllRanges();selection.addRange(range);return selection;}
function addCopyButton(containerEl){var copyBtn=document.createElement("button");copyBtn.className="highlight-copy-btn";copyBtn.textContent="Copy";var codeEl=containerEl.firstElementChild;copyBtn.addEventListener('click',function(){try{var selection=selectText(codeEl);document.execCommand('copy');selection.removeAllRanges();flashCopyMessage(copyBtn,'Copied!')}catch(e){console&&console.log(e);flashCopyMessage(copyBtn,'Failed :\'(')}});containerEl.appendChild(copyBtn);}
var highlightBlocks=document.getElementsByClassName('highlight');Array.prototype.forEach.call(highlightBlocks,addCopyButton);})();
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"Target":"js/code-copy.min.0b73c3e137ac0bb903c3a422bc6acc074838e8ebfb94de26a65197d62b436d15.js","MediaType":"application/javascript","Data":{"Integrity":"sha256-C3PD4TesC7kDw6QivGrMB0g46Ov7lN4mplGX1itDbRU="}}

0 comments on commit d2c0991

Please sign in to comment.