1/// <reference path="../../shared/ts/jquery.d.ts" /> 2/// <reference path="../../shared/ts/dotgolf.vue.d.ts" /> 3/// <reference path="../base-control-model.ts" /> 4/// <reference path="../models/menu-control-model.ts" /> 5var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) { 6 if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) { 7 if (ar || !(i in from)) { 8 if (!ar) ar = Array.prototype.slice.call(from, 0, i); 9 ar[i] = from[i]; 10 } 11 } 12 return to.concat(ar || Array.prototype.slice.call(from)); 13}; 14var VueHelper; 15(function (VueHelper) { 16 VueHelper.useDebouncedRef = function (value, delay) { 17 if (delay === void 0) { delay = 200; } 18 var timeout; 19 return customRef(function (track, trigger) { 20 return { 21 get: function () { 22 track(); 23 return value; 24 }, 25 set: function (newValue) { 26 clearTimeout(timeout); 27 timeout = setTimeout(function () { 28 value = newValue; 29 trigger(); 30 }, delay); 31 } 32 }; 33 }); 34 }; 35 VueHelper.groupBy = function (arr, key) { 36 return arr.reduce(function (obj, x) { 37 (obj[x[key]] = obj[x[key]] || []).push(x); 38 return obj; 39 }, {}); 40 }; 41 VueHelper.toggleClass = function (element, className) { 42 if (!element || !className) { 43 return; 44 } 45 var classString = element.className, nameIndex = classString.indexOf(className); 46 if (nameIndex == -1) { 47 classString += ' ' + className; 48 } 49 else { 50 classString = classString.substr(0, nameIndex) + classString.substr(nameIndex + className.length); 51 } 52 element.className = classString.trim(); 53 }; 54 VueHelper.addClass = function (element, className) { 55 if (!element || !className) { 56 return; 57 } 58 var classString = element.className, nameIndex = classString.indexOf(className); 59 if (nameIndex == -1) { 60 classString += ' ' + className; 61 } 62 element.className = classString.trim(); 63 }; 64 VueHelper.removeClass = function (element, className) { 65 if (!element || !className) { 66 return; 67 } 68 element.classList.remove(className); 69 }; 70 VueHelper.toggleAccordion = function (event, parentClass, contentClass, activeClass) { 71 var parentElement = event.target.parentElement.closest(parentClass); 72 var wrapper = parentElement.querySelector(contentClass); 73 if (VueHelper.hasClass(parentElement, activeClass)) { 74 VueHelper.slideUp(wrapper); 75 } 76 else { 77 VueHelper.slideDown(wrapper); 78 } 79 VueHelper.toggleClass(parentElement, activeClass); 80 return VueHelper.hasClass(parentElement, activeClass); 81 }; 82 VueHelper.hasClass = function (element, className) { 83 return (' ' + element.className + ' ').indexOf(' ' + className + ' ') > -1; 84 }; 85 VueHelper.slideUp = function (target, duration) { 86 if (duration === void 0) { duration = 100; } 87 target.style.transitionProperty = 'height, margin, padding, opacity'; 88 target.style.transitionDuration = duration + 'ms'; 89 target.style.boxSizing = 'border-box'; 90 target.style.height = target.offsetHeight + 'px'; 91 target.offsetHeight; 92 target.style.overflow = 'hidden'; 93 target.style.height = 0; 94 target.style.opacity = 0; 95 target.style.paddingTop = 0; 96 target.style.paddingBottom = 0; 97 target.style.marginTop = 0; 98 target.style.marginBottom = 0; 99 window.setTimeout(function () { 100 target.style.display = 'none'; 101 target.style.removeProperty('height'); 102 target.style.removeProperty('padding-top'); 103 target.style.removeProperty('padding-bottom'); 104 target.style.removeProperty('margin-top'); 105 target.style.removeProperty('margin-bottom'); 106 target.style.removeProperty('overflow'); 107 target.style.removeProperty('transition-duration'); 108 target.style.removeProperty('transition-property'); 109 }, duration); 110 }; 111 VueHelper.slideDown = function (target, duration) { 112 if (duration === void 0) { duration = 100; } 113 target.style.removeProperty('display'); 114 var display = window.getComputedStyle(target).display; 115 if (display === 'none') 116 display = 'block'; 117 target.style.display = display; 118 var height = target.offsetHeight; 119 target.style.overflow = 'hidden'; 120 target.style.height = 0; 121 target.style.opacity = 0; 122 target.style.paddingTop = 0; 123 target.style.paddingBottom = 0; 124 target.style.marginTop = 0; 125 target.style.marginBottom = 0; 126 target.offsetHeight; 127 target.style.boxSizing = 'border-box'; 128 target.style.transitionProperty = "height, margin, padding, opacity"; 129 target.style.transitionDuration = duration + 'ms'; 130 target.style.height = height + 'px'; 131 target.style.opacity = '1'; 132 target.style.removeProperty('padding-top'); 133 target.style.removeProperty('padding-bottom'); 134 target.style.removeProperty('margin-top'); 135 target.style.removeProperty('margin-bottom'); 136 window.setTimeout(function () { 137 target.style.removeProperty('height'); 138 target.style.removeProperty('overflow'); 139 target.style.removeProperty('transition-duration'); 140 target.style.removeProperty('transition-property'); 141 }, duration); 142 }; 143 VueHelper.slideToggle = function (target, duration) { 144 if (duration === void 0) { duration = 100; } 145 if (window.getComputedStyle(target).display === 'none') { 146 return VueHelper.slideDown(target, duration); 147 } 148 else { 149 return VueHelper.slideUp(target, duration); 150 } 151 }; 152 VueHelper.getParameterValues = function (param) { 153 var url = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&'); 154 for (var i = 0; i < url.length; i++) { 155 var urlparam = url[i].split('='); 156 if (urlparam[0] == param) { 157 return urlparam[1]; 158 } 159 } 160 }; 161 VueHelper.buildMenuTree = function (menuItems, menuGroup, level, parentMenuId) { 162 var filteredMenuItems = menuItems.filter(function (menu) { return menu.MenuLevel === level && menu.MenuGroup === menuGroup && (!parentMenuId || menu.ParentMenuId === parentMenuId); }); 163 return filteredMenuItems.map(function (menu) { return ({ 164 Menu: menu, 165 Submenus: VueHelper.buildMenuTree(menuItems, menuGroup, level
165+ 1, menu.MenuId), 166 }); }); 167 }; 168 /** 169 * Dynamically loads a local css file into the browser, checks for existing file via id. 170 */ 171 VueHelper.loadCss = function (id, cssLocalPath) { 172 if (!VueHelper.isPathLocal(cssLocalPath)) { 173 return; 174 } 175 if (document.getElementById(id) !== null) { 176 return; 177 } 178 var head = document.getElementsByTagName('head')[0]; 179 var link = document.createElement('link'); 180 link.setAttribute("id", id); 181 link.setAttribute("rel", "stylesheet"); 182 link.setAttribute("type", "text/css"); 183 link.setAttribute("href", cssLocalPath); 184 // Append link element to HTML head 185 head.appendChild(link); 186 }; 187 /** 188 * Dynamically loads a local javaScript file into the browser, checks for existing file via id. 189 */ 190 VueHelper.loadJs = function (id, jsLocalPath, onLoad) { 191 if (!VueHelper.isPathLocal(jsLocalPath)) { 192 return; 193 } 194 var existingScript = document.getElementById(id); 195 if (existingScript !== null) { 196 if (typeof (onLoad) === "undefined") 197 return; 198 existingScript.remove(); 199 } 200 var script = document.createElement('script'); 201 script.setAttribute('src', jsLocalPath); 202 script.setAttribute('id', id); 203 document.body.appendChild(script); 204 if (typeof (onLoad) === "undefined") { 205 return; 206 } 207 script.onload = function () { return onLoad(); }; 208 }; 209 /** 210 * Checks a javascript source if already in head tag. 211 */ 212 VueHelper.isScriptInHead = function (src) { 213 var headScripts = document.head.getElementsByTagName('script'); 214 for (var i = 0; i < headScripts.length; i++) { 215 if (headScripts[i].src === src) { 216 return true; // Found the script 217 } 218 } 219 return false; // Script not found 220 }; 221 VueHelper.isPathLocal = function (path) { 222 var url = new URL(path, window.location.href); 223 // Check if the origin of the URL matches the current window's origin. 224 return url.origin === window.location.origin; 225 }; 226 VueHelper.generateUID = function () { 227 return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx' 228 .replace(/[xy]/g, function (c) { 229 var r = Math.random() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8); 230 return v.toString(16); 231 }); 232 }; 233 VueHelper.openFileManager = function (fieldName, additionalParams) { 234 var w = 1000; 235 var h = 700; 236 var left = (screen.width / 2) - (w / 2); 237 var top = (screen.height / 2) - (h / 2); 238 var params = "?fieldName=".concat(fieldName); 239 if (additionalParams) { 240 params += additionalParams; 241 } 242 var windowFeatures = "menubar=no,location=no,resizable=yes,scrollbars=yes,status=no,width=".concat(w, ",height=").concat(h, ",top=").concat(top, ",left=").concat(left); 243 window.open("/FileManager.aspx".concat(params), "File Manager", windowFeatures); 244 }; 245 VueHelper.removeDuplicateObjects = function (array, property) { 246 var uniqueIds = []; 247 var unique = array.filter(function (element) { 248 var isDuplicate = uniqueIds.indexOf(element[property]) !== -1; 249 if (!isDuplicate) { 250 uniqueIds.push(element[property]); 251 return true; 252 } 253 return false; 254 }); 255 return unique; 256 }; 257 VueHelper.nameOf = function (name) { return name; }; 258 /** 259 * Check for the availability of a global variable before execute 260 */ 261 VueHelper.whenAvailable = function (name, callback) { 262 var interval = 10; // ms 263 setTimeout(function () { 264 if (window[name]) { 265 callback(window[name]); 266 } 267 else { 268 VueHelper.whenAvailable(name, callback); 269 } 270 }, interval); 271 }; 272 /** 273 * Check for the DOM visibility of an element before execute 274 */ 275 VueHelper.whenElementAvailable = function (elementId, callback) { 276 var interval = 100; // ms 277 setTimeout(function () { 278 var element = document.getElementById(elementId); 279 if (element) { 280 callback(element); 281 } 282 else { 283 VueHelper.whenElementAvailable(elementId, callback); 284 } 285 }, interval); 286 }; 287 VueHelper.removeHyphensAndCapitalize = function (inputString) { 288 // Split the string by hyphens 289 var words = inputString.split('-'); 290 // Capitalize the first letter of each word 291 var capitalizedWords = words.map(function (word) { 292 return word.charAt(0).toUpperCase() + word.slice(1); 293 }); 294 // Join the words back together 295 return capitalizedWords.join(''); 296 }; 297 VueHelper.toFriendlyUrl = function (inputString) { 298 if (inputString) { 299 return inputString.replace(/&/g, "and").replace(/[^a-z0-9_]+/gi, '-').replace(/^-|-$/g, '').toLowerCase(); 300 } 301 }; 302 /** 303 * Usually for name/s conversion 304 */ 305 VueHelper.toTitleCase = function (str) { 306 if (!str || str.trim().length <= 0) 307 return ''; 308 return str.toLowerCase() 309 .split(' ') 310 .map(function (word) { return word.charAt(0).toUpperCase() + word.slice(1); }) 311 .join(' '); 312 }; 313 /** 314 * Only capitalise first letter of first word 315 */ 316 VueHelper.toFirstUpper = function (str) { 317 if (!str || str.trim().length <= 0) 318 return ''; 319 return str.trim().charAt(0).toUpperCase() + str.trim().slice(1).toLowerCase(); 320 }; 321 VueHelper.isImageExists = function (imgUrl, callback) { 322 if (!imgUrl) { //performance check 323 callback(false); 324 } 325 else { 326 var img = new Image(); 327 img.src = imgUrl; 328 if (img.complete) { 329 callback(true); 330 } 331 else { 332 img.onload = function () { callback(true); }; 333 img.onerror = function () { callback(false); }; 334 } 335 } 336 }; 337 VueHelper.isFloat = function (n) { 338 return Number(n) === n && n % 1 !== 0; 339 }; 340 VueHelper.isInt = function (n) { 341 return Number(n) === n && n % 1 === 0; 342 }; 343 VueHelper.enableDisableButton = function (isTrue, btnClassName) { 344 var ele = $(btnClassName); 345 if (isTrue) { 346 ele.removeAttr("disabled"); 347 } 348 else { 349 ele.prop("disabled", true); 350 } 351 }; 352 var boundaryCount = ref(1); 353 var siblingCount = ref(1); 354 VueHelper.initCachePaging = function (currentPage, totalPages) { 355 var range = function (start, end) { 356 var length = end - start + 1; 357 //@ts-ignore type checking warning 358 return Array.from({ length: length }, function (_, i) { return start + i; }); 359 }; 360 var startPages = range(1, Math.floor(Math.min(boundaryCount.value, totalPages))); 361 var endPages = range(Math.floor(Math.max(totalPages - boundaryCount.value + 1, boundaryCount.value + 1)), totalPages); 362 var siblingsStart = Math.floor(Math.max(Math.min( 363 // natural start 364 currentPage - siblingCount.value, 365 // lower boundary when current is high 366 totalPages - boundaryCount.value - siblingCount.value * 2 - 1), 367 // greater than startPages 368 boundaryCount.value + 2)); 369 var siblingsEnd = Math.floor(Math.min(Math.max( 370 // natural end 371 currentPage + siblingCount.value, 372 // upper boundary when current is low 373 boundaryCount.value + siblingCount.value * 2 + 2), 374 // Less than endPages 375 endPages.length > 0 ? endPages[0] - 2 : totalPages - 1)); 376 return __spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], startPages, true), (siblingsStart >
376 boundaryCount.value + 2 377 ? ['...'] 378 : (boundaryCount.value + 1 < totalPages - boundaryCount.value ? [boundaryCount.value + 1] : [])), true), range(siblingsStart, siblingsEnd), true), (siblingsEnd < totalPages - boundaryCount.value - 1 379 ? ['...'] 380 : (totalPages - boundaryCount.value > boundaryCount.value ? [totalPages - boundaryCount.value] : [])), true), endPages, true); 381 }; 382 VueHelper.parseDate = function (dateToParse) { 383 var dateToText = dateToParse.split('/'); 384 return new Date(Number(dateToText[2]), Number(dateToText[1]) - 1, Number(dateToText[0])); 385 }; 386 VueHelper.initTotalPages = function (totalRecords, pageSize) { 387 var pageN = totalRecords / pageSize; 388 return totalRecords > pageSize 389 ? Math.floor(pageN) + (VueHelper.isFloat(pageN) ? 1 : 0) 390 : ((totalRecords > 0 && totalRecords <= pageSize) ? 1 : 0); 391 }; 392 VueHelper.getEditButton = function (controlName, pageControlId, controlLabel, adminPath) { 393 if (controlName === void 0) { controlName = "Control Block"; } 394 if (controlLabel === void 0) { controlLabel = ""; } 395 if (adminPath === void 0) { adminPath = "admin-control"; } 396 var mode = VueHelper.getParameterValues("mode"); 397 var pnlAdmin = document.getElementById("pnlAdmin"); 398 var editMode = "&mode=edit";
399 if (controlLabel && controlLabel != "") { 400 controlName = controlLabel; 401 } 402 if (adminPath === "admin-control") { 403 editMode = ""; 404 } 405 if (pnlAdmin !== null && mode == "edit") { 406 return "<a class=\"admin__edit-btn\" target=\"_blank\" href=\"/".concat(adminPath, "?pcid=").concat(pageControlId).concat(editMode, "\">Edit ").concat(controlName, "</a>"); 407 } 408 return null; 409 }; 410 /** 411 * Returns the date object as a string using local conventions 412 * @param dtObject => e.g., 28/02/2024 413 * @param locales => e.g., 'en-NZ' 414 * @returns => i.e., Wednesday, 28 Feb 2024 415 */ 416 VueHelper.toLocaleDTString = function (dtObject, locales) { 417 var dt = VueHelper.parseDate(dtObject); 418 // Request a weekday along with a long date 419 var options = { weekday: "long", year: "numeric", month: "short", day: "numeric", }; 420 //@ts-ignore type checking warning 421 return dt.toLocaleDateString(locales, options); 422 }; 423 VueHelper.setCookie = function (cname, cvalue, exdays) { 424 if (exdays === void 0) { exdays = 100; } 425 var d = new Date(); 426 d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000)); 427 var expires = "expires=" + d.toUTCString(); 428 document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/"; 429 }; 430 VueHelper.getCookie = function (cname) { 431 var name = cname + "="; 432 var decodedCookie = decodeURIComponent(document.cookie); 433 var ca = decodedCookie.split(';'); 434 for (var i = 0; i < ca.length; i++) { 435 var c = ca[i]; 436 while (c.charAt(0) == ' ') { 437 c = c.substring(1); 438 } 439 if (c.indexOf(name) == 0) { 440 return c.substring(name.length, c.length); 441 } 442 } 443 return ""; 444 }; 445 VueHelper.validateEmail = function (email) { 446 return String(email) 447 .toLowerCase() 448 .match(/^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|.(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/); 449 }; 450 VueHelper.arrPrepend = function (value, array) { 451 var newArray = array.slice(); 452 newArray.unshift(value); 453 return newArray; 454 }; 455 VueHelper.scrollTo = function (destination, offset, duration, easing, callback) { 456 if (offset === void 0) { offset = 0; } 457 if (duration === void 0) { duration = 200; } 458 if (easing === void 0) { easing = 'linear'; } 459 if (callback === void 0) { callback = null; } 460 var easings = { 461 linear: function (t) { 462 return t; 463 }, 464 easeInQuad: function (t) { 465 return t * t; 466 }, 467 easeOutQuad: function (t) { 468 return t * (2 - t); 469 }, 470 easeInOutQuad: function (t) { 471 return t < 0.5 ? 2 * t * t : -1 + (4 - 2 * t) * t; 472 }, 473 easeInCubic: function (t) { 474 return t * t * t; 475 }, 476 easeOutCubic: function (t) { 477 return (--t) * t * t + 1; 478 }, 479 easeInOutCubic: function (t) { 480 return t < 0.5 ? 4 * t * t * t : (t - 1) * (2 * t - 2) * (2 * t - 2) + 1; 481 }, 482 easeInQuart: function (t) { 483 return t * t * t * t; 484 }, 485 easeOutQuart: function (t) { 486 return 1 - (--t) * t * t * t; 487 }, 488 easeInOutQuart: function (t) { 489 return t < 0.5 ? 8 * t * t * t * t : 1 - 8 * (--t) * t * t * t; 490 }, 491 easeInQuint: function (t) { 492 return t * t * t * t * t; 493 }, 494 easeOutQuint: function (t) { 495 return 1 + (--t) * t * t * t * t; 496 }, 497 easeInOutQuint: function (t) { 498 return t < 0.5 ? 16 * t * t * t * t * t : 1 + 16 * (--t) * t * t * t * t; 499 } 500 }; 501 var start = window.pageYOffset; 502 var startTime = 'now' in window.performance ? performance.now() : new Date().getTime(); 503 var documentHeight = Math.max(document.body.scrollHeight, document.body.offsetHeight, document.documentElement.clientHeight, document.documentElement.scrollHeight, document.documentElement.offsetHeight); 504 var windowHeight = window.innerHeight || document.documentElement.clientHeight || document.getElementsByTagName('body')[0].clientHeight; 505 var destinationOffset = typeof destination === 'number' ? destination : destination.offsetTop + offset; 506 var destinationOffsetToScroll = Math.round(documentHeight - destinationOffset < windowHeight ? documentHeight - windowHeight : destinationOffset); 507 if ('requestAnimationFrame' in window === false) { 508 window.scroll(0, destinationOffsetToScroll); 509 if (callback) { 510 callback(); 511 } 512 return; 513 } 514 var animationId; 515 var userScrolled = false;
516 var tolerance = 5; // pixels tolerance for mobile browsers 517 var maxDuration = duration + 500; // Add 500ms buffer to prevent infinite loops 518 // Cancel animation if user starts scrolling 519 var cancelOnUserScroll = function () { 520 userScrolled = true; 521 }; 522 // Add event listeners to detect user interaction 523 window.addEventListener('wheel', cancelOnUserScroll, { passive: true }); 524 window.addEventListener('touchstart', cancelOnUserScroll, { passive: true }); 525 var cleanup = function () { 526 if (animationId) { 527 cancelAnimationFrame(animationId); 528 } 529 window.removeEventListener('wheel', cancelOnUserScroll); 530 window.removeEventListener('touchstart', cancelOnUserScroll); 531 }; 532 var scroll = function () { 533 var now = 'now' in window.performance ? performance.now() : new Date().getTime(); 534 var elapsed = now - startTime; 535 var time = Math.min(1, elapsed / duration); 536 var timeFunction = easings[easing](time); 537 var currentPosition = Math.ceil((timeFunction * (destinationOffsetToScroll - start)) + start); 538 window.scroll(0, currentPosition); 539 var currentScroll = window.pageYOffset; 540 var isComplete = time >= 1; 541 var isCloseEnough = Math.abs(currentScroll - destinationOffsetToScroll) <= tolerance; 542 var hasTimedOut = elapsed > maxDuration; 543 // Exit conditions: animation complete, close enough to target, user scrolled, or timeout 544 if (isComplete || isCloseEnough || userScrolled || hasTimedOut) { 545 cleanup(); 546 // Ensure we're at the exact destination if animation completed normally 547 if (!userScrolled && !hasTimedOut) { 548 window.scroll(0, destinationOffsetToScroll); 549 } 550 if (callback) { 551 callback(); 552 } 553 return; 554 } 555 animationId = requestAnimationFrame(scroll); 556 }; 557 scroll(); 558 }; 559})(VueHelper || (VueHelper = {}));
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.