Advertisement
Guest User

Untitled

a guest
Apr 2nd, 2020
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.24 KB | None | 0 0
  1. init(){
  2. const button = '.js-copy-to-clipboard';
  3. const el = document.querySelector(button);
  4.  
  5. let instance = (tippy(button, {
  6. hideOnClick: false,
  7. animateFill: true,
  8. arrow: true,
  9. animation: 'shift-away',
  10. trigger: 'mouseenter',
  11. onHide() {
  12. setTimeout(function () {
  13. instance[0].setContent(el.getAttribute('data-tippy-content'));
  14. }, 500);
  15. },
  16. }));
  17.  
  18. $('.js-copy-to-clipboard').on('click touchstart', function () {
  19. let copyText = $(this).data('latitude') + ',' + $(this).data('longitude');
  20. let textArea = document.createElement("textarea");
  21.  
  22. textArea.value = copyText;
  23. document.body.appendChild(textArea);
  24. textArea.select();
  25. textArea.setSelectionRange(0, 99999); /* For mobile devices*/
  26.  
  27. try {
  28. let successful = document.execCommand('copy');
  29. instance[0].setContent('Sačuvano: ' + copyText);
  30. } catch (err) {
  31. console.log('Oops, unable to copy');
  32. }
  33. document.body.removeChild(textArea);
  34. });
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement