Skip to content

Commit 8cfbddc

Browse files
committed
(fix): copy toast function
1 parent 146e3a7 commit 8cfbddc

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

src/js/cheatsheet.js

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,17 @@ function directHashLinkRedirect(){
306306
}
307307
}
308308

309+
// On copied, show toast
310+
function copyToast(){
311+
var toastNotiList = [].slice.call(document.querySelectorAll('.notification-toast'))
312+
var toastNotiList = toastNotiList.map(function (toastNotiEl) {
313+
return new bootstrap.Toast(toastNotiEl, {
314+
autohide: true,
315+
delay: 2000
316+
}).show()
317+
})
318+
}
319+
309320
$(function(){
310321

311322
// On modal close location hash clear
@@ -407,13 +418,7 @@ $(function(){
407418
document.execCommand("copy");
408419
$temp.remove();
409420

410-
var toastNotiList = [].slice.call(document.querySelectorAll('.notification-toast'))
411-
var toastNotiList = toastNotiList.map(function (toastNotiEl) {
412-
return new bootstrap.Toast(toastNotiEl, {
413-
autohide: true,
414-
delay: 2000
415-
}).show()
416-
})
421+
copyToast();
417422
}
418423

419424
// copy attribute on icon click
@@ -454,6 +459,7 @@ $(function(){
454459
editor.selectAll();
455460
editor.focus();
456461
document.execCommand('copy');
462+
copyToast();
457463
});
458464

459465
// Copy Code Snippet of mixins and variables
@@ -464,6 +470,7 @@ $(function(){
464470
previewEditor.selectAll();
465471
previewEditor.focus();
466472
document.execCommand('copy');
473+
copyToast();
467474
}
468475
});
469476

0 commit comments

Comments
 (0)