authelia/docs/assets/js/clipboard.js

37 lines
771 B
JavaScript
Raw Permalink Normal View History

import Clipboard from 'clipboard';
var pre = document.getElementsByTagName('pre');
for (var i = 0; i < pre.length; ++ i)
{
var element = pre[i];
var mermaid = element.getElementsByClassName('language-mermaid')[0];
if (mermaid == null) {
element.insertAdjacentHTML('afterbegin', '<button class="btn btn-copy"></button>');
}
}
var clipboard = new Clipboard('.btn-copy', {
target: function(trigger) {
return trigger.nextElementSibling;
},
});
clipboard.on('success', function(e) {
2022-06-21 21:57:51 +00:00
/*
console.info('Action:', e.action);
console.info('Text:', e.text);
console.info('Trigger:', e.trigger);
*/
2022-06-21 21:57:51 +00:00
e.clearSelection();
});
clipboard.on('error', function(e) {
2022-06-21 21:57:51 +00:00
console.error('Action:', e.action);
console.error('Trigger:', e.trigger);
});