{"version":3,"file":"extranet.min.js","sources":["../../../../Frontend/src/js/page-files/extranet.js"],"sourcesContent":["const FeatureSniffer = new function featureSniffer() {\r\n this.IsIE11 = function isIE11() {\r\n return !!window.MSInputMethodContext && !!document.documentMode;\r\n };\r\n this.ISEdge = function isEdge(){\r\n let userAgent = navigator.userAgent;\r\n // Detect Chromium-based Edge\r\n return (/Edg/.test(userAgent));\r\n };\r\n this.IsIOS = function isIOS() {\r\n const ua = navigator.userAgent;\r\n if (/iPad|iPhone|iPod/.test(ua) ||\r\n (navigator.platform === 'MacIntel' && navigator.maxTouchPoints > 1)) {\r\n return true;\r\n }\r\n return false;\r\n };\r\n this.SupportsCustomScrollbars = function supportsCustomScrollbars() {\r\n // Tested Element\r\n let test = document.createElement('div'),\r\n\r\n // Fake body\r\n fake = false,\r\n root = document.body || (function () {\r\n fake = true;\r\n return document.documentElement.appendChild(document.createElement('body'));\r\n }());\r\n\r\n // Force scrollbar\r\n test.id = '__sb';\r\n test.style.overflow = 'scroll';\r\n test.style.width = '40px';\r\n\r\n // Apply scrollbar style for all vendors\r\n test.innerHTML = '';\r\n\r\n root.appendChild(test);\r\n\r\n // If css scrollbar is supported, than the scrollWidth should not be impacted\r\n const ret = test.scrollWidth == 40;\r\n\r\n // Cleaning\r\n document.body.removeChild(test);\r\n if (fake) {\r\n document.documentElement.removeChild(root);\r\n }\r\n return ret;\r\n };\r\n this.SupportsTouch = function supportsTouch() {\r\n return ((('ontouchstart' in window) ||\r\n (navigator.maxTouchPoints > 0) ||\r\n (navigator.msMaxTouchPoints > 0)));\r\n };\r\n};\r\n\r\nString.prototype.format = function () {\r\n let str = this;\r\n const args = Array.prototype.slice.call(arguments);\r\n if (args.length == 1) {\r\n if (!$.isArray(args[0])) {\r\n str = str.replace('{0}', args[0]);\r\n } else {\r\n for (var i = 0; i < args[0].length; i++) {\r\n str = str.replace(`{${i}}`, args[0][i]);\r\n }\r\n }\r\n } else if (args.length > 1) {\r\n for (i = 0; i < args.length; i++) {\r\n str = str.replace(`{${i}}`, args[i]);\r\n }\r\n }\r\n return str;\r\n};\r\n\r\nconst Extranet = {\r\n Current: {\r\n Culture: $('html').attr('lang'),\r\n IsIE11: FeatureSniffer.IsIE11(),\r\n SupportsTouch: FeatureSniffer.SupportsTouch(),\r\n SupportsCustomScrollbars: FeatureSniffer.SupportsCustomScrollbars(),\r\n IsIOS: FeatureSniffer.IsIOS()\r\n },\r\n ResolveUrl: function resolveUrl(url) {\r\n const basePath = $('body').attr('data-baseurl') || '';\r\n if (url.indexOf(basePath) == -1) {\r\n url = basePath + url;\r\n }\r\n return url;\r\n },\r\n ResolveWebApiControllerUrl: function resolveWebApiControllerUrl(relativeUrl) {\r\n if (typeof (relativeUrl) == 'undefined' || relativeUrl == null) {\r\n relativeUrl = '';\r\n }\r\n const basePath = $('body').attr('data-baseurl') || '';\r\n if (relativeUrl[0] == '/') {\r\n relativeUrl = relativeUrl.substring(1);\r\n }\r\n return `${basePath}/extranet/api/${relativeUrl}`;\r\n },\r\n NewGuid: function newGuid() {\r\n let d = new Date().getTime();\r\n if (window.performance && typeof window.performance.now === 'function') {\r\n d += performance.now(); //use high-precision timer if available\r\n }\r\n const uuid = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {\r\n const r = (d + Math.random() * 16) % 16 | 0;\r\n d = Math.floor(d / 16);\r\n return (c == 'x' ? r : (r & 0x3 | 0x8)).toString(16);\r\n });\r\n return uuid;\r\n },\r\n EntityActions: {},\r\n Init (settings) {\r\n //Misc init stuff\r\n const $html = $('html');\r\n\r\n if (Extranet.Current.SupportsTouch) {\r\n $html.addClass('touch');\r\n } else {\r\n $html.addClass('no-touch');\r\n }\r\n\r\n if (!Extranet.Current.SupportsCustomScrollbars) {\r\n $html.addClass('no-custom-scrollbars');\r\n }\r\n\r\n if (Extranet.Current.IsIOS) {\r\n $html.addClass('ios');\r\n }\r\n\r\n if (Extranet.Current.IsIE11) {\r\n $html.addClass('ie11');\r\n }\r\n\r\n $.ajaxSetup({\r\n statusCode: {\r\n 401 (err) {\r\n Extranet.Dialogs.HideAll();\r\n Extranet.Dialogs.Alert(null, ResourceManager.Get('AjaxLoggedOutError'), function() {\r\n location.reload(true);\r\n });\r\n }\r\n }\r\n });\r\n\r\n new Extranet.WindowScrollHandler({});\r\n\r\n //Misc on page ready stuff\r\n $(function () {\r\n const $body = $('body');\r\n const navigation = document.querySelector('.navigation');\r\n\r\n // Set standby class\r\n setTimeout(() => {\r\n document.body.classList.remove('standby');\r\n }, 0);\r\n\r\n // Navigation toggle\r\n if (navigation) {\r\n const navigationToggles = document.querySelectorAll('[data-action~=\"navigation-toggle\"]');\r\n const burgerNavigationMedia = window.matchMedia('(max-width: 1023px)');\r\n\r\n navigationToggles.forEach(navigationToggle => {\r\n navigationToggle.addEventListener('click', () => {\r\n if (navigation.classList.contains('navigation--open')) {\r\n navigation.classList.remove('navigation--open');\r\n\r\n if (burgerNavigationMedia.matches) {\r\n document.body.classList.remove('no-scroll');\r\n }\r\n } else {\r\n navigation.classList.add('navigation--open');\r\n\r\n if (burgerNavigationMedia.matches) {\r\n document.body.classList.add('no-scroll');\r\n }\r\n }\r\n });\r\n });\r\n\r\n function handleBodyScrollOnResize () {\r\n setTimeout(() => {\r\n if (navigation.classList.contains('navigation--open') && burgerNavigationMedia.matches) {\r\n document.body.classList.add('no-scroll');\r\n } else {\r\n document.body.classList.remove('no-scroll');\r\n }\r\n }, 100);\r\n }\r\n\r\n window.addEventListener('resize', handleBodyScrollOnResize);\r\n window.addEventListener('orientationchange', handleBodyScrollOnResize);\r\n }\r\n\r\n\r\n // Log out triggers\r\n const logoutTriggers = document.querySelectorAll('[data-action~=\"log-out\"]');\r\n logoutTriggers.forEach(logOutTrigger => {\r\n logOutTrigger.addEventListener('click', logoutClickHandler);\r\n });\r\n\r\n function logoutClickHandler(e) {\r\n $body.addClass('busy');\r\n $.ajax({\r\n url: '/extranet/api/applicationuser/logout',\r\n type: 'post',\r\n success (data) {\r\n location.replace('/');\r\n },\r\n error (response) {\r\n Extranet.Dialogs.Alert(null, ResourceManager.Get('GenericAjaxError'));\r\n $body.removeClass('busy');\r\n }\r\n });\r\n return false;\r\n };\r\n\r\n // Log out triggers\r\n const helpDialogToggles = document.querySelectorAll('[data-action~=\"help-dialog-toggle\"]');\r\n helpDialogToggles.forEach(helpDialogToggle => {\r\n helpDialogToggle.addEventListener('click', helpDialogClickHandler);\r\n });\r\n\r\n function helpDialogClickHandler(e) {\r\n const markup = [];\r\n markup.push('
{1}
');\r\n markup.push('');\r\n markup.push(' {3}');\r\n markup.push('
');\r\n markup.push('{0}
'.format(subHeader));\r\n markup.push('{0}
'.format(text));\r\n markup.push('{0}
'.format(text));\r\n markup.push('{0}
'.format(text));\r\n markup.push('