1function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } 2 3function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } 4 5function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } 6 7function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } 8 9/** 10 * SPDX-FileCopyrightText: (c) 2000 Liferay, Inc. https://liferay.com 11 * SPDX-License-Identifier: LGPL-2.1-or-later OR LicenseRef-Liferay-DXP-EULA-2.0.0-2023-06 12 */ 13(function (A) { 14 A.use('aui-base-lang'); 15 var Lang = A.Lang; 16 var EVENT_CLICK = 'click'; 17 var MAP_TOGGLE_STATE = { 18 false: { 19 cssClass: 'controls-hidden', 20 iconCssClass: 'hidden', 21 state: 'hidden' 22 }, 23 true: { 24 cssClass: 'controls-visible', 25 iconCssClass: 'view', 26 state: 'visible' 27 } 28 }; 29 var REGEX_SUB = /\{\s*([^|}]+?)\s*(?:\|([^}]*))?\s*\}/g; 30 var SRC_HIDE_LINK = { 31 src: 'hideLink' 32 }; 33 var STR_RIGHT_SQUARE_BRACKET = ']'; 34 var TPL_LEXICON_ICON = '<svg aria-hidden="true" class="lexicon-icon lexicon-icon-{0} {1}" focusable="false" role="presentation">' + '<use href="' + themeDisplay.getPathThemeImages() + '/clay/icons.svg#{0}" />' + '</svg>'; 35 var Window = { 36 _map: {}, 37 getById: function getById(id) { 38 var instance = this; 39 return instance._map[id]; 40 } 41 }; 42 var Util = { 43 _getEditableInstance: function _getEditableInstance(title) { 44 var editable = Util._EDITABLE; 45 46 if (!editable) { 47 editable = new A.Editable({ 48 after: { 49 contentTextChange: function contentTextChange(event) { 50 var instance = this; 51 52 if (!event.initial) { 53 var title = instance.get('node'); 54 var portletTitleEditOptions = title.getData('portletTitleEditOptions'); 55 Util.savePortletTitle({ 56 doAsUserId: portletTitleEditOptions.doAsUserId, 57 plid: portletTitleEditOptions.plid, 58 portletId: portletTitleEditOptions.portletId, 59 title: event.newVal 60 }); 61 } 62 }, 63 startEditing: function startEditing() { 64 var instance = this; 65 var Layout = Liferay.Layout; 66 67 if (Layout) { 68 instance._dragListener = Layout.getLayoutHandler().on('drag:start', function () { 69 instance.fire('save'); 70 }); 71 } 72 73 var title = instance.get('node'); 74 instance._titleListener = title.on('mouseupoutside', function (event) { 75 var editable = Util._getEditableInstance(title); 76 77 if (!editable.get('boundingBox').contains(event.target)) { 78 editable.save(); 79 } 80 }); 81 }, 82 stopEditing: function stopEditing() { 83 var instance = this; 84 85 if (instance._dragListener) { 86 instance._dragListener.detach(); 87 } 88 89 if (instance._titleListener) { 90 instance._titleListener.detach(); 91 } 92 } 93 }, 94 cssClass: 'lfr-portlet-title-editable', 95 node: title 96 }); 97 editable.get('cancelButton').icon = 'times'; 98 editable.get('saveButton').icon = 'check'; 99 Util._EDITABLE = editable; 100 } 101 102 return editable; 103 }, 104 addInputCancel: function addInputCancel() { 105 A.use('aui-button-search-cancel', function (A) { 106 new A.ButtonSearchCancel({ 107 trigger: 'input[type=password], input[type=search], input.clearable, input.search-query' 108 }); 109 }); 110 111 Util.addInputCancel = function () {}; 112 }, 113 checkAll: function checkAll(form, name, allBox, selectClassName) { 114 if (form) { 115 form = Util.getDOM(form); 116 117 if (typeof form === 'string') { 118 form = document.querySelector(form); 119 } 120 121 allBox = Util.getDOM(allBox); 122 123 if (typeof allBox === 'string') { 124 allBox = document.querySelector(allBox); 125 } 126 127 var selector; 128 129 if (Array.isArray(name)) { 130 selector = 'input[name=' + name.join('], input[name=') + STR_RIGHT_SQUARE_BRACKET; 131 } else { 132 selector = 'input[name=' + name + STR_RIGHT_SQUARE_BRACKET; 133 } 134 135 var allBoxChecked = allBox.checked; 136 var uploadedItems = Array.from(form.querySelectorAll(selector));
137 uploadedItems.forEach(function (item) { 138 if (!item.disabled) { 139 item.checked = allBoxChecked; 140 } 141 }); 142 143 if (selectClassName) { 144 var selectItem = form.querySelector(selectClassName); 145 146 if (allBoxChecked) { 147 selectItem.classList.add('info'); 148 } else { 149 selectItem.classList.remove('info'); 150 } 151 } 152 } 153 }, 154 checkAllBox: function checkAllBox(form, name, allBox) { 155 var totalOn = 0; 156 157 if (form) { 158 form = Util.getDOM(form); 159 160 if (typeof form === 'string') { 161 form = document.querySelector(form); 162 } 163 164 allBox = Util.getDOM(allBox); 165 166 if (typeof allBox === 'string') { 167 allBox = document.querySelector(allBox) || form.querySelector("input[name=\"".concat(allBox, "\"]")); 168 } 169 170 var inputs = Array.from(form.querySelectorAll('input[type=checkbox]')); 171 172 if (!Array.isArray(name)) { 173 name = [name]; 174 } 175 176 var totalBoxes = 0; 177 inputs.forEach(function (input) { 178 if (input.id !== allBox.id || input.id !== allBox.name && name.indexOf(input.name) > -1) { 179 totalBoxes++; 180 181 if (input.checked) { 182 totalOn++; 183 } 184 } 185 }); 186 allBox.checked = totalBoxes === totalOn; 187 } 188 189 return totalOn; 190 }, 191 checkTab: function checkTab(box) { 192 if (document.all && window.event.keyCode == 9) { 193 box.selection = document.selection.createRange(); 194 setTimeout(function () { 195 Util.processTab(box.id); 196 }, 0); 197 } 198 }, 199 disableElements: function disableElements(el) { 200 var currentElement = Util.getElement(el); 201 202 if (currentElement) { 203 var children = currentElement.getElementsByTagName('*'); 204 205 var emptyFnFalse = function emptyFnFalse() { 206 return false; 207 }; 208 209 for (var i = children.length - 1; i >= 0; i--) { 210 var item = children[i]; 211 item.style.cursor = 'default'; 212 item.onclick = emptyFnFalse; 213 item.onmouseover = emptyFnFalse; 214 item.onmouseout = emptyFnFalse; 215 item.onmouseenter = emptyFnFalse; 216 item.onmouseleave = emptyFnFalse; 217 item.action = ''; 218 item.disabled = true; 219 item.href = 'javascript:;'; 220 item.onsubmit = emptyFnFalse; 221 } 222 } 223 }, 224 disableFormButtons: function disableFormButtons(inputs, form) { 225 inputs.attr('disabled', true); 226 inputs.setStyle('opacity', 0.5); 227 228 if (A.UA.gecko) { 229 A.getWin().on('unload', function () { 230 inputs.attr('disabled', false); 231 }); 232 } else if (A.UA.safari) { 233 A.use('node-event-html5', function (A) { 234 A.getWin().on('pagehide', function () { 235 Util.enableFormButtons(inputs, form); 236 }); 237 }); 238 } 239 }, 240 disableToggleBoxes: function disableToggleBoxes(checkBoxId, toggleBoxId, checkDisabled) { 241 var checkBox = document.getElementById(checkBoxId); 242 var toggleBox = document.getElementById(toggleBoxId); 243 244 if (checkBox && toggleBox) { 245 toggleBox.disabled = checkDisabled && checkBox.checked; 246 checkBox.addEventListener(EVENT_CLICK, function () { 247 toggleBox.disabled = !toggleBox.disabled; 248 }); 249 } 250 }, 251 enableFormButtons: function enableFormButtons(inputs) { 252 Util._submitLocked = null; 253 Util.toggleDisabled(inputs, false); 254 }, 255 256 /** 257 * @deprecated As of Athanasius (7.3.x), with no direct replacement 258 */ 259 escapeCDATA: function escapeCDATA(str) { 260 return str.replace(/<!\[CDATA\[|\]\]>/gi, function (match) { 261 var str = ''; 262 263 if (match == ']]>') { 264 str = ']]>'; 265 } else if (match == '<![CDATA[') { 266 str = '<![CDATA['; 267 } 268 269 return str; 270 }); 271 }, 272 forcePost: function forcePost(link) { 273 var currentElement = Util.getElement(link); 274 275 if (currentElement) { 276 var url = currentElement.getAttribute('href'); // LPS-127302 277 278 if (url === 'javascript:;') { 279 return; 280 } 281 282 var newWindow = currentElement.getAttribute('target') == '_blank'; 283 var hrefFm = document.hrefFm; 284 285 if (newWindow) { 286 hrefFm.setAttribute('target', '_blank'); 287 } 288 289 submitForm(hrefFm, url, !newWindow); 290 Util._submitLocked = null; 291 } 292 }, 293 getAttributes: function getAttributes(el, attributeGetter) { 294 var result = null; 295 296 if (el) { 297 el = Util.getDOM(el); 298 299 if (el.jquery) { 300 el = el[0]; 301 } 302 303 result = {}; 304 var getterFn = typeof attributeGetter === 'function'; 305 var getterString = typeof attributeGetter === 'string'; 306 var attrs = el.attributes; 307 var length = attrs.length; 308 309 while (length--) { 310 var attr = attrs[length]; 311 var name = attr.nodeName.toLowerCase(); 312 var value = attr.nodeValue; 313 314 if (getterString) { 315 if (name.indexOf(attributeGetter) === 0) { 316 name = name.substr(attributeGetter.length); 317 } else { 318 continue; 319 } 320 } else if (getterFn) { 321 value = attributeGetter(value, name, attrs); 322 323 if (value === false) { 324 continue; 325 } 326 } 327 328 result[name] = value; 329 } 330 } 331 332 return result; 333 }, 334 getColumnId: function getColumnId(str) { 335 var columnId = str.replace(/layout-column_/, ''); 336 return columnId; 337 }, 338 getGeolocation: function getGeolocation(success, fallback, options) { 339 if (success && navigator.geolocation) { 340 navigator.geolocation.getCurrentPosition(function (position) { 341 success(position.coords.latitude, position.coords.longitude, position); 342 }, fallback, options); 343 } else if (fallback) { 344 fallback(); 345 } 346 }, 347 getLexiconIcon: function getLexiconIcon(icon, cssClass) { 348 var instance = this; 349 var tempElement = document.createElement('div'); 350 tempElement.innerHTML = instance.getLexiconIconTpl(icon, cssClass); 351 return tempElement.firstChild; 352 }, 353 getLexiconIconTpl: function getLexiconIconTpl(icon, cssClass) { 354 return Liferay.Util.sub(TPL_LEXICON_ICON, icon, cssClass || ''); 355 }, 356 getOpener: function getOpener() { 357 var openingWindow = Window._opener; 358 359 if (!openingWindow) { 360 var topUtil = Liferay.Util.getTop().Liferay.Util; 361 var windowName = Liferay.Util.getWindowName(); 362 var dialog = topUtil.Window.getById(windowName); 363 364 if (dialog) { 365 openingWindow = dialog._opener; 366 Window._opener = openingWindow; 367 } 368 } 369 370 return openingWindow || window.opener || window.parent; 371 }, 372 getTop: function getTop() { 373 var topWindow = Util._topWindow; 374 375 if (!topWindow) { 376 var parentWindow = window.parent; 377 var parentThemeDisplay; 378 379 while (parentWindow != window) { 380 try { 381 if (typeof parentWindow.location.href == 'undefined') { 382 break; 383 } 384 385 parentThemeDisplay = parentWindow.themeDisplay; 386 } catch (e) { 387 break; 388 } 389 390 if (!parentThemeDisplay || window.name === 'simulationDeviceIframe') { 391 break; 392 } else if (!parentThemeDisplay.isStatePopUp() || parentWindow == parentWindow.parent) { 393 topWindow = parentWindow; 394 break; 395 } 396 397 parentWindow = parentWindow.parent; 398 } 399 400 if (!topWindow) { 401 topWindow = window; 402 } 403 404 Util._topWindow = topWindow; 405 } 406 407 return topWindow; 408 }, 409 getURLWithSessionId: function getURLWithSessionId(url) { 410 if (!themeDisplay.isAddSessionIdToURL()) { 411 return url; 412 } // LEP-4787 413 414 415 var x = url.indexOf(';'); 416 417 if (x > -1) { 418 return url; 419 } 420 421 var sessionId = ';jsessionid=' + themeDisplay.getSessionId(); 422 x = url.indexOf('?'); 423 424 if (x > -1) { 425 return url.substring(0, x) + sessionId + url.substring(x); 426 } // In IE6, http://www.abc.com;jsessionid=XYZ does not work, but 427 // http://www.abc.com/;jsessionid=XYZ does work. 428 429 430 x = url.indexOf('//'); 431 432 if (x > -1) { 433 var y = url.lastIndexOf('/'); 434 435 if (x + 1 == y) { 436 return url + '/' + sessionId; 437 } 438 } 439 440 return url + sessionId; 441 }, 442 getWindow: function getWindow(id) { 443 if (!id) { 444 id = Util.getWindowName(); 445 } 446 447 return Util.getTop().Liferay.Util.Window.getById(id); 448 }, 449 getWindowName: function getWindowName() { 450 return window.name || Window._name || ''; 451 }, 452 453 /** 454 * @deprecated As of Athanasius (7.3.x), replaced by `window.innerWidth` 455 */ 456 getWindowWidth: function getWindowWidth() { 457 return window.innerWidth; 458 }, 459 460 /** 461 * @deprecated As of Athanasius (7.3.x), replaced by `typeof val === 'function'` 462 */ 463 isFunction: function isFunction(val) { 464 return typeof val === 'function'; 465 }, 466 listCheckboxesExcept: function listCheckboxesExcept(form, except, name, checked) { 467 form = Util.getDOM(form); 468 469 if (typeof form === 'string') { 470 form = document.querySelector(form); 471 } 472 473 var selector = 'input[type=checkbox]'; 474 475 if (name) { 476 selector += '[name=' + name + ']'; 477 } 478 479 var checkboxes = Array.from(form.querySelectorAll(selector)); 480 return checkboxes.reduce(function (prev, item) { 481 var value = item.value; 482 483 if (value && item.name !== except && item.checked === checked && !item.disabled) { 484 prev.push(value); 485 } 486 487 return prev; 488 }, []).join(); 489 }, 490 listCheckedExcept: function listCheckedExcept(form, except, name) { 491 return Util.listCheckboxesExcept(form, except, name, true); 492 }, 493 listSelect: function listSelect(select, delimeter) { 494 select = Util.getElement(select); 495 return Array.from(select.querySelectorAll('option')).reduce(function (prev, item) { 496 var val = item.value; 497 498 if (val) { 499 prev.push(val); 500 } 501 502 return prev; 503 }, []).join(delimeter || ','); 504 }, 505 listUncheckedExcept: function listUncheckedExcept(form, except, name) { 506 return Util.listCheckboxesExcept(form, except, name, false); 507 }, 508 openInDialog: function openInDialog(event, config) { 509 event.preventDefault(); 510 var currentTarget = Util.getElement(event.currentTarget); 511 config = A.mix(A.merge({}, currentTarget.dataset), config); 512 513 if (!config.uri) { 514 config.uri = currentTarget.dataset.href || currentTarget.getAttribute('href'); 515 } 516 517 if (!config.title) { 518 config.title = currentTarget.getAttribute('title'); 519 } 520 521 Liferay.Util.openWindow(config); 522 }, 523 openWindow: function openWindow(config, callback) { 524 config.openingWindow = window; 525 var top = Util.getTop(); 526 var topUtil = top.Liferay.Util; 527 528 topUtil._openWindowProvider(config, callback); 529 }, 530 processTab: function processTab(id) { 531 document.all[id].selection.text = String.fromCharCode(9); 532 document.all[id].focus(); 533 }, 534 535 /** 536 * @deprecated As of Athanasius (7.3.x), with no direct replacement 537 */ 538 randomInt: function randomInt() { 539 return Math.ceil(Math.random() * new Date().getTime()); 540 }, 541 removeEntitySelection: function removeEntitySelection(entityIdString, entityNameString, removeEntityButton, namespace) { 542 var elementByEntityId = document.getElementById("".concat(namespace).concat(entityIdString)); 543 544 if (elementByEntityId) { 545 elementByEntityId.value = 0; 546 } 547 548 var elementByEntityName = document.getElementById("".concat(namespace).concat(entityNameString)); 549 550 if (elementByEntityName) { 551 elementByEntityName.value = ''; 552 } 553 554 Liferay.Util.toggleDisabled(removeEntityButton, true); 555 Liferay.fire('entitySelectionRemoved'); 556 }, 557 reorder: function reorder(box, down) { 558 box = Util.getElement(box); 559 560 if (box) { 561 if (box.getAttribute('selectedIndex') == -1) { 562 box.setAttribute('selectedIndex', 0); 563 } else { 564 var selectedItems = Array.from(box.querySelectorAll('option:checked')); 565 var items = Array.from(box.querySelectorAll('option')); 566 567 if (down) {
568 selectedItems.reverse().forEach(function (item) { 569 var itemIndex = items.indexOf(item); 570 var lastIndex = items.length - 1; 571 572 if (itemIndex === lastIndex) { 573 box.insertBefore(item, box.firstChild); 574 } else { 575 var nextItem = item.nextElementSibling.nextElementSibling; 576 box.insertBefore(item, nextItem); 577 } 578 }); 579 } else { 580 selectedItems.forEach(function (item) { 581 var itemIndex = items.indexOf(item); 582 583 if (itemIndex === 0) { 584 box.appendChild(item); 585 } else { 586 box.insertBefore(item, item.previousElementSibling); 587 } 588 }); 589 } 590 } 591 } 592 }, 593 rowCheckerCheckAllBox: function rowCheckerCheckAllBox(ancestorTable, ancestorRow, checkboxesIds, checkboxAllIds, cssClass) { 594 Util.checkAllBox(ancestorTable, checkboxesIds, checkboxAllIds); 595 596 if (ancestorRow) { 597 ancestorRow.toggleClass(cssClass); 598 } 599 }, 600 savePortletTitle: function savePortletTitle(params) { 601 params = _objectSpread({ 602 doAsUserId: 0, 603 plid: 0, 604 portletId: 0, 605 title: '', 606 url: themeDisplay.getPathMain() + '/portal/update_portlet_title' 607 }, params); 608 var data = { 609 doAsUserId: params.doAsUserId, 610 p_auth: Liferay.authToken, 611 p_l_id: params.plid, 612 portletId: params.portletId, 613 title: params.title 614 }; 615 Liferay.Util.fetch(params.url, { 616 body: Liferay.Util.objectToFormData(data), 617 method: 'POST' 618 }); 619 }, 620 selectFolder: function selectFolder(folderData, namespace) { 621 var folderDataElement = document.getElementById(namespace + folderData.idString); 622 623 if (folderDataElement) { 624 folderDataElement.value = folderData.idValue; 625 } 626 627 var folderNameElement = document.getElementById(namespace + folderData.nameString); 628 629 if (folderNameElement) { 630 folderNameElement.value = this.unescape(folderData.nameValue); 631 } 632 633 var removeFolderButton = document.getElementById("".concat(namespace, "removeFolderButton")); 634 635 if (removeFolderButton) { 636 this.toggleDisabled(removeFolderButton, false); 637 } 638 }, 639 setCursorPosition: function setCursorPosition(el, position) { 640 var instance = this; 641 instance.setSelectionRange(el, position, position); 642 }, 643 setSelectionRange: function setSelectionRange(el, selectionStart, selectionEnd) { 644 el = Util.getDOM(el); 645 646 if (el.jquery) { 647 el = el[0]; 648 } 649 650 if (el.setSelectionRange) { 651 el.focus(); 652 el.setSelectionRange(selectionStart, selectionEnd); 653 } else if (el.createTextRange) { 654 var textRange = el.createTextRange(); 655 textRange.collapse(true); 656 textRange.moveEnd('character', selectionEnd); 657 textRange.moveEnd('character', selectionStart); 658 textRange.select(); 659 } 660 }, 661 showCapsLock: function showCapsLock(event, spanId) { 662 var span = document.getElementById(spanId); 663 664 if (span) { 665 var keyCode = event.keyCode ? event.keyCode : event.which; 666 var shiftKeyCode = keyCode === 16; 667 var shiftKey = event.shiftKey ? event.shiftKey : shiftKeyCode; 668 var display = 'none'; 669 670 if (keyCode >= 65 && keyCode <= 90 && !shiftKey || keyCode >= 97 && keyCode <= 122 && shiftKey) { 671 display = ''; 672 } 673 674 span.style.display = display; 675 } 676 }, 677 678 /** 679 * @deprecated As of Athanasius (7.3.x), with no direct replacement 680 */ 681 sortByAscending: function sortByAscending(a, b) { 682 a = a[1].toLowerCase(); 683 b = b[1].toLowerCase(); 684 685 if (a > b) { 686 return 1; 687 } 688 689 if (a < b) { 690 return -1; 691 } 692 693 return 0; 694 }, 695 sub: function sub(string, data) { 696 if (arguments.length > 2 || _typeof(data) !== 'object' && typeof data !== 'function') { 697 data = Array.prototype.slice.call(arguments, 1); 698 } 699 700 return string.replace ? string.replace(REGEX_SUB, function (match, key) { 701 return data[key] === undefined ? match : data[key]; 702 }) : string; 703 }, 704 submitCountdown: 0, 705 submitForm: function submitForm(form) { 706 form.submit(); 707 }, 708 709 /** 710 * @deprecated As of Athanasius (7.3.x), replaced by `parseInt()` 711 */ 712 toNumber: function toNumber(value) { 713 return parseInt(value, 10) || 0; 714 }, 715 toggleBoxes: function toggleBoxes(checkBoxId, toggleBoxId, displayWhenUnchecked, toggleChildCheckboxes) { 716 var checkBox = document.getElementById(checkBoxId); 717 var toggleBox = document.getElementById(toggleBoxId); 718 719 if (checkBox && toggleBox) { 720 var checked = checkBox.checked; 721 722 if (displayWhenUnchecked) { 723 checked = !checked; 724 } 725 726 if (checked) { 727 toggleBox.classList.remove('hide'); 728 } else { 729 toggleBox.classList.add('hide'); 730 } 731 732 checkBox.addEventListener(EVENT_CLICK, function () { 733 toggleBox.classList.toggle('hide'); 734 735 if (toggleChildCheckboxes) { 736 var childCheckboxes = toggleBox.querySelectorAll('input[type=checkbox]');
737 childCheckboxes.forEach(function (childCheckbox) { 738 childCheckbox.checked = checkBox.checked; 739 }); 740 } 741 }); 742 } 743 }, 744 toggleRadio: function toggleRadio(radioId, showBoxIds, hideBoxIds) { 745 var radioButton = document.getElementById(radioId); 746 747 if (radioButton) { 748 var showBoxes; 749 750 if (showBoxIds) { 751 if (Array.isArray(showBoxIds)) { 752 showBoxIds = showBoxIds.join(',#'); 753 } 754 755 showBoxes = document.querySelectorAll('#' + showBoxIds); 756 showBoxes.forEach(function (showBox) { 757 if (radioButton.checked) { 758 showBox.classList.remove('hide'); 759 } else { 760 showBox.classList.add('hide'); 761 } 762 }); 763 } 764 765 radioButton.addEventListener('change', function () { 766 if (showBoxes) { 767 showBoxes.forEach(function (showBox) { 768 showBox.classList.remove('hide'); 769 }); 770 } 771 772 if (hideBoxIds) { 773 if (Array.isArray(hideBoxIds)) { 774 hideBoxIds = hideBoxIds.join(',#'); 775 } 776 777 var hideBoxes = document.querySelectorAll('#' + hideBoxIds); 778 hideBoxes.forEach(function (hideBox) { 779 hideBox.classList.add('hide'); 780 }); 781 } 782 }); 783 } 784 }, 785 786 /* 787 * @deprecated As of Athanasius (7.3.x), with no direct replacement 788 */ 789 toggleSearchContainerButton: function toggleSearchContainerButton(buttonId, searchContainerId, form, ignoreFieldName) { 790 A.one(searchContainerId).delegate(EVENT_CLICK, function () { 791 Util.toggleDisabled(buttonId, !Util.listCheckedExcept(form, ignoreFieldName)); 792 }, 'input[type=checkbox]'); 793 }, 794 toggleSelectBox: function toggleSelectBox(selectBoxId, value, toggleBoxId) { 795 var selectBox = document.getElementById(selectBoxId); 796 var toggleBox = document.getElementById(toggleBoxId); 797 798 if (selectBox && toggleBox) { 799 var dynamicValue = typeof value === 'function'; 800 801 var toggle = function toggle() { 802 var currentValue = selectBox.value; 803 var visible = value == currentValue; 804 805 if (dynamicValue) { 806 visible = value(currentValue, value); 807 } 808 809 if (visible) { 810 toggleBox.classList.remove('hide'); 811 } else { 812 toggleBox.classList.add('hide'); 813 } 814 }; 815 816 toggle(); 817 selectBox.addEventListener('change', toggle); 818 } 819 } 820 }; 821 Liferay.provide(Util, 'afterIframeLoaded', function (event) { 822 var nodeInstances = A.Node._instances; 823 var docEl = event.doc; 824 var docUID = docEl._yuid; 825 826 if (docUID in nodeInstances) { 827 delete nodeInstances[docUID]; 828 } 829 830 var iframeDocument = A.one(docEl); 831 var iframeBody = iframeDocument.one('body'); 832 var dialog = event.dialog; 833 var lfrFormContent = iframeBody.one('.lfr-form-content'); 834 iframeBody.addClass('dialog-iframe-popup'); 835 836 if (lfrFormContent && iframeBody.one('.button-holder.dialog-footer')) { 837 iframeBody.addClass('dialog-with-footer'); 838 var stagingAlert = iframeBody.one('.portlet-body > .lfr-portlet-message-staging-alert'); 839 840 if (stagingAlert) { 841 stagingAlert.remove(); 842 lfrFormContent.prepend(stagingAlert); 843 } 844 } 845 846 iframeBody.addClass(dialog.iframeConfig.bodyCssClass); 847 event.win.focus(); 848 var iframeWindow = event.win; 849 850 if (iframeWindow.Liferay.SPA) { 851 var beforeScreenFlipHandler = iframeWindow.Liferay.on('beforeScreenFlip', function () { 852 iframeWindow.document.body.classList.add('dialog-iframe-popup'); 853 }); 854 855 iframeWindow.onunload = function () { 856 if (beforeScreenFlipHandler) { 857 iframeWindow.Liferay.detach(beforeScreenFlipHandler); 858 } 859 }; 860 } 861 862 var cancelEventHandler = iframeBody.delegate(EVENT_CLICK, function (event) { 863 dialog.set('visible', false, event.currentTarget.hasClass('lfr-hide-dialog') ? SRC_HIDE_LINK : null); 864 cancelEventHandler.detach(); 865 iframeDocument.purge(true); 866 }, '.btn-cancel,.lfr-hide-dialog'); 867 Liferay.fire('modalIframeLoaded', { 868 src: event.dialog.iframe.node.getAttribute('src') 869 }); 870 }, ['aui-base']); 871 Liferay.provide(Util, 'openDDMPortlet', function (config, callback) { 872 var defaultValues = { 873 eventName: 'selectStructure' 874 }; 875 config = A.merge(defaultValues, config); 876 var params = { 877 classNameId: config.classNameId, 878 classPK: config.classPK, 879 doAsGroupId: config.doAsGroupId || themeDisplay.getScopeGroupId(), 880 eventName: config.eventName, 881 groupId: config.groupId, 882 mvcPath: config.mvcPath || '/view.jsp', 883 p_p_state: 'pop_up', 884 portletResourceNamespace: config.portletResourceNamespace, 885 resourceClassNameId: config.resourceClassNameId, 886 scopeTitle: config.title, 887 structureAvailableFields: config.structureAvailableFields, 888 templateId: config.templateId 889 }; 890 891 if ('mode' in config) { 892 params.mode = config.mode; 893 } 894 895 if ('navigationStartsOn' in config) { 896 params.navigationStartsOn = config.navigationStartsOn; 897 } 898 899 if ('redirect' in config) { 900 params.redirect = config.redirect; 901 } 902 903 if ('refererPortletName' in config) { 904 params.refererPortletName = config.refererPortletName; 905 } 906 907 if ('refererWebDAVToken' in config) { 908 params.refererWebDAVToken = config.refererWebDAVToken; 909 } 910 911 if ('searchRestriction' in config) { 912 params.searchRestriction = config.searchRestriction; 913 params.searchRestrictionClassNameId = config.searchRestrictionClassNameId; 914 params.searchRestrictionClassPK = config.searchRestrictionClassPK; 915 } 916 917 if ('showAncestorScopes' in config) { 918 params.showAncestorScopes = config.showAncestorScopes; 919 } 920 921 if ('showBackURL' in config) { 922 params.showBackURL = config.showBackURL; 923 } 924 925 if ('showCacheableInput' in config) { 926 params.showCacheableInput = config.showCacheableInput; 927 } 928 929 if ('showHeader' in config) { 930 params.showHeader = config.showHeader; 931 } 932 933 if ('showManageTemplates' in config) { 934 params.showManageTemplates = config.showManageTemplates; 935 } 936 937 var url = Liferay.Util.PortletURL.createRenderURL(config.basePortletURL, params); 938 config.uri = url.toString(); 939 var dialogConfig = config.dialog; 940 941 if (!dialogConfig) { 942 dialogConfig = {}; 943 config.dialog = dialogConfig; 944 } 945 946 var eventHandles = []; 947 948 if (callback) { 949 eventHandles.push(Liferay.once(config.eventName, callback)); 950 } 951 952 var detachSelectionOnHideFn = function detachSelectionOnHideFn(event) { 953 Liferay.fire(config.eventName); 954 955 if (!event.newVal) { 956 new A.EventHandle(eventHandles).detach(); 957 } 958 }; 959 960 Util.openWindow(config, function (dialogWindow) { 961 eventHandles.push(dialogWindow.after(['destroy', 'visibleChange'], detachSelectionOnHideFn)); 962 }); 963 }, ['aui-base']); 964 Liferay.provide(Util, 'openDocument', function (webDavUrl, onSuccess, onError) { 965 if (A.UA.ie) {
966 try { 967 var executor = new A.config.win.ActiveXObject('SharePoint.OpenDocuments'); 968 executor.EditDocument(webDavUrl); 969 970 if (Lang.isFunction(onSuccess)) { 971 onSuccess(); 972 } 973 } catch (e) { 974 if (Lang.isFunction(onError)) { 975 onError(e); 976 } 977 } 978 } 979 }, ['aui-base']); 980 Liferay.provide(Util, 'selectEntityHandler', function (containerSelector, selectEventName, disableButton) { 981 var container = A.one(containerSelector); 982 983 if (!container) { 984 return; 985 } 986 987 var openingLiferay = Util.getOpener().Liferay; 988 var selectorButtons = container.getDOM().querySelectorAll('.selector-button'); 989 container.delegate(EVENT_CLICK, function (event) { 990 var currentTarget = event.currentTarget.getDOM(); 991 992 if (currentTarget.disabled || currentTarget.dataset['preventSelection']) { 993 return; 994 } 995 996 var confirmSelection = currentTarget.dataset['confirmSelection'] === 'true'; 997 998 if (!confirmSelection || confirm(currentTarget.dataset['confirmSelectionMessage'])) { 999 if (disableButton) { 1000 selectorButtons.forEach(function (selectorButton) { 1001 selectorButton.disabled = false; 1002 }); 1003 currentTarget.disabled = true; 1004 } 1005 1006 var result = Util.getAttributes(currentTarget, 'data-'); 1007 openingLiferay.fire(selectEventName, result); 1008 1009 var _window = Util.getWindow(); 1010 1011 if (_window) { 1012 _window.hide(); 1013 } 1014 } 1015 }, '.selector-button'); 1016 openingLiferay.on('entitySelectionRemoved', function () { 1017 selectorButtons.forEach(function (selectorButton) { 1018 selectorButton.disabled = false; 1019 }); 1020 }); 1021 }, ['aui-base']); 1022 Liferay.provide(Util, 'portletTitleEdit', function (options) { 1023 var obj = options.obj; 1024 A.Event.defineOutside('mouseup'); 1025 1026 if (obj) { 1027 var title = obj.one('.portlet-title-text'); 1028 1029 if (title && !title.hasClass('not-editable')) { 1030 title.addClass('portlet-title-editable'); 1031 title.on(EVENT_CLICK, function (event) { 1032 var editable = Util._getEditableInstance(title); 1033 1034 var rendered = editable.get('rendered'); 1035 1036 if (rendered) { 1037 editable.fire('stopEditing'); 1038 } 1039 1040 editable.set('node', event.currentTarget); 1041 1042 if (rendered) { 1043 editable.syncUI(); 1044 } 1045 1046 editable._startEditing(event); 1047 1048 if (!rendered) { 1049 var defaultIconsTpl = A.ToolbarRenderer.prototype.TEMPLATES.icon; 1050 A.ToolbarRenderer.prototype.TEMPLATES.icon = Liferay.Util.getLexiconIconTpl('{cssClass}'); 1051 1052 editable._comboBox.icons.destroy(); 1053 1054 editable._comboBox._renderIcons(); 1055 1056 A.ToolbarRenderer.prototype.TEMPLATES.icon = defaultIconsTpl; 1057 } 1058 }); 1059 title.setData('portletTitleEditOptions', options); 1060 } 1061 } 1062 }, ['aui-editable-deprecated', 'event-outside']); 1063 Liferay.provide(Util, 'editEntity', function (config, callback) { 1064 var dialog = Util.getWindow(config.id); 1065 var eventName = config.eventName || config.id; 1066 var eventHandles = [Liferay.on(eventName, callback)]; 1067 1068 var detachSelectionOnHideFn = function detachSelectionOnHideFn(event) { 1069 if (!event.newVal) { 1070 new A.EventHandle(eventHandles).detach(); 1071 } 1072 }; 1073 1074 if (dialog) { 1075 eventHandles.push(dialog.after(['destroy', 'visibleChange'], detachSelectionOnHideFn)); 1076 dialog.show(); 1077 } else { 1078 var destroyDialog = function destroyDialog(event) { 1079 var dialogId = config.id; 1080 var dialogWindow = Util.getWindow(dialogId); 1081 1082 if (dialogWindow && Util.getPortletId(dialogId) === event.portletId) { 1083 dialogWindow.destroy(); 1084 Liferay.detach('destroyPortlet', destroyDialog); 1085 } 1086 }; 1087 1088 var editURL = new Liferay.Util.PortletURL.createPortletURL(config.uri, A.merge({ 1089 eventName: eventName 1090 }, config.urlParams)); 1091 config.uri = editURL.toString(); 1092 config.dialogIframe = A.merge({ 1093 bodyCssClass: 'dialog-with-footer' 1094 }, config.dialogIframe || {}); 1095 Util.openWindow(config, function (dialogWindow) { 1096 eventHandles.push(dialogWindow.after(['destroy', 'visibleChange'], detachSelectionOnHideFn)); 1097 Liferay.on('destroyPortlet', destroyDialog); 1098 }); 1099 } 1100 }, ['aui-base', 'liferay-util-window']); 1101 Liferay.provide(Util, 'selectEntity', function (config, callback) { 1102 var dialog = Util.getWindow(config.id); 1103 var eventName = config.eventName || config.id; 1104 var eventHandles = [Liferay.on(eventName, callback)]; 1105 var selectedData = config.selectedData; 1106 1107 if (selectedData) { 1108 config.dialog.destroyOnHide = true; 1109 } 1110 1111 var detachSelectionOnHideFn = function detachSelectionOnHideFn(event) { 1112 if (!event.newVal) { 1113 new A.EventHandle(eventHandles).detach(); 1114 } 1115 }; 1116 1117 var syncAssets = function syncAssets(event) { 1118 var currentWindow = event.currentTarget.node.get('contentWindow.document'); 1119 var selectorButtons = currentWindow.all('.lfr-search-container-wrapper .selector-button'); 1120 1121 if (selectedData) { 1122 A.each(selectorButtons, function (item) { 1123 var assetEntryId = item.attr('data-entityid') || item.attr('data-entityname'); 1124 var assetGroupId = item.attr('data-groupid'); 1125 1126 if (assetGroupId) { 1127 assetEntryId = assetGroupId + '-' + assetEntryId; 1128 } 1129 1130 var disabled = selectedData.includes(assetEntryId); 1131 1132 if (disabled) { 1133 item.attr('data-prevent-selection', true); 1134 } else { 1135 item.removeAttribute('data-prevent-selection'); 1136 } 1137 1138 Util.toggleDisabled(item, disabled); 1139 }); 1140 } 1141 }; 1142 1143 if (dialog) { 1144 eventHandles.push(dialog.after(['destroy', 'visibleChange'], detachSelectionOnHideFn)); 1145 dialog.show(); 1146 } else { 1147 var destroyDialog = function destroyDialog(event) { 1148 var dialogId = config.id; 1149 var dialogWindow = Util.getWindow(dialogId); 1150 1151 if (dialogWindow && Util.getPortletId(dialogId) === event.portletId) { 1152 dialogWindow.destroy(); 1153 Liferay.detach('destroyPortlet', destroyDialog); 1154 } 1155 }; 1156 1157 Util.openWindow(config, function (dialogWindow) { 1158 eventHandles.push(dialogWindow.after(['destroy', 'visibleChange'], detachSelectionOnHideFn), dialogWindow.iframe.after(['load'], syncAssets)); 1159 Liferay.on('destroyPortlet', destroyDialog); 1160 }); 1161 } 1162 }, ['aui-base', 'liferay-util-window']); 1163 Liferay.provide(Util, 'toggleControls', function (node) { 1164 var docBody = A.getBody(); 1165 node = node || docBody;
1166 var trigger = node.one('.toggle-controls'); 1167 1168 if (trigger) { 1169 var controlsVisible = Liferay._editControlsState === 'visible'; 1170 var currentState = MAP_TOGGLE_STATE[controlsVisible]; 1171 var icon = trigger.one('.lexicon-icon'); 1172 1173 if (icon) { 1174 currentState.icon = icon; 1175 } 1176 1177 docBody.addClass(currentState.cssClass); 1178 Liferay.fire('toggleControls', { 1179 enabled: controlsVisible 1180 }); 1181 trigger.on('tap', function () { 1182 controlsVisible = !controlsVisible; 1183 var prevState = currentState; 1184 currentState = MAP_TOGGLE_STATE[controlsVisible]; 1185 docBody.toggleClass(prevState.cssClass); 1186 docBody.toggleClass(currentState.cssClass); 1187 var editControlsIconClass = currentState.iconCssClass; 1188 var editControlsState = currentState.state; 1189 1190 if (icon) { 1191 var newIcon = currentState.icon; 1192 1193 if (!newIcon) { 1194 newIcon = Util.getLexiconIcon(editControlsIconClass); 1195 newIcon = A.one(newIcon); 1196 currentState.icon = newIcon; 1197 } 1198 1199 icon.replace(newIcon); 1200 icon = newIcon; 1201 } 1202 1203 Liferay._editControlsState = editControlsState; 1204 Liferay.Util.Session.set('com.liferay.frontend.js.web_toggleControls', editControlsState); 1205 Liferay.fire('toggleControls', { 1206 enabled: controlsVisible, 1207 src: 'ui' 1208 }); 1209 }); 1210 } 1211 }, ['event-tap']); 1212 Liferay.provide(Util, '_openWindowProvider', function (config, callback) { 1213 var dialog = Window.getWindow(config); 1214 1215 if (Lang.isFunction(callback)) { 1216 callback(dialog); 1217 } 1218 }, ['liferay-util-window']); 1219 Util.Window = Window; 1220 Liferay.Util = Util; 1221 Liferay.STATUS_CODE = { 1222 BAD_REQUEST: 400, 1223 INTERNAL_SERVER_ERROR: 500, 1224 OK: 200, 1225 SC_DUPLICATE_FILE_EXCEPTION: 490, 1226 SC_FILE_ANTIVIRUS_EXCEPTION: 494, 1227 SC_FILE_CUSTOM_EXCEPTION: 499, 1228 SC_FILE_EXTENSION_EXCEPTION: 491, 1229 SC_FILE_NAME_EXCEPTION: 492, 1230 SC_FILE_SIZE_EXCEPTION: 493, 1231 SC_UPLOAD_REQUEST_SIZE_EXCEPTION: 495 1232 }; // 0-200: Theme Developer 1233 // 200-400: Portlet Developer 1234 // 400+: Liferay 1235 1236 Liferay.zIndex = { 1237 ALERT: 430, 1238 DOCK: 10, 1239 DOCK_PARENT: 20, 1240 DRAG_ITEM: 460, 1241 DROP_AREA: 440, 1242 DROP_POSITION: 450, 1243 MENU: 5000, 1244 OVERLAY: 1000, 1245 POPOVER: 1600, 1246 TOOLTIP: 10000, 1247 WINDOW: 1200 1248 }; 1249})(AUI()); 1250//# sourceMappingURL=util.js.map
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.