You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
<script src="<%- theme.plugins.clipboard %>"></script>
|
|
|
|
<script>
|
|
|
|
!function (e, t, a) {
|
|
|
|
var initCopyCode = function(){
|
|
|
|
var copyHtml = '';
|
|
|
|
copyHtml += '<button class="btn-copy" data-clipboard-snippet="">';
|
|
|
|
copyHtml += '<i class="fas fa-copy"></i><span>COPY</span>';
|
|
|
|
copyHtml += '</button>';
|
|
|
|
$(".highlight .code pre").before(copyHtml);
|
|
|
|
$(".article pre code").before(copyHtml);
|
|
|
|
var clipboard = new ClipboardJS('.btn-copy', {
|
|
|
|
target: function(trigger) {
|
|
|
|
return trigger.nextElementSibling;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
clipboard.on('success', function(e) {
|
|
|
|
let $btn = $(e.trigger);
|
|
|
|
$btn.addClass('copied');
|
|
|
|
let $icon = $($btn.find('i'));
|
|
|
|
$icon.removeClass('fa-copy');
|
|
|
|
$icon.addClass('fa-clipboard-check');
|
|
|
|
let $span = $($btn.find('span'));
|
|
|
|
$span[0].innerText = 'COPIED';
|
|
|
|
});
|
|
|
|
clipboard.on('error', function(e) {
|
|
|
|
e.clearSelection();
|
|
|
|
let $btn = $(e.trigger);
|
|
|
|
$btn.addClass('copy-failed');
|
|
|
|
let $icon = $($btn.find('i'));
|
|
|
|
$icon.removeClass('fa-copy');
|
|
|
|
$icon.addClass('fa-exclamation-triangle');
|
|
|
|
let $span = $($btn.find('span'));
|
|
|
|
$span[0].innerText = 'COPY FAILED';
|
|
|
|
});
|
|
|
|
}
|
|
|
|
initCopyCode();
|
|
|
|
}(window, document);
|
|
|
|
</script>
|