- md5
- e3736208d7c6afe211a44df01d30958b
- sha1
- 7bd8047fbceaa8f59aa9449c4723b56d2641a517
- sha256
- 72bb57b9b71c9ae1c2c17d44677b032cb181f45ae2207ba49f2d1c6b67b98069
(function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
'use strict';var _createClass=function(){function a(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)}return function(b,c,d){return c&&a(b.prototype,c),d&&a(b,d),b}}();function _classCallCheck(a,b){if(!(a instanceof b))throw new TypeError('Cannot call a class as a function')}function _possibleConstructorReturn(a,b){if(!a)throw new ReferenceError('this hasn\'t been initialised - super() hasn\'t been called');return b&&('object'==typeof b||'function'==typeof b)?b:a}function _inherits(a,b){if('function'!=typeof b&&null!==b)throw new TypeError('Super expression must either be null or a function, not '+typeof b);a.prototype=Object.create(b&&b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}}),b&&(Object.setPrototypeOf?Object.setPrototypeOf(a,b):a.__proto__=b)}(function(a){var b={ENTER:13,SPACE:32},c=function(a){function c(){_classCallCheck(this,c);var a=_possibleConstructorReturn(this,(c.__proto__||Object.getPrototypeOf(c)).call(this));return a.inputs=[],a.spans=[],a.initialized=!1,a.inputsContainer='',a.newActive='',a.inputLabel='',a.inputLabelText='',a.createMarkup=a.createMarkup.bind(a),a.addListeners=a.addListeners.bind(a),a.removeListeners=a.removeListeners.bind(a),a.switch=a.switch.bind(a),a.toggle=a.toggle.bind(a),a.keyEvents=a.keyEvents.bind(a),a.onFocus=a.onFocus.bind(a),a}return _inherits(c,a),_createClass(c,[{key:'type',get:function get(){return this.getAttribute('type')},set:function set(a){return this.setAttribute('type',a)}},{key:'offText',get:function get(){return this.getAttribute('off-text')||'Off'}},{key:'onText',get:function get(){return this.getAttribute('on-text')||'On'}}],[{key:'observedAttributes',get:function get(){return['type','off-text','on-text']}}]),_createClass(c,[{key:'connectedCallback',value:function connectedCallback(){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',this.id+'-lbl')):(this.spans[0].classList.add('active'),this.inputsContainer.setAttribute('aria-label',this.spans[0].innerHTML)),this.addListeners()}},{key:'disconnectedCallback',value:function disconnectedCallback(){this.removeListeners()}},{key:'dispatchCustomEvent',value:function dispatchCustomEvent(a){var b=new CustomEvent(a,{bubbles:!0,cancelable:!0});b.relatedTarget=this,this.dispatchEvent(b),this.removeEventListener(a,this)}},{key:'createMarkup',value:function createMarkup(){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=''+this.offText;var f=document.createElement('span');f.classList.add('switcher-label-1'),f.innerHTML=''+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 _switch(){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',this.inputLabelText+' '+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.inputLabelText+' '+this.spans[0].innerHTML),this.dispatchCustomEvent('joomla.switcher.off')),this.spans[this.newActive].classList.add('active')}},{key:'toggle',value:function toggle(){this.newActive=this.inputs[1].classList.contains('active')?0:1,this.switch()}},{key:'keyEvents',value:function keyEvents(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 onFocus(){this.inputsContainer.focus()}},{key:'addListeners',value:function addListeners(){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 removeListeners(){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}(HTMLElement);a.define('joomla-field-switcher',c)})(customElements);
},{}]},{},[1]);
No other release has this exact content. See every version of this file.