[ Index ] |
PHP Cross Reference of Joomla 4.2.2 documentation |
[Summary view] [Print] [Text view]
1 (function () { 2 'use strict'; 3 4 function _defineProperties(target, props) { 5 for (var i = 0; i < props.length; i++) { 6 var descriptor = props[i]; 7 descriptor.enumerable = descriptor.enumerable || false; 8 descriptor.configurable = true; 9 if ("value" in descriptor) descriptor.writable = true; 10 Object.defineProperty(target, descriptor.key, descriptor); 11 } 12 } 13 14 function _createClass(Constructor, protoProps, staticProps) { 15 if (protoProps) _defineProperties(Constructor.prototype, protoProps); 16 if (staticProps) _defineProperties(Constructor, staticProps); 17 Object.defineProperty(Constructor, "prototype", { 18 writable: false 19 }); 20 return Constructor; 21 } 22 23 function _inheritsLoose(subClass, superClass) { 24 subClass.prototype = Object.create(superClass.prototype); 25 subClass.prototype.constructor = subClass; 26 27 _setPrototypeOf(subClass, superClass); 28 } 29 30 function _getPrototypeOf(o) { 31 _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { 32 return o.__proto__ || Object.getPrototypeOf(o); 33 }; 34 return _getPrototypeOf(o); 35 } 36 37 function _setPrototypeOf(o, p) { 38 _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { 39 o.__proto__ = p; 40 return o; 41 }; 42 43 return _setPrototypeOf(o, p); 44 } 45 46 function _isNativeReflectConstruct() { 47 if (typeof Reflect === "undefined" || !Reflect.construct) return false; 48 if (Reflect.construct.sham) return false; 49 if (typeof Proxy === "function") return true; 50 51 try { 52 Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); 53 return true; 54 } catch (e) { 55 return false; 56 } 57 } 58 59 function _construct(Parent, args, Class) { 60 if (_isNativeReflectConstruct()) { 61 _construct = Reflect.construct; 62 } else { 63 _construct = function _construct(Parent, args, Class) { 64 var a = [null]; 65 a.push.apply(a, args); 66 var Constructor = Function.bind.apply(Parent, a); 67 var instance = new Constructor(); 68 if (Class) _setPrototypeOf(instance, Class.prototype); 69 return instance; 70 }; 71 } 72 73 return _construct.apply(null, arguments); 74 } 75 76 function _isNativeFunction(fn) { 77 return Function.toString.call(fn).indexOf("[native code]") !== -1; 78 } 79 80 function _wrapNativeSuper(Class) { 81 var _cache = typeof Map === "function" ? new Map() : undefined; 82 83 _wrapNativeSuper = function _wrapNativeSuper(Class) { 84 if (Class === null || !_isNativeFunction(Class)) return Class; 85 86 if (typeof Class !== "function") { 87 throw new TypeError("Super expression must either be null or a function"); 88 } 89 90 if (typeof _cache !== "undefined") { 91 if (_cache.has(Class)) return _cache.get(Class); 92 93 _cache.set(Class, Wrapper); 94 } 95 96 function Wrapper() { 97 return _construct(Class, arguments, _getPrototypeOf(this).constructor); 98 } 99 100 Wrapper.prototype = Object.create(Class.prototype, { 101 constructor: { 102 value: Wrapper, 103 enumerable: false, 104 writable: true, 105 configurable: true 106 } 107 }); 108 return _setPrototypeOf(Wrapper, Class); 109 }; 110 111 return _wrapNativeSuper(Class); 112 } 113 114 function _assertThisInitialized(self) { 115 if (self === void 0) { 116 throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); 117 } 118 119 return self; 120 } 121 122 /** 123 * @copyright (C) 2018 Open Source Matters, Inc. <https://www.joomla.org> 124 * @license GNU General Public License version 2 or later; see LICENSE.txt 125 */ 126 window.customElements.define('joomla-toolbar-button', /*#__PURE__*/function (_HTMLElement) { 127 _inheritsLoose(_class, _HTMLElement); 128 129 /** 130 * Lifecycle 131 */ 132 function _class() { 133 var _this; 134 135 _this = _HTMLElement.call(this) || this; 136 137 if (!Joomla) { 138 throw new Error('Joomla API is not properly initiated'); 139 } 140 141 _this.onChange = _this.onChange.bind(_assertThisInitialized(_this)); 142 _this.executeTask = _this.executeTask.bind(_assertThisInitialized(_this)); 143 return _this; 144 } 145 /** 146 * Lifecycle 147 */ 148 149 150 var _proto = _class.prototype; 151 152 _proto.connectedCallback = function connectedCallback() { 153 // We need a button to support button behavior, 154 // because we cannot currently extend HTMLButtonElement 155 this.buttonElement = this.querySelector('button, a'); 156 this.buttonElement.addEventListener('click', this.executeTask); // Check whether we have a form 157 158 var formSelector = this.form || 'adminForm'; 159 this.formElement = document.getElementById(formSelector); 160 this.disabled = false; // If list selection is required, set button to disabled by default 161 162 if (this.listSelection) { 163 this.setDisabled(true); 164 } 165 166 if (this.listSelection) { 167 if (!this.formElement) { 168 throw new Error("The form \"" + formSelector + "\" is required to perform the task, but the form was not found on the page."); 169 } // Watch on list selection 170 171 172 this.formElement.boxchecked.addEventListener('change', this.onChange); 173 } 174 } 175 /** 176 * Lifecycle 177 */ 178 ; 179 180 _proto.disconnectedCallback = function disconnectedCallback() { 181 if (this.formElement.boxchecked) { 182 this.formElement.boxchecked.removeEventListener('change', this.onChange); 183 } 184 185 this.buttonElement.removeEventListener('click', this.executeTask); 186 }; 187 188 _proto.onChange = function onChange(_ref) { 189 var target = _ref.target; 190 // Check whether we have selected something 191 this.setDisabled(target.value < 1); 192 }; 193 194 _proto.setDisabled = function setDisabled(disabled) { 195 // Make sure we have a boolean value 196 this.disabled = !!disabled; // Switch attribute for native element 197 // An anchor does not support "disabled" attribute, so use class 198 199 if (this.buttonElement) { 200 if (this.disabled) { 201 if (this.buttonElement.nodeName === 'BUTTON') { 202 this.buttonElement.disabled = true; 203 } else { 204 this.buttonElement.classList.add('disabled'); 205 } 206 } else if (this.buttonElement.nodeName === 'BUTTON') { 207 this.buttonElement.disabled = false; 208 } else { 209 this.buttonElement.classList.remove('disabled'); 210 } 211 } 212 }; 213 214 _proto.executeTask = function executeTask() { 215 if (this.disabled) { 216 return false; 217 } // eslint-disable-next-line no-restricted-globals 218 219 220 if (this.confirmMessage && !confirm(this.confirmMessage)) { 221 return false; 222 } 223 224 if (this.task) { 225 Joomla.submitbutton(this.task, this.form, this.formValidation); 226 } 227 228 return true; 229 }; 230 231 _createClass(_class, [{ 232 key: "task", 233 get: // Attribute getters 234 function get() { 235 return this.getAttribute('task'); 236 } 237 }, { 238 key: "listSelection", 239 get: function get() { 240 return this.hasAttribute('list-selection'); 241 } 242 }, { 243 key: "form", 244 get: function get() { 245 return this.getAttribute('form'); 246 } 247 }, { 248 key: "formValidation", 249 get: function get() { 250 return this.hasAttribute('form-validation'); 251 } 252 }, { 253 key: "confirmMessage", 254 get: function get() { 255 return this.getAttribute('confirm-message'); 256 } 257 }]); 258 259 return _class; 260 }( /*#__PURE__*/_wrapNativeSuper(HTMLElement))); 261 262 })();
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Wed Sep 7 05:41:13 2022 | Chilli.vc Blog - For Webmaster,Blog-Writer,System Admin and Domainer |