mirror of
https://github.com/zenorocha/clipboard.js.git
synced 2023-08-10 21:12:48 +03:00
Updates custom events
This commit is contained in:
@@ -5,29 +5,27 @@ document.addEventListener('DOMContentLoaded', function() {
|
||||
var btns = clipboard.triggers;
|
||||
|
||||
for (var i = 0; i < btns.length; i++) {
|
||||
btns[i].addEventListener('copy', complete);
|
||||
btns[i].addEventListener('cut', complete);
|
||||
btns[i].addEventListener('success', function(e) {
|
||||
console.info('Action:', e.detail.action);
|
||||
console.info('Text:', e.detail.text);
|
||||
|
||||
e.currentTarget.classList.add('tooltipped', 'tooltipped-s');
|
||||
e.currentTarget.setAttribute('aria-label', 'Copied!');
|
||||
});
|
||||
|
||||
btns[i].addEventListener('mouseleave', function(e) {
|
||||
e.currentTarget.classList.remove('tooltipped', 'tooltipped-s');
|
||||
e.currentTarget.removeAttribute('aria-label');
|
||||
});
|
||||
|
||||
btns[i].addEventListener('no-support', function(e) {
|
||||
btns[i].addEventListener('error', function(e) {
|
||||
var flashes = document.querySelectorAll('.flash');
|
||||
|
||||
for (var j = 0; j < btns.length; j++) {
|
||||
btns[j].disabled = true;
|
||||
flashes[j].textContent = e.detail;
|
||||
flashes[j].classList.remove('hidden');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function complete(e) {
|
||||
console.info('Event:', e.type);
|
||||
console.info('Text:', e.detail);
|
||||
|
||||
e.currentTarget.classList.add('tooltipped', 'tooltipped-s');
|
||||
e.currentTarget.setAttribute('aria-label', 'Copied!');
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user