Created
October 17, 2019 22:47
-
-
Save AndersonKatharineTNC/46476c14975a93030b0bea2eb9c08d3d to your computer and use it in GitHub Desktop.
ClassicURLComponent
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<aura:component implements="flexipage:availableForAllPageTypes,force:hasRecordId,force:hasSObjectName" access="global"> | |
<aura:attribute name="sObjectName" type="String" /> | |
<aura:attribute name="url" type="String"/> | |
<aura:attribute name="hostName" type="String" /> | |
<aura:attribute name="showOpenButton" type="Boolean"/> | |
<aura:handler name="init" value="{!this}" action="{!c.doInit}"/> | |
<aura:attribute name="urlClassic" type="String" default="{!v.url+v.recordId}" /> | |
<br/> | |
<div align="center"> | |
<aura:if isTrue = "{!v.showOpenButton}"> | |
<lightning:button class="slds-button slds-button_neutral" iconName="utility:forward_up" variant="border-filled" label="Open" onclick="{!c.loadClassic }"/> | |
</aura:if> | |
<lightning:button variant="brand" class="slds-button" iconName="utility:copy_to_clipboard" label="Copy" onclick="{!c.copyClassic }"/> | |
</div> | |
<br/> | |
<textarea rows="3" class="slds-textarea" readonly="true" aura:id="urlClassic">{!v.urlClassic}</textarea> | |
</aura:component> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<design:component> | |
<design:attribute name="showOpenButton" default="true"/> | |
</design:component> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
({ | |
doInit : function(cmp){ | |
var hostName = window.location.hostname; | |
hostName = hostName.replace(".lightning.force.com",".my.salesforce.com"); | |
var url = "https://"+hostName+"/"; | |
cmp.set("v.url", url); | |
}, | |
loadClassic : function(cmp, event, helper) { | |
var url = cmp.get("v.urlClassic"); | |
window.open(url); | |
}, | |
copyClassic : function(cmp, event){ | |
var urlClassic = document.getElementById('urlClassic'); | |
cmp.find('urlClassic').getElement().select(); | |
document.queryCommandSupported('copy'); | |
document.execCommand('copy'); | |
var source = event.getSource(); | |
source.set('v.label', 'COPIED!'); | |
setTimeout(function(){ | |
source.set('v.label', 'Copy'); | |
}, 2000); | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment