copyKeyForDataTable.js 1.0 KB

1234567891011121314151617181920212223242526272829
  1. mgJsComponentHandler.addDefaultComponent('ds-copy-on-click', {
  2. template: '#t-ds-copy-on-click',
  3. data: function () {
  4. return {
  5. wrapper_id: null,
  6. text_to_copy: null,
  7. confirmation_lang: null
  8. };
  9. },
  10. mounted: function () {
  11. var self = this;
  12. var wrapper = $(self.$el).parent();
  13. self.wrapper_id = $(wrapper).attr('id');
  14. self.component_id = $(wrapper).attr('component_id');
  15. self.text_to_copy = $(wrapper).attr('text_to_copy');
  16. self.confirmation_lang = $(wrapper).attr('confirmation_lang');
  17. initTooltipsForDatatables(self.wrapper_id);
  18. },
  19. methods: {
  20. copyTextToClipboard: function() {
  21. var self = this;
  22. initTooltipsForDatatables(self.wrapper_id);
  23. var copyText = document.getElementById("cp_txt_" + self.component_id);
  24. copyText.select();
  25. document.execCommand("copy");
  26. mgPageControler.vueLoader.addAlert('success', self.confirmation_lang);
  27. }
  28. }
  29. });