Skip to content

Commit c842473

Browse files
committed
[ADD] email address Copied! functionality
1 parent 5516793 commit c842473

File tree

1 file changed

+27
-4
lines changed

1 file changed

+27
-4
lines changed

js/scripts.js

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
/*!
2-
* Start Bootstrap - Grayscale v7.0.5 (https://startbootstrap.com/theme/grayscale)
3-
* Copyright 2013-2022 Start Bootstrap
4-
* Licensed under MIT (https://github.com/StartBootstrap/startbootstrap-grayscale/blob/master/LICENSE)
5-
*/
2+
* Start Bootstrap - Grayscale v7.0.5 (https://startbootstrap.com/theme/grayscale)
3+
* Copyright 2013-2022 Start Bootstrap
4+
* Licensed under MIT (https://github.com/StartBootstrap/startbootstrap-grayscale/blob/master/LICENSE)
5+
*/
66
//
77
// Scripts
88
//
@@ -51,4 +51,27 @@ window.addEventListener('DOMContentLoaded', event => {
5151
});
5252
});
5353

54+
// Enabling automatically copying email when clicking copy button.
55+
// Showing a popover when copy to clipboard is completed.
56+
let copyEmailBtn = document.getElementById('copyEmail');
57+
58+
new bootstrap.Popover(document.querySelector('[data-bs-toggle]'), {
59+
placement: 'bottom',
60+
trigger: 'focus',
61+
html: true
62+
});
63+
64+
//get instance
65+
let popover_instance = bootstrap.Popover.getInstance(document.querySelector('[data-bs-toggle]'));
66+
67+
copyEmailBtn.addEventListener('click', () => {
68+
navigator.clipboard.writeText('aqeebimtiaz@gmail.com')
69+
.then(res => {
70+
popover_instance.show();
71+
setTimeout(function () {
72+
popover_instance.hide();
73+
}, 1000);
74+
});
75+
});
76+
5477
});

0 commit comments

Comments
 (0)