PluginProbe
Toggle Content / trunk
Toggle Content vtrunk
trunk 1.0.0 1.0.1 1.0.2 1.1.0 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.8 1.3.0
toggle-content / dist / frontend / index.js

index.js in Toggle Content trunk, at dist/frontend/index.js

1 lines 3.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 (()=>{function e(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}document.addEventListener("DOMContentLoaded",(function(t){var r=document.querySelectorAll(".eb-toggle-wrapper");if(r){var n,o=function(t,r){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=function(t,r){if(t){if("string"==typeof t)return e(t,r);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?e(t,r):void 0}}(t))||r&&t&&"number"==typeof t.length){n&&(t=n);var o=0,l=function(){};return{s:l,n:function(){return o>=t.length?{done:!0}:{done:!1,value:t[o++]}},e:function(e){throw e},f:l}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,c=!0,i=!1;return{s:function(){n=n.call(t)},n:function(){var e=n.next();return c=e.done,e},e:function(e){i=!0,a=e},f:function(){try{c||null==n.return||n.return()}finally{if(i)throw a}}}}(r);try{var l=function(){var e=n.value,t=e.querySelector(".eb-toggle-switch > input"),r=e.querySelector(".eb-toggle-primary-label"),o=e.querySelector(".eb-toggle-secondary-label"),l=e.querySelector(".eb-toggle-primary-label-text"),a=e.querySelector(".eb-toggle-secondary-label-text"),c=e.querySelector(".eb-toggle-slider"),i=e.querySelector(".eb-toggle-controller"),u=e.querySelector(".eb-toggle-content"),s=e.querySelector(".eb-toggle-seperator"),d=e.getAttribute("data-init-content"),y=e.getAttribute("data-size"),g=e.getAttribute("data-switch-style"),b=e.getAttribute("data-primary-color"),f=e.getAttribute("data-secondary-color"),p=e.getAttribute("data-active-color"),h=e.getAttribute("data-bg-color"),m=e.getAttribute("data-active-bg"),v="inherit",x="inherit",S=window.getComputedStyle(u.children[0]).display,A=window.getComputedStyle(u.children[1]).display,w=function(){switch(y){case"s":return"translateX(22px)";case"m":return"translateX(26px)";case"l":return"translateX(36px)";case"xl":return"translateX(42px)"}},k=e.querySelector(".eb-text-switch-label"),q=k?k.getAttribute("for"):null,E=q?e.querySelector("#".concat(q)):null;function L(){"toggle"!==g&&(r.style.background=m||x,o.style.background=h||v),C()}function X(){"toggle"!==g&&(o.style.background=m||x,r.style.background=h||v),j()}function C(){t.checked=!1,u.children[0].style.display=S,u.children[1].style.display="none",o.style.color=f,r.style.color=p||b,"toggle"===g&&(a.style.color=f,l.style.color=p||b),"text"!==g&&(i.style.transform="translateX(0px)")}function j(){t.checked=!0,u.children[1].style.display=A,u.children[0].style.display="none",r.style.color=b,o.style.color=p,"toggle"===g&&(l.style.color=b,a.style.color=p||f),"text"!==g&&(i.style.transform=w())}"primary"===d?C():(E&&(E.checked=!0),j()),E&&E.addEventListener("change",(function(){this.checked?j():C()})),"text"===g&&(r.style.background=h||v,o.style.background=h||v,s.style.background=h||v),r.addEventListener("click",L),o.addEventListener("click",X),"text"===g&&("primary"===d?L():X()),"rounded"==g&&(c.style.borderRadius="21px",i.style.borderRadius=function(){switch(y){case"s":return"10px";case"m":return"13px";case"l":return"18px";case"xl":return"21px"}}()),"primary"===d?C():j(),t.addEventListener("change",(function(){this.checked?j():C()}))};for(o.s();!(n=o.n()).done;)l()}catch(e){o.e(e)}finally{o.f()}}}))})();