UNPKG

@stratusjs/idx

Version:

AngularJS idx/property Service and Components bundle to be used as an add on to StratusJS

1 lines 1.84 kB
System.register(["@stratusjs/runtime/stratus","@stratusjs/core/dom","@stratusjs/angularjs/services/model","@stratusjs/angularjs/services/collection"],function(exports_1,context_1){"use strict";var stratus_1,dom_1;context_1&&context_1.id;return{setters:[function(stratus_1_1){stratus_1=stratus_1_1},function(dom_1_1){dom_1=dom_1_1},function(_1){},function(_2){}],execute:function(){stratus_1.Stratus.Services.ListTrac=["$provide",$provide=>{$provide.factory("ListTrac",($q,$window)=>{const eventQueue=[];let LT,listTracLoaded=!1,listTracPending=!1,listTracAccountId="",eventTypes={};async function loadListTrac(){if(listTracAccountId){if(!listTracPending&&!listTracLoaded)try{listTracPending=!0,await dom_1.DOMComplete();const jsFile=$window.document.createElement("script");jsFile.type="application/javascript",jsFile.async=!0,jsFile.src=`https://code.listtrac.com/monitor.ashx?nonjq=1&acct=${listTracAccountId}`,jsFile.onload=()=>async function(){Object.prototype.hasOwnProperty.call($window,"_LT")&&void 0!==$window._LT&&null!==$window._LT?(eventTypes=$window._eventType,LT=$window._LT,listTracLoaded=!0,listTracPending=!1,processEventQueue()):(listTracLoaded=!1,console.warn("ListTrac failed to load"));listTracPending=!1}(),stratus_1.Stratus.Select("head").append(jsFile)}catch(e){console.error(e)}}else console.warn("ListTrac Account Id not provided, will not load")}function processEventQueue(){if(listTracLoaded)for(;eventQueue.length>0;)$q(eventQueue.shift());else console.warn("Cannot processEventQueue as ListTrac not loaded")}return{setAccountId:function(accountId){listTracAccountId=accountId},track:async function(eventName,mlsId,postalCode,agentId){var event;await loadListTrac(),event=()=>{LT._trackEvent(eventTypes[eventName],mlsId,postalCode,agentId)},eventQueue.push(event),listTracLoaded&&processEventQueue()}}})}]}}});