1/** 2 * SPDX-FileCopyrightText: (c) 2000 Liferay, Inc. https://liferay.com 3 * SPDX-License-Identifier: LGPL-2.1-or-later OR LicenseRef-Liferay-DXP-EULA-2.0.0-2023-06 4 */ 5(function (A) { 6 var CLICK_EVENTS = {}; 7 var Util = Liferay.Util; 8 A.use('attribute', 'oop', function (A) { 9 A.augment(Liferay, A.Attribute, true); 10 }); 11 Liferay.provide(Liferay, 'delegateClick', function (id, fn) { 12 var el = A.config.doc.getElementById(id); 13 14 if (!el || el.id != id) { 15 return; 16 } 17 18 var guid = A.one(el).addClass('lfr-delegate-click').guid(); 19 CLICK_EVENTS[guid] = fn; 20 21 if (!Liferay._baseDelegateHandle) { 22 Liferay._baseDelegateHandle = A.getBody().delegate('click', Liferay._baseDelegate, '.lfr-delegate-click'); 23 } 24 }, ['aui-base']); 25 26 Liferay._baseDelegate = function (event) { 27 var id = event.currentTarget.attr('id'); 28 var fn = CLICK_EVENTS[id]; 29 30 if (fn) { 31 fn.apply(this, arguments); 32 } 33 }; 34 35 Liferay._CLICK_EVENTS = CLICK_EVENTS; 36 Liferay.provide(window, 'submitForm', function (form, action, singleSubmit, validate) { 37 if (!Util._submitLocked) { 38 if (form.jquery) { 39 form = form[0]; 40 } 41 42 Liferay.fire('submitForm', { 43 action: action, 44 form: A.one(form), 45 singleSubmit: singleSubmit, 46 validate: validate !== false 47 }); 48 } 49 }, ['aui-base', 'aui-form-validator', 'aui-url', 'liferay-form']); 50 Liferay.publish('submitForm', { 51 defaultFn: function defaultFn(event) { 52 var form = event.form; 53 var hasErrors = false; 54 55 if (event.validate) { 56 var liferayForm = Liferay.Form.get(form.attr('id')); 57 58 if (liferayForm) { 59 var validator = liferayForm.formValidator; 60 61 if (A.instanceOf(validator, A.FormValidator)) { 62 validator.validate(); 63 hasErrors = validator.hasErrors(); 64 65 if (hasErrors) { 66 validator.focusInvalidField(); 67 } 68 } 69 } 70 } 71 72 if (!hasErrors) { 73 var action = event.action || form.getAttribute('action'); 74 var singleSubmit = event.singleSubmit; 75 var inputs = form.all('button[type=submit], input[type=button], input[type=image], input[type=reset], input[type=submit]'); 76 Util.disableFormButtons(inputs, form); 77 78 if (singleSubmit === false) { 79 Util._submitLocked = A.later(1000, Util, Util.enableFormButtons, [inputs, form]); 80 } else { 81 Util._submitLocked = true; 82 } 83 84 var baseURL; 85 var queryString; 86 var searchParamsIndex = action.indexOf('?'); 87 88 if (searchParamsIndex === -1) { 89 baseURL = action; 90 queryString = ''; 91 } else { 92 baseURL = action.slice(0, searchParamsIndex); 93 queryString = action.slice(searchParamsIndex + 1); 94 } 95 96 var searchParams = new URLSearchParams(queryString); 97 var authToken = searchParams.get('p_auth') || ''; 98 99 if (authToken.includes('#')) { 100 authToken = authToken.substring(0, authToken.indexOf('#')); 101 } 102 103 if (authToken) { 104 form.append('<input name="p_auth" type="hidden" value="' + authToken + '" />'); 105 searchParams.delete('p_auth'); 106 action = baseURL + '?' + searchParams.toString(); 107 } 108 109 form.attr('action', action); 110 Util.submitForm(form); 111 form.attr('target', ''); 112 Util._submitLocked = null; 113 } 114 } 115 }); 116 Liferay.after('closeWindow', function (event) { 117 var id = event.id; 118 var dialog = Util.getTop().Liferay.Util.Window.getById(id); 119 120 if (dialog && dialog.iframe) { 121 var dialogWindow = dialog.iframe.node.get('contentWindow').getDOM(); 122 var openingWindow = dialogWindow.Liferay.Util.getOpener(); 123 var redirect = event.redirect; 124 125 if (redirect) { 126 openingWindow.Liferay.Util.navigate(redirect); 127 } else { 128 var refresh = event.refresh; 129 130 if (refresh && openingWindow) { 131 var data; 132 133 if (!event.portletAjaxable) { 134 data = { 135 portletAjaxable: false 136 }; 137 } 138 139 openingWindow.Liferay.Portlet.refresh('#p_p_id_' + refresh + '_', data); 140 } 141 } 142 143 dialog.hide(); 144 } 145 }); 146})(AUI()); 147//# sourceMappingURL=events.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.