/** * receive emitted message and broadcast it global to the application * event names must be distinct */ MainApp.run(function($rootScope) { /** show modal window from another controller */ $rootScope.$on('showModal', function(event, args) { $rootScope.$broadcast('handleShowModal', args); }); /** populate modal window contents with any particular values */ $rootScope.$on('populateModalParams', function(event, args) { $rootScope.$broadcast('handlePopulateModalParams', args); }); /** someone clicked the body of the search results, so we hide all the filter dropdowns */ $rootScope.$on('hideSearchFilterDropdowns', function(event, args) { $rootScope.$broadcast('handleHideSearchFilterDropdowns', args); }); /** on page load, GTM is ready for OPT IN/OUT setting the cookie appropriately */ $rootScope.trackingParamsAllowed = false; angular.element(document).ready(function() { /** runtime function to add scripts if they've opted in to 3rd party tracking partners */ function addOptInOnlyScript(url) { var script = document.createElement('script'); script.setAttribute('src', '//static.buydomains.com//?version=2023-01-20-1'); script.setAttribute('type', 'text/javascript'); document.getElementsByTagName('head')[0].appendChild(script); } /** if tracking parameters are allowed, then inject the scripts needed at runtime */ /** and apply the rootScope variable to ng-show HTML elements */ if (document.cookie.indexOf('tracking_params_allowed=true') !== -1) { $rootScope.trackingParamsAllowed = true; $rootScope.$apply(); } }); });