- md5
- e5e4297e4ea1974b3ffab6f7fd2a1cb5
- sha1
- c8d1dae940a8e2e4dcda6e9fc0c6f19e25d2e7fc
- sha256
- abe1f369b2cfb63546355e51126c18d2ae7498ca82364359447f24e82881521e
"use strict";function _typeof(a){return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},_typeof(a)}function _classCallCheck(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}function _possibleConstructorReturn(a,b){return b&&("object"===_typeof(b)||"function"==typeof b)?b:_assertThisInitialized(a)}function _defineProperties(a,b){for(var c,d=0;d<b.length;d++)c=b[d],c.enumerable=c.enumerable||!1,c.configurable=!0,"value"in c&&(c.writable=!0),Object.defineProperty(a,c.key,c)}function _createClass(a,b,c){return b&&_defineProperties(a.prototype,b),c&&_defineProperties(a,c),a}function _inherits(a,b){if("function"!=typeof b&&null!==b)throw new TypeError("Super expression must either be null or a function");a.prototype=Object.create(b&&b.prototype,{constructor:{value:a,writable:!0,configurable:!0}}),b&&_setPrototypeOf(a,b)}function _assertThisInitialized(a){if(void 0===a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return a}function _wrapNativeSuper(a){var b="function"==typeof Map?new Map:void 0;return _wrapNativeSuper=function(a){function c(){return _construct(a,arguments,_getPrototypeOf(this).constructor)}if(null===a||!_isNativeFunction(a))return a;if("function"!=typeof a)throw new TypeError("Super expression must either be null or a function");if("undefined"!=typeof b){if(b.has(a))return b.get(a);b.set(a,c)}return c.prototype=Object.create(a.prototype,{constructor:{value:c,enumerable:!1,writable:!0,configurable:!0}}),_setPrototypeOf(c,a)},_wrapNativeSuper(a)}function isNativeReflectConstruct(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch(a){return!1}}function _construct(){return _construct=isNativeReflectConstruct()?Reflect.construct:function(b,c,d){var e=[null];e.push.apply(e,c);var a=Function.bind.apply(b,e),f=new a;return d&&_setPrototypeOf(f,d.prototype),f},_construct.apply(null,arguments)}function _isNativeFunction(a){return-1!==Function.toString.call(a).indexOf("[native code]")}function _setPrototypeOf(a,b){return _setPrototypeOf=Object.setPrototypeOf||function(a,b){return a.__proto__=b,a},_setPrototypeOf(a,b)}function _getPrototypeOf(a){return _getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf:function(a){return a.__proto__||Object.getPrototypeOf(a)},_getPrototypeOf(a)}(function(a){var b={ENTER:13,SPACE:32},c=function(a){function c(){var a;return _classCallCheck(this,c),a=_possibleConstructorReturn(this,_getPrototypeOf(c).call(this)),a.inputs=[],a.spans=[],a.initialized=!1,a.inputsContainer="",a.newActive="",a.inputLabel="",a.inputLabelText="",a.createMarkup=a.createMarkup.bind(_assertThisInitialized(_assertThisInitialized(a))),a.addListeners=a.addListeners.bind(_assertThisInitialized(_assertThisInitialized(a))),a.removeListeners=a.removeListeners.bind(_assertThisInitialized(_assertThisInitialized(a))),a.switch=a.switch.bind(_assertThisInitialized(_assertThisInitialized(a))),a.toggle=a.toggle.bind(_assertThisInitialized(_assertThisInitialized(a))),a.keyEvents=a.keyEvents.bind(_assertThisInitialized(_assertThisInitialized(a))),a.onFocus=a.onFocus.bind(_assertThisInitialized(_assertThisInitialized(a))),a}return _inherits(c,a),_createClass(c,[{key:"type",get:function a(){return this.getAttribute("type")},set:function b(a){return this.setAttribute("type",a)}},{key:"offText",get:function a(){return this.getAttribute("off-text")||"Off"}},{key:"onText",get:function a(){return this.getAttribute("on-text")||"On"}}],[{key:"observedAttributes",get:function a(){return["type","off-text","on-text"]}}]),_createClass(c,[{key:"connectedCallback",value:function a(){if(this.initialized&&0<this.inputs.length)return void this.addListeners();if(this.inputs=[].slice.call(this.querySelectorAll("input")),2!==this.inputs.length||"radio"!==this.inputs[0].type)throw new Error("`Joomla-switcher` requires two inputs type=\"radio\"");this.createMarkup(),this.inputsContainer=this.inputs[0].parentNode,this.inputsContainer.setAttribute("role","switch"),this.inputs[1].checked?(this.inputs[1].parentNode.classList.add("active"),this.spans[1].classList.add("active"),this.inputsContainer.setAttribute("aria-labeledby","".concat(this.id,"-lbl"))):(this.spans[0].classList.add("active"),this.inputsContainer.setAttribute("aria-label",this.spans[0].innerHTML)),this.addListeners()}},{key:"disconnectedCallback",value:function a(){this.removeListeners()}},{key:"dispatchCustomEvent",value:function c(a){var b=new CustomEvent(a,{bubbles:!0,cancelable:!0});b.relatedTarget=this,this.dispatchEvent(b),this.removeEventListener(a,this)}},{key:"createMarkup",value:function g(){var a=0;this.type||this.setAttribute("type","success");var b=document.createElement("fieldset");b.classList.add("switcher"),b.classList.add(this.type),b.setAttribute("tabindex","0"),b.id=this.id;var c=document.createElement("span");c.classList.add("switch"),c.classList.add(this.type),this.inputs.forEach(function(c,d){c.setAttribute("tabindex","-1"),c.checked&&b.setAttribute("aria-checked",!0),b.appendChild(c),1===d&&c.checked&&(a=1)}),b.appendChild(c);var d=document.createElement("span");d.classList.add("switcher-labels");var e=document.createElement("span");e.classList.add("switcher-label-0"),e.innerHTML="".concat(this.offText);var f=document.createElement("span");f.classList.add("switcher-label-1"),f.innerHTML="".concat(this.onText),0==a?e.classList.add("active"):f.classList.add("active"),this.spans.push(e),this.spans.push(f),d.appendChild(e),d.appendChild(f),this.appendChild(b),this.appendChild(d),this.initialized=!0}},{key:"switch",value:function a(){this.spans.forEach(function(a){a.classList.remove("active")}),this.inputsContainer.classList.contains("active")?this.inputsContainer.classList.remove("active"):this.inputsContainer.classList.add("active"),this.inputs.forEach(function(a){a.classList.remove("active")}),1===this.newActive?(this.inputs[this.newActive].classList.add("active"),this.inputs[1].setAttribute("checked",""),this.inputs[0].removeAttribute("checked"),this.inputsContainer.setAttribute("aria-checked",!0),this.inputsContainer.setAttribute("aria-label","".concat(this.inputLabelText," ").concat(this.spans[1].innerHTML)),this.dispatchCustomEvent("joomla.switcher.on")):(this.inputs[1].removeAttribute("checked"),this.inputs[0].setAttribute("checked",""),this.inputs[0].classList.add("active"),this.inputsContainer.setAttribute("aria-checked",!1),this.inputsContainer.setAttribute("aria-label","".concat(this.inputLabelText," ").concat(this.spans[0].innerHTML)),this.dispatchCustomEvent("joomla.switcher.off")),this.spans[this.newActive].classList.add("active")}},{key:"toggle",value:function a(){this.newActive=this.inputs[1].classList.contains("active")?0:1,this.switch()}},{key:"keyEvents",value:function c(a){(a.keyCode===b.ENTER||a.keyCode===b.SPACE)&&(a.preventDefault(),this.newActive=this.inputs[1].classList.contains("active")?0:1,this.switch())}},{key:"onFocus",value:function a(){this.inputsContainer.focus()}},{key:"addListeners",value:function b(){var a=this;this.inputLabel&&this.inputLabel.addEventListener("click",this.onFocus),this.inputs.forEach(function(b){b.addEventListener("click",a.toggle)}),this.inputsContainer.addEventListener("keydown",this.keyEvents)}},{key:"removeListeners",value:function b(){var a=this;this.inputLabel&&this.inputLabel.removeEventListener("click",this.onFocus),this.inputs.forEach(function(b){b.removeEventListener("click",a.toggle)}),this.inputsContainer.removeEventListener("keydown",this.keyEvents)}}]),c}(_wrapNativeSuper(HTMLElement));a.define("joomla-field-switcher",c)})(customElements);
No other release has this exact content. See every version of this file.