Skip to content

Commit cab375b

Browse files
author
tyr
committed
Fix : notificiation didn't disappear if the copy button was clicked several time
1 parent f3bccd7 commit cab375b

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

app/templates/crate/version.hbs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -291,16 +291,25 @@
291291
e.clearSelection();
292292
notificationElement.classList.add('copy-success')
293293
notificationElement.textContent = successText;
294+
fadeOffElement(notificationElement, 2000);
294295
});
295296
clipboard.on('error', function(e) {
296297
var failureText = 'An error occured. Please use CTRL+C.';
297298
298299
notificationElement.classList.add('copy-failure')
299300
notificationElement.textContent = failureText;
301+
fadeOffElement(notificationElement, 2000);
300302
});
301303
302-
window.setTimeout(function() {
303-
notificationElement.innerHTML = '';
304-
}, 2000);
304+
function fadeOffElement(element, delay) {
305+
setTimeout(function() {
306+
resetElement(element);
307+
}, delay);
308+
}
309+
310+
function resetElement(element) {
311+
element.innerHTML = '';
312+
element.className = '';
313+
}
305314
306315
</script>

0 commit comments

Comments
 (0)