- md5
- 0326726c621b17eb1814488c68acfc4d
- sha1
- e6f9504d026143081f6da873a16861a7c8ad1968
- sha256
- 3369941e1ec0d5146f6852257d84ab48e2f5f8858efad56129c5f1df618c8975
!function(){return function t(e,i,n){function s(a,c){if(!i[a]){if(!e[a]){var o="function"==typeof require&&require;if(!c&&o)return o(a,!0);if(r)return r(a,!0);var u=new Error("Cannot find module '"+a+"'");throw u.code="MODULE_NOT_FOUND",u}var h=i[a]={exports:{}};e[a][0].call(h.exports,function(t){return s(e[a][1][t]||t)},h,h.exports,t,e,i,n)}return i[a].exports}for(var r="function"==typeof require&&require,a=0;a<n.length;a++)s(n[a]);return s}}()({1:[function(t,e,i){"use strict";var n=function(){function t(t,e){for(var i=0;i<e.length;i++){var n=e[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}return function(e,i,n){return i&&t(e.prototype,i),n&&t(e,n),e}}();!function(t){var e=13,i=32,s=function(t){function s(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,s);var t=function(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}(this,(s.__proto__||Object.getPrototypeOf(s)).call(this));return t.inputs=[],t.spans=[],t.inputsContainer="",t.newActive="",t}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}(s,HTMLElement),n(s,[{key:"type",get:function(){return this.getAttribute("type")},set:function(t){return this.setAttribute("type",t)}},{key:"offText",get:function(){return this.getAttribute("off-text")||"Off"}},{key:"onText",get:function(){return this.getAttribute("on-text")||"On"}}],[{key:"observedAttributes",get:function(){return["type","off-text","on-text"]}}]),n(s,[{key:"connectedCallback",value:function(){var t=this;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="checkbox"');this.createMarkup.bind(this)(),this.inputsContainer=this.firstElementChild,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-label",this.spans[1].innerHTML)):(this.spans[0].classList.add("active"),this.inputsContainer.setAttribute("aria-label",this.spans[0].innerHTML)),this.inputs.forEach(function(e){e.addEventListener("click",t.toggle.bind(t))}),this.inputsContainer.addEventListener("keydown",this.keyEvents.bind(this))}},{key:"disconnectedCallback",value:function(){this.removeEventListener("joomla.switcher.toggle",this.toggle,!0),this.removeEventListener("click",this.switch,!0),this.removeEventListener("keydown",this.keydown,!0)}},{key:"dispatchCustomEvent",value:function(t){var e=new CustomEvent(t,{bubbles:!0,cancelable:!0});e.relatedTarget=this,this.dispatchEvent(e),this.removeEventListener(t,this)}},{key:"createMarkup",value:function(){var t=0,e=document.createElement("span");e.classList.add("switcher"),e.setAttribute("tabindex",0),this.type||this.setAttribute("type","success");var i=document.createElement("span");i.classList.add("switch"),this.inputs.forEach(function(i,n){i.setAttribute("tabindex","-1"),i.checked&&e.setAttribute("aria-checked",!0),e.appendChild(i),1===n&&i.checked&&(t=1)}),e.appendChild(i);var n=document.createElement("span");n.classList.add("switcher-labels");var s=document.createElement("span");s.classList.add("switcher-label-0"),s.innerText=this.offText;var r=document.createElement("span");r.classList.add("switcher-label-1"),r.innerText=this.onText,0===t?s.classList.add("active"):r.classList.add("active"),this.spans.push(s),this.spans.push(r),n.appendChild(s),n.appendChild(r),this.appendChild(e),this.appendChild(n)}},{key:"switch",value:function(){this.spans.forEach(function(t){t.classList.remove("active")}),this.inputsContainer.classList.contains("active")?this.inputsContainer.classList.remove("active"):this.inputsContainer.classList.add("active"),this.inputs.forEach(function(t){t.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",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",this.spans[0].innerHTML),this.dispatchCustomEvent("joomla.switcher.off")),this.spans[this.newActive].classList.add("active")}},{key:"toggle",value:function(){this.newActive=this.inputs[1].classList.contains("active")?0:1,this.switch.bind(this)()}},{key:"keyEvents",value:function(t){t.keyCode!==e&&t.keyCode!==i||(t.preventDefault(),this.newActive=this.inputs[1].classList.contains("active")?0:1,this.switch.bind(this)())}}]),s}();t.define("joomla-field-switcher",s)}(customElements)},{}]},{},[1]);
No other release has this exact content. See every version of this file.