Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- init(){
- const button = '.js-copy-to-clipboard';
- const el = document.querySelector(button);
- let instance = (tippy(button, {
- hideOnClick: false,
- animateFill: true,
- arrow: true,
- animation: 'shift-away',
- trigger: 'mouseenter',
- onHide() {
- setTimeout(function () {
- instance[0].setContent(el.getAttribute('data-tippy-content'));
- }, 500);
- },
- }));
- $('.js-copy-to-clipboard').on('click touchstart', function () {
- let copyText = $(this).data('latitude') + ',' + $(this).data('longitude');
- let textArea = document.createElement("textarea");
- textArea.value = copyText;
- document.body.appendChild(textArea);
- textArea.select();
- textArea.setSelectionRange(0, 99999); /* For mobile devices*/
- try {
- let successful = document.execCommand('copy');
- instance[0].setContent('Sačuvano: ' + copyText);
- } catch (err) {
- console.log('Oops, unable to copy');
- }
- document.body.removeChild(textArea);
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement