mirror of
https://github.com/zenorocha/clipboard.js.git
synced 2023-08-10 21:12:48 +03:00
Adds tooltips and updates button labels
This commit is contained in:
@@ -96,6 +96,10 @@ h3 {
|
||||
top: 3px;
|
||||
}
|
||||
|
||||
.btn[disabled] .clippy {
|
||||
opacity: .3;
|
||||
}
|
||||
|
||||
/* Code
|
||||
========================================================================== */
|
||||
|
||||
|
||||
@@ -5,14 +5,12 @@ document.addEventListener('DOMContentLoaded', function() {
|
||||
var btns = clipboard.triggers;
|
||||
|
||||
for (var i = 0; i < btns.length; i++) {
|
||||
btns[i].addEventListener('copy', function(e) {
|
||||
console.info('Event:', e.type);
|
||||
console.info('Text:', e.detail);
|
||||
});
|
||||
btns[i].addEventListener('copy', complete);
|
||||
btns[i].addEventListener('cut', complete);
|
||||
|
||||
btns[i].addEventListener('cut', function(e) {
|
||||
console.info('Event:', e.type);
|
||||
console.info('Text:', e.detail);
|
||||
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) {
|
||||
@@ -24,4 +22,12 @@ document.addEventListener('DOMContentLoaded', function() {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
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