1// make sure we don't redefine the api if already present 2if (!window.$Lightning) { 3 $Lightning = (function() { 4 // delegate status 5 var delegateLoaded = false; 6 7 // queue to store un-delegated calls 8 var callQueue = []; 9 10 // util methods 11 function getDelegateScriptUrl() { 12 // load the delegate script based on stored version (got from aura nonce) or get latest version 13 var url = "/lightning/lightning.out.delegate.js?v=" + getDelegateScriptVersion(); 14 15 // Extract the base path from our own <script> include to adjust for LC4VF/Communities/Sites 16 var scripts = document.getElementsByTagName("script"); 17 for (var m = 0; m < scripts.length; m++) { 18 var script = scripts[m].src; 19 var i = script.indexOf("/lightning/lightning.out.js"); 20 if (i >= 0) { 21 var basePath = script.substring(0, i); 22 url = basePath + url; 23 break; 24 } 25 } 26 27 return url; 28 } 29 30 function getDelegateScriptVersion(){ 31 try { 32 if(localStorage.lightningOutDelegateVersion){ 33 return localStorage.lightningOutDelegateVersion; 34 } 35 } catch (e) {} 36 return (new Date()).getTime(); 37 } 38 39 function loadDelegateScript() { 40 var script = document.createElement('script'); 41 script.type = "text/javascript"; 42 script.src = getDelegateScriptUrl(); 43 script.onload = function() { 44 delegateLoaded = true; 45 while(callQueue.length) { 46 $Lightning._delegate.use.apply(this, callQueue.shift()); 47 } 48 } 49 document.head.appendChild(script); 50 } 51 52 // load delegate 53 loadDelegateScript(); 54 55 return { 56 use: function() { 57 var args = Array.prototype.slice.call(arguments); 58 if (delegateLoaded) { 59 return $Lightning._delegate.use.apply(this, args); 60 } else { 61 // queue the request 62 return callQueue.push(args); 63 } 64 }, 65 createComponent: function() { 66 return $Lightning._delegate.createComponent.apply(this, Array.prototype.slice.call(arguments)); 67 }, 68 getApplication: function() { 69 return $Lightning._delegate.getApplication.apply(this, Array.prototype.slice.call(arguments)); 70 }, 71 lightningLoaded: function() { 72 return $Lightning._delegate.lightningLoaded.apply(this, Array.prototype.slice.call(arguments)); 73 }, 74 ready: function() { 75 return $Lightning._delegate.ready.apply(this, Array.prototype.slice.call(arguments)); 76 } 77 } 78 })(); 79}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.