(function () { var app = angular.module('app'); // Service for the layout app.factory('layoutService', ['$window', function ($window) { return { // Guess if the app is running on mobile using the screen size isMobile: function () { return $window.innerWidth < 768; } }; }]); // Service for tinycolor app.factory('tinycolor', function () { return window.tinycolor; }); // Service for the zendesk help widget app.factory('zendeskService', ['$rootScope', '$location', 'config', 'branding', 'userService', function ($rootScope, $location, config, branding, userService) { return { loadWidget: function () { if (branding.suppressHelpWidget === 'yes' || !config.zendeskHost) { return; } userService.profile(function (user) { // Open the help widget window.zESettings = { webWidget: { color: { theme: branding.secondaryColour, launcherText: branding.secondaryColourText || "#FFF", }, 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() }(); if (typeof zE != "undefined") { zE(function () { zE.identify({ name: user.firstName + ' ' + user.lastName, email: user.email.email }); if ($location.$$path == '/backpack') { zE.setHelpCenterSuggestions({ labels: ['Backpack'] }) } if ($location.$$path == '/dashboard') { zE.setHelpCenterSuggestions({ labels: ['Dashboard'] }) } }); } }); // Add labels to the helpdesk widget when the route changes $rootScope.$on('$routeChangeStart', function () { var currentPath = $location.$$path; var labels = null; // switch instead //switch (currentPath) { // case '/dashboard': //} if (currentPath == '/dashboard') { labels = ['Dashboard']; } if (currentPath == '/reporting') { labels = ['Reporting']; } if (currentPath == '/issuers') { labels = ['Badges', 'Issuers', 'CreateIssuer']; } if (currentPath == '/graphics') { labels = ['Badges', 'BadgeGraphic']; } if (currentPath == '/graphics') { labels = ['Badges', 'BadgeGraphic']; } if (currentPath == '/badges') { labels = ['Badges', 'CreateBadge']; } if (currentPath == '/issue') { labels = ['Badges', 'IssueBadge']; } if (currentPath == '/organisations') { labels = ['Organisation', 'Group']; } if (currentPath == '/users') { labels = ['Users']; } if (currentPath == '/createuser') { labels = ['CreateUser']; } if (currentPath == '/key') { labels = ['API']; } if (currentPath == '/rules') { labels = ['Rules']; } if (currentPath == '/rules/manage') { labels = ['ManageRule']; } if (currentPath == '/branding') { labels = ['Branding']; } if (currentPath == '/landing') { labels = ['Landing']; } if (currentPath == '/templates') { labels = ['EmailTemplates']; } if (currentPath == '/templates/manage') { labels = ['ManageEmailTemplates']; } if (currentPath == '/roles') { labels = ['Roles']; } if (currentPath.includes('roles/manage')) { labels = ['CreateRole']; } if (currentPath == '/subscription/details') { labels = ['Subscription']; } if (currentPath == '/subscription/upgrade') { labels = ['SubscriptionChange']; } if (currentPath == '/backpack') { labels = ['Backpack']; } if (currentPath == '/collections') { labels = ['Backpack', 'BakpackCollection']; } if (typeof zE != "undefined") { zE(function () { if (labels) { zE.setHelpCenterSuggestions({ labels: labels }); } else { zE.setHelpCenterSuggestions({ search: currentPath }); } }); } }); } }; }]); })();