Advertisement
Guest User

Untitled

a guest
Aug 20th, 2019
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.06 KB | None | 0 0
  1. <ui:outputRichText value="{!v.code__c}" aura:id="code"
  2. class="slds-rich-text-area__content"/>
  3.  
  4. copyText : function(component, event, helper) {
  5. helper.copyTextHelper(component, event, event.getSource().get("v.value"));
  6. }
  7.  
  8. copyTextHelper : function(component,event,text) {
  9. // Create an hidden input
  10. var hiddenInput = document.createElement("input");
  11. // passed text into the input
  12. hiddenInput.setAttribute("value", text);
  13. // Append the hiddenInput input to the body
  14. document.body.appendChild(hiddenInput);
  15. // select the content
  16. hiddenInput.select();
  17. // Execute the copy command
  18. document.execCommand("copy");
  19. // Remove the input from the body after copy text
  20. document.body.removeChild(hiddenInput);
  21. // store target button label value
  22. var orignalLabel = event.getSource().get("v.label");
  23. // change button icon after copy text
  24. event.getSource().set("v.iconName" , 'utility:check');
  25. // change button label with 'copied' after copy text
  26. event.getSource().set("v.label" , 'Copied');
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement