(function () { 'use strict'; var controllerId = 'shell'; var templatePath = modulesSharedResourcesUrl + 'Templates/'; angular.module('app').controller(controllerId, ['config', '$rootScope', '$location', 'layoutService', 'branding', 'user', '$window', shell]); function shell(config, $rootScope, $location, layoutService, branding, user, $window) { var vm = this; var zenInitialized = false; vm.branding = branding; vm.isMobile = mobile; layoutService.setLeftSideBar(!isTouchDevice()); vm.rightSideBar = layoutService.getRightSideBar; vm.leftSideBar = layoutService.getLeftSideBar; vm.currentPath = $location.$$path; vm.styleTemplate = templatePath + 'styles.html'; vm.noAuthUrls = config.noAuthUrls; vm.toggleLeftSideBar = function () { layoutService.setLeftSideBar(!layoutService.getLeftSideBar()); }; if ($window.innerWidth <= 1240) { layoutService.setLeftSideBar(false); } // Check if touch device function isTouchDevice() { var el = document.createElement('div'); el.setAttribute('ongesturestart', 'return;'); // or try "ontouchstart" return typeof el.ongesturestart === "function"; } vm.scrollFunction = function () { if (document.body.scrollTop > 20 || document.documentElement.scrollTop > 20) { return "block"; } else { return "none"; } }; vm.topFunction = function () { document.body.scrollTop = 0; document.documentElement.scrollTop = 0; }; function loadZendeskWidget() { user.getProfile(true).then(function (theUser) { // Open the help widget window.zESettings = { webWidget: { color: { theme: vm.branding.secondaryColour, launcherText: vm.branding.secondaryColourText, }, contactForm: { attachments: false }, } }; window.zEmbed || function (e, t) { var n, o, d, i, s, a = [], r = document.createElement("iframe"); window.zEmbed = function () { a.push(arguments) }, window.zE = window.zE || window.zEmbed, r.src = "javascript:false", r.title = "", r.role = "presentation", (r.frameElement || r).style.cssText = "display: none", d = document.getElementsByTagName("script"), d = d[d.length - 1], d.parentNode.insertBefore(r, d), i = r.contentWindow, s = i.document; try { o = s } catch (e) { n = document.domain, r.src = 'javascript:var d=document.open();d.domain="' + n + '";void(0);', o = s } o.open()._l = function () { var e = this.createElement("script"); n && (this.domain = n), e.id = "js-iframe-async", e.src = "https://assets.zendesk.com/embeddable_framework/main.js", this.t = +new Date, this.zendeskHost = config.zendeskHost, this.zEQueue = a, this.body.appendChild(e) }, o.write(''), o.close() }(); zE(function () { zE.identify({ name: theUser.firstName + ' ' + theUser.lastName, email: theUser.email.email }); if ($location.$$path == '/backpack') { zE.setHelpCenterSuggestions({ labels: ['Backpack'] }) } if ($location.$$path == '/dashboard') { zE.setHelpCenterSuggestions({ labels: ['Dashboard'] }) } zenInitialized = true; }); }); } $rootScope.$on('$routeChangeStart', function (event, next, current) { vm.currentPath = $location.$$path; var labels = null; if (vm.currentPath == '/dashboard') { labels = ['Dashboard']; } if (vm.currentPath == '/reporting') { labels = ['Reporting']; } if (vm.currentPath == '/issuers') { labels = ['Badges', 'Issuers', 'CreateIssuer']; } if (vm.currentPath == '/graphics') { labels = ['Badges', 'BadgeGraphic']; } if (vm.currentPath == '/graphics') { labels = ['Badges', 'BadgeGraphic']; } if (vm.currentPath == '/badges') { labels = ['Badges', 'CreateBadge']; } if (vm.currentPath == '/issue') { labels = ['Badges', 'IssueBadge']; } if (vm.currentPath == '/organisations') { labels = ['Organisation', 'Group']; } if (vm.currentPath == '/users') { labels = ['Users']; } if (vm.currentPath == '/createuser') { labels = ['CreateUser']; } if (vm.currentPath == '/key') { labels = ['API']; } if (vm.currentPath == '/rules') { labels = ['Rules']; } if (vm.currentPath == '/rules/manage') { labels = ['ManageRule']; } if (vm.currentPath == '/branding') { labels = ['Branding']; } if (vm.currentPath == '/landing') { labels = ['Landing']; } if (vm.currentPath == '/templates') { labels = ['EmailTemplates']; } if (vm.currentPath == '/templates/manage') { labels = ['ManageEmailTemplates']; } if (vm.currentPath == '/roles') { labels = ['Roles']; } if (vm.currentPath.includes('roles/manage')) { labels = ['CreateRole']; } if (vm.currentPath == '/subscription/details') { labels = ['Subscription']; } if (vm.currentPath == '/subscription/upgrade') { labels = ['SubscriptionChange']; } if (vm.currentPath == '/backpack ') { labels = ['Backpack']; } if (vm.currentPath == '/collections ') { labels = ['Backpack', 'BakpackCollection']; } if (zenInitialized) { zE(function () { if (labels) { zE.setHelpCenterSuggestions({ labels: labels }); } else { zE.setHelpCenterSuggestions({ search: vm.currentPath }); } }); } }); if (branding.suppressHelpWidget !== 'yes' && config.zendeskHost) loadZendeskWidget(); }; })();