You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

lc-switch

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lc-switch - npm Package Compare versions

Comparing version

to
2.0.1

18

lc_switch.min.js

@@ -5,3 +5,3 @@ /* ------------------------------------------------------------------------

*
* @version: 2.0
* @version: 2.0.1
* @author: Luca Montanari (LCweb)

@@ -14,9 +14,9 @@ * @website: https://lcweb.it

var $jscomp=$jscomp||{};$jscomp.scope={};$jscomp.createTemplateTagFirstArg=function(h){return h.raw=h};$jscomp.createTemplateTagFirstArgWithRaw=function(h,e){h.raw=e;return h};
(function(h){if("undefined"!=typeof Element.prototype.lc_switch)return!1;var e=!1,p={on_txt:"ON",off_txt:"OFF",on_color:!1,compact_mode:!1};window.lc_switch=function(c,a){a="object"!=typeof a?p:Object.assign({},p,a);f(c).forEach(function(b){if("INPUT"!=b.tagName||"INPUT"==b.tagName&&"checkbox"!=b.getAttribute("type")&&"radio"!=b.getAttribute("type"))return!1;if(b.parentNode.classList.length&&b.parentNode.classList.contains("lcs_wrap"))return!0;var d=a.on_txt?'<div class="lcs_label lcs_label_on">'+
a.on_txt+"</div>":"",m=a.off_txt?'<div class="lcs_label lcs_label_off">'+a.off_txt+"</div>":"",n="lcs_"+b.getAttribute("type");n+=b.checked?" lcs_on":" lcs_off";b.disabled&&(n+=" lcs_disabled");var r=a.on_color&&b.checked?'style="background: '+a.on_color+';"':"",t=a.on_color?'data-on-color="'+a.on_color+'"':"",k=document.createElement("div");k.classList.add("lcs_wrap");k.innerHTML='<div class="lcs_switch '+n+'" '+t+" "+r+'><div class="lcs_cursor"></div>'+d+m+"</div>";a.compact_mode&&k.classList.add("lcs_compact");
b.parentNode.insertBefore(k,b);k.appendChild(b);k.querySelector(".lcs_switch").addEventListener("click",function(l){(l.target.classList.contains("lcs_switch")?l.target:q(l.target,".lcs_switch")).classList.contains("lcs_disabled")||lcs_toggle(b)});b.addEventListener("change",function(l){lcs_update(b)})});document.head.insertAdjacentHTML("beforeend",'<style>\n.lcs_wrap,\n.lcs_wrap * {\n user-select: none;\n}\n.lcs_wrap {\n\tdisplay: inline-block;\n\tdirection: ltr;\n\theight: 28px;\n width: 73px;\n vertical-align: middle;\n}\n.lcs_wrap input {\n\tdisplay: none;\n}\n.lcs_switch {\n\tdisplay: inline-block;\n\tposition: relative;\n\twidth: 100%;\n\theight: 100%;\n\tborder-radius: 30px;\n\tbackground: #ddd;\n\toverflow: hidden;\n\tcursor: pointer;\n\ttransition: all .2s ease-in-out;\n}\n.lcs_cursor {\n\tdisplay: inline-block;\n\tposition: absolute;\n\ttop: 50%;\n margin-top: -11px;\n\twidth: 22px;\n\theight: 22px;\n\tborder-radius: 100%;\n\tbackground: #fff;\n\tbox-shadow: 0 1px 2px 0 rgba(0, 0, 0, .2), 0 3px 4px 0 rgba(0, 0, 0, .1);\n\tz-index: 10;\n\ttransition: all .2s linear;\n}\n.lcs_label {\n\tfont-family: "Trebuchet MS", Helvetica, sans-serif;\n font-size: 12px;\n\tletter-spacing: 1px;\n\tline-height: 18px;\n\tcolor: #fff;\n\tfont-weight: bold;\n\tposition: absolute;\n\twidth: 33px;\n\ttop: 5px;\n\toverflow: hidden;\n\ttext-align: center;\n\topacity: 0;\n text-shadow: 0 0 2px rgba(0,0,0, .1);\n\ttransition: all .2s ease-in-out .1s;\n}\n.lcs_label.lcs_label_on {\n\tleft: -70px;\n\tz-index: 6;\n}\n.lcs_label.lcs_label_off {\n\tright: -70px;\n\tz-index: 5;\n}\n.lcs_switch.lcs_on {\n\tbackground: #75b936;\n}\n.lcs_switch.lcs_on .lcs_cursor {\n\tleft: 48px;\n}\n.lcs_switch.lcs_on .lcs_label_on {\n\tleft: 10px;\n\topacity: 1;\n}\n.lcs_switch.lcs_off {\n\tbackground: #b2b2b2;\n\tbox-shadow: 0px 0px 2px #a4a4a4 inset;\n}\n.lcs_switch.lcs_off .lcs_cursor {\n\tleft: 3px;\n}\n.lcs_switch.lcs_off .lcs_label_off {\n\tright: 10px;\n\topacity: 1;\n}\n.lcs_switch.lcs_disabled {\n\topacity: 0.65;\n\tcursor: default;\n}\n.lcs_compact {\n height: 22px;\n width: 47px;\n}\n.lcs_compact .lcs_label {\n display: none;\n}\n.lcs_compact .lcs_cursor {\n\tmargin-top: -8px;\n\twidth: 16px;\n\theight: 16px;\n}\n.lcs_compact .lcs_switch.lcs_on .lcs_cursor {\n\tleft: 28px;\n}\n</style>')};
window.lcs_destroy=function(c){f(c).forEach(function(a){g(a)&&a.parentNode.replaceWith(a)})};window.lcs_on=function(c){f(c).forEach(function(a){if(g(a)&&(!a.checked||e)){"radio"==a.getAttribute("type")&&lcs_off(q(a,"form").querySelectorAll('input[name="'+a.getAttribute("name")+'"]'),!0);a.checked=!0;var b=a.previousElementSibling;b.classList.add("lcs_on");b.classList.remove("lcs_off");b.getAttribute("data-on-color")&&(b.style.background=b.getAttribute("data-on-color"));if(!e){b=new Event("lcs-off");
var d=new Event("lcs-statuschange");a.dispatchEvent(b);a.dispatchEvent(d)}}})};window.lcs_off=function(c,a){f(c).forEach(function(b){if(!g(b)||!b.checked&&!e||"radio"==b.getAttribute("type")&&!a&&!e)return!1;b.checked=!1;var d=b.previousElementSibling;d.classList.add("lcs_off");d.classList.remove("lcs_on");d.getAttribute("data-on-color")&&(d.style.background=null);if(!e){d=new Event("lcs-off");var m=new Event("lcs-statuschange");b.dispatchEvent(d);b.dispatchEvent(m)}})};window.lcs_toggle=function(c){f(c).forEach(function(a){if(!g(a)||
"radio"==a.getAttribute("type")&&a.checked)return!1;a.checked?lcs_off(a):lcs_on(a)})};window.lcs_disable=function(c){f(c).forEach(function(a){if(!g(a)||a.disabled&&!e)return!1;a.disabled=!0;a.previousElementSibling.classList.add("lcs_disabled");var b=new Event("lcs-disabled"),d=new Event("lcs-statuschange");a.dispatchEvent(b);a.dispatchEvent(d)})};window.lcs_enable=function(c){f(c).forEach(function(a){if(!g(a)||!a.disabled&&!e)return!1;a.disabled=!1;a.previousElementSibling.classList.remove("lcs_disabled");
var b=new Event("lcs-enabled"),d=new Event("lcs-statuschange");a.dispatchEvent(b);a.dispatchEvent(d)})};window.lcs_update=function(c){f(c).forEach(function(a){if(!g(a))return!1;e=!0;a.checked?lcs_on(a):lcs_off(a);a.disabled?lcs_disable(a):lcs_enable(a);e=!1})};var f=function(c){return"string"!=typeof c?"undefined"!=typeof c[0]?Object.values(c):c.length?c:[c]:document.querySelectorAll(c)},g=function(c){return"INPUT"!=c.tagName||"INPUT"==c.tagName&&"checkbox"!=c.getAttribute("type")&&"radio"!=c.getAttribute("type")||
!c.parentNode.classList.length||c.parentNode.classList.length&&!c.parentNode.classList.contains("lcs_wrap")?!1:!0},q=function(c,a){for(var b=c;null!=b.parentNode&&!b.matches(a);)b=b.parentNode;return b}})();
(function(h){if("undefined"!=typeof Element.prototype.lc_switch)return!1;var e=!1,p={on_txt:"ON",off_txt:"OFF",on_color:!1,compact_mode:!1},q=!1;window.lc_switch=function(c,a){a="object"!=typeof a?p:Object.assign({},p,a);f(c).forEach(function(b){if(!("INPUT"!=b.tagName||"INPUT"==b.tagName&&"checkbox"!=b.getAttribute("type")&&"radio"!=b.getAttribute("type")||b.parentNode.classList.length&&b.parentNode.classList.contains("lcs_wrap"))){var d=a.on_txt?'<div class="lcs_label lcs_label_on">'+a.on_txt+"</div>":
"",m=a.off_txt?'<div class="lcs_label lcs_label_off">'+a.off_txt+"</div>":"",n="lcs_"+b.getAttribute("type");n+=b.checked?" lcs_on":" lcs_off";b.disabled&&(n+=" lcs_disabled");var t=a.on_color&&b.checked?'style="background: '+a.on_color+';"':"",u=a.on_color?'data-on-color="'+a.on_color+'"':"",k=document.createElement("div");k.classList.add("lcs_wrap");k.innerHTML='<div class="lcs_switch '+n+'" '+u+" "+t+'><div class="lcs_cursor"></div>'+d+m+"</div>";a.compact_mode&&k.classList.add("lcs_compact");
b.parentNode.insertBefore(k,b);k.appendChild(b);k.querySelector(".lcs_switch").addEventListener("click",function(l){(l.target.classList.contains("lcs_switch")?l.target:r(l.target,".lcs_switch")).classList.contains("lcs_disabled")||lcs_toggle(b)});b.addEventListener("change",function(l){lcs_update(b)})}});q||(q=!0,document.head.insertAdjacentHTML("beforeend",'<style>\n.lcs_wrap,\n.lcs_wrap * {\n user-select: none;\n}\n.lcs_wrap {\n\tdisplay: inline-block;\n\tdirection: ltr;\n\theight: 28px;\n width: 73px;\n vertical-align: middle;\n}\n.lcs_wrap input {\n\tdisplay: none;\n}\n.lcs_switch {\n\tdisplay: inline-block;\n\tposition: relative;\n\twidth: 100%;\n\theight: 100%;\n\tborder-radius: 30px;\n\tbackground: #ddd;\n\toverflow: hidden;\n\tcursor: pointer;\n\ttransition: all .2s ease-in-out;\n}\n.lcs_cursor {\n\tdisplay: inline-block;\n\tposition: absolute;\n\ttop: 50%;\n margin-top: -11px;\n\twidth: 22px;\n\theight: 22px;\n\tborder-radius: 100%;\n\tbackground: #fff;\n\tbox-shadow: 0 1px 2px 0 rgba(0, 0, 0, .2), 0 3px 4px 0 rgba(0, 0, 0, .1);\n\tz-index: 10;\n\ttransition: all .2s linear;\n}\n.lcs_label {\n\tfont-family: "Trebuchet MS", Helvetica, sans-serif;\n font-size: 12px;\n\tletter-spacing: 1px;\n\tline-height: 18px;\n\tcolor: #fff;\n\tfont-weight: bold;\n\tposition: absolute;\n\twidth: 33px;\n\ttop: 5px;\n\toverflow: hidden;\n\ttext-align: center;\n\topacity: 0;\n text-shadow: 0 0 2px rgba(0,0,0, .1);\n\ttransition: all .2s ease-in-out .1s;\n}\n.lcs_label.lcs_label_on {\n\tleft: -70px;\n\tz-index: 6;\n}\n.lcs_label.lcs_label_off {\n\tright: -70px;\n\tz-index: 5;\n}\n.lcs_switch.lcs_on {\n\tbackground: #75b936;\n}\n.lcs_switch.lcs_on .lcs_cursor {\n\tleft: 48px;\n}\n.lcs_switch.lcs_on .lcs_label_on {\n\tleft: 10px;\n\topacity: 1;\n}\n.lcs_switch.lcs_off {\n\tbackground: #b2b2b2;\n\tbox-shadow: 0px 0px 2px #a4a4a4 inset;\n}\n.lcs_switch.lcs_off .lcs_cursor {\n\tleft: 3px;\n}\n.lcs_switch.lcs_off .lcs_label_off {\n\tright: 10px;\n\topacity: 1;\n}\n.lcs_switch.lcs_disabled {\n\topacity: 0.65;\n\tcursor: default;\n}\n.lcs_compact {\n height: 22px;\n width: 47px;\n}\n.lcs_compact .lcs_label {\n display: none;\n}\n.lcs_compact .lcs_cursor {\n\tmargin-top: -8px;\n\twidth: 16px;\n\theight: 16px;\n}\n.lcs_compact .lcs_switch.lcs_on .lcs_cursor {\n\tleft: 28px;\n}\n</style>'))};
window.lcs_destroy=function(c){f(c).forEach(function(a){g(a)&&a.parentNode.replaceWith(a)})};window.lcs_on=function(c){f(c).forEach(function(a){if(g(a)&&(!a.checked||e)){"radio"==a.getAttribute("type")&&lcs_off(r(a,"form").querySelectorAll('input[name="'+a.getAttribute("name")+'"]'),!0);a.checked=!0;var b=a.previousElementSibling;b.classList.add("lcs_on");b.classList.remove("lcs_off");b.getAttribute("data-on-color")&&(b.style.background=b.getAttribute("data-on-color"));if(!e){b=new Event("lcs-off");
var d=new Event("lcs-statuschange");a.dispatchEvent(b);a.dispatchEvent(d)}}})};window.lcs_off=function(c,a){f(c).forEach(function(b){if(g(b)&&(b.checked||e)&&("radio"!=b.getAttribute("type")||a||e)){b.checked=!1;var d=b.previousElementSibling;d.classList.add("lcs_off");d.classList.remove("lcs_on");d.getAttribute("data-on-color")&&(d.style.background=null);if(!e){d=new Event("lcs-off");var m=new Event("lcs-statuschange");b.dispatchEvent(d);b.dispatchEvent(m)}}})};window.lcs_toggle=function(c){f(c).forEach(function(a){g(a)&&
("radio"==a.getAttribute("type")&&a.checked||(a.checked?lcs_off(a):lcs_on(a)))})};window.lcs_disable=function(c){f(c).forEach(function(a){if(g(a)&&(!a.disabled||e)){a.disabled=!0;a.previousElementSibling.classList.add("lcs_disabled");var b=new Event("lcs-disabled"),d=new Event("lcs-statuschange");a.dispatchEvent(b);a.dispatchEvent(d)}})};window.lcs_enable=function(c){f(c).forEach(function(a){if(g(a)&&(a.disabled||e)){a.disabled=!1;a.previousElementSibling.classList.remove("lcs_disabled");var b=new Event("lcs-enabled"),
d=new Event("lcs-statuschange");a.dispatchEvent(b);a.dispatchEvent(d)}})};window.lcs_update=function(c){f(c).forEach(function(a){g(a)&&(e=!0,a.checked?lcs_on(a):lcs_off(a),a.disabled?lcs_disable(a):lcs_enable(a),e=!1)})};var f=function(c){return"string"!=typeof c?"undefined"!=typeof c[0]?Object.values(c):c.length?c:[c]:document.querySelectorAll(c)},g=function(c){return"INPUT"!=c.tagName||"INPUT"==c.tagName&&"checkbox"!=c.getAttribute("type")&&"radio"!=c.getAttribute("type")||!c.parentNode.classList.length||
c.parentNode.classList.length&&!c.parentNode.classList.contains("lcs_wrap")?!1:!0},r=function(c,a){for(var b=c;null!=b.parentNode&&!b.matches(a);)b=b.parentNode;return b}})();
{
"author": "LCweb",
"name": "lc-switch",
"version": "2.0.0",
"version": "2.0.1",
"description": "Superlight vanilla javascript plugin improving forms look and functionality",

@@ -10,3 +10,3 @@ "keywords": [

"lightweight",
"forms",
"forms",
"checkbox",

@@ -13,0 +13,0 @@ "vanilla-javascript",