jquery.onoff
Advanced tools
+1
-1
| { | ||
| "name": "onoff", | ||
| "version": "0.3.1", | ||
| "version": "0.3.2", | ||
| "ignore": [ | ||
@@ -5,0 +5,0 @@ "**/.*", |
@@ -1,2 +0,2 @@ | ||
| /** jquery.onoff - v0.3.1 - 2014-03-04 | ||
| /** jquery.onoff - v0.3.2 - 2014-03-11 | ||
| * https://github.com/timmywil/jquery.onoff | ||
@@ -149,2 +149,3 @@ * Copyright (c) 2014 Timmy Willison; Licensed MIT */ | ||
| var $elem = this.$elem; | ||
| var options = this.options; | ||
@@ -155,3 +156,4 @@ // Get or create elem wrapper | ||
| $elem.wrap('<div class="onoffswitch"></div>'); | ||
| $con = $elem.parent(); | ||
| $con = $elem.parent() | ||
| .addClass(elem.className.replace(options.className, '')); | ||
| } | ||
@@ -301,3 +303,3 @@ this.$con = $con; | ||
| this.$label.remove(); | ||
| this.$elem.unwrap(); | ||
| this.$elem.unwrap().removeClass(this.options.className); | ||
| }, | ||
@@ -304,0 +306,0 @@ |
@@ -1,4 +0,4 @@ | ||
| /** jquery.onoff - v0.3.1 - 2014-03-04 | ||
| /** jquery.onoff - v0.3.2 - 2014-03-11 | ||
| * https://github.com/timmywil/jquery.onoff | ||
| * Copyright (c) 2014 Timmy Willison; Licensed MIT */ | ||
| !function(a,b){"function"==typeof define&&define.amd?define(["jquery"],b):"object"==typeof exports?b(require("jquery")):b(a.jQuery)}(this,function(a){"use strict";function b(c,d){if(!(this instanceof b))return new b(c,d);if("input"!==c.nodeName.toLowerCase()||"checkbox"!==c.type)return a.error("OnOff should be called on checkboxes");var e=a.data(c,b.datakey);return e?e:(this.options=d=a.extend({},b.defaults,d),this.elem=c,this.$elem=a(c).addClass(d.className),this.$doc=a(c.ownerDocument||document),d.namespace+=a.guid++,c.id||(c.id="onoffswitch"+g++),this.enable(),a.data(c,b.datakey,this),void 0)}var c="over out down up move enter leave cancel".split(" "),d=a.extend({},a.event.mouseHooks),e={};if(window.PointerEvent)a.each(c,function(b,c){a.event.fixHooks[e[c]="pointer"+c]=d});else{var f=d.props;d.props=f.concat(["touches","changedTouches","targetTouches","altKey","ctrlKey","metaKey","shiftKey"]),d.filter=function(a,b){var c,d=f.length;if(!b.pageX&&b.touches&&(c=b.touches[0]))for(;d--;)a[f[d]]=c[f[d]];return a},a.each(c,function(b,c){if(2>b)e[c]="mouse"+c;else{var f="touch"+("down"===c?"start":"up"===c?"end":c);a.event.fixHooks[f]=d,e[c]=f+" mouse"+c}})}a.pointertouch=e;var g=1,h=Array.prototype.slice;return b.datakey="_onoff",b.defaults={namespace:".onoff",className:"onoffswitch-checkbox"},b.prototype={constructor:b,instance:function(){return this},wrap:function(){var b=this.elem,c=this.$elem,d=c.parent(".onoffswitch");d.length||(c.wrap('<div class="onoffswitch"></div>'),d=c.parent()),this.$con=d;var e=c.next('label[for="'+b.id+'"]');e.length||(e=a("<label/>").attr("for",b.id).insertAfter(b)),this.$label=e.addClass("onoffswitch-label");var f=e.find(".onoffswitch-inner");f.length||(f=a("<div/>").addClass("onoffswitch-inner").prependTo(e)),this.$inner=f;var g=e.find(".onoffswitch-switch");g.length||(g=a("<div/>").addClass("onoffswitch-switch").appendTo(e)),this.$switch=g},_handleMove:function(a){if(!this.disabled){this.moved=!0,this.lastX=a.clientX;var b=Math.max(Math.min(this.startX-this.lastX,this.maxRight),0);this.$switch.css("right",b),this.$inner.css("marginLeft",100*-(b/this.maxRight)+"%")}},_startMove:function(b){b.preventDefault();var c,d;"pointerdown"===b.type?(c="pointermove",d="pointerup"):"touchstart"===b.type?(c="touchmove",d="touchend"):(c="mousemove",d="mouseup");var e=this.elem,f=this.options.namespace,g=this.$switch,h=g[0],i=this.$inner.add(g).css("transition","none");this.maxRight=this.$con.width()-g.width()-a.css(h,"margin-left",!0)-a.css(h,"margin-right",!0)-a.css(h,"border-left-width",!0)-a.css(h,"border-right-width",!0);var j=e.checked;this.moved=!1,this.startX=b.clientX+(j?0:this.maxRight);var k=this,l=this.$doc.on(c+f,a.proxy(this._handleMove,this)).on(d+f,function(){i.css("transition",""),l.off(f),setTimeout(function(){k.moved&&(e.checked=k.lastX>k.startX-k.maxRight/2),k.$switch.css("right",""),k.$inner.css("marginLeft","")})})},_bind:function(){this._unbind(),this.$switch.on(a.pointertouch.down,a.proxy(this._startMove,this))},enable:function(){this.wrap(),this._bind(),this.disabled=!1},_unbind:function(){this.$doc.add(this.$switch).off(this.options.namespace)},disable:function(){this.disabled=!0,this._unbind()},unwrap:function(){this.disable(),this.$label.remove(),this.$elem.unwrap()},isDisabled:function(){return this.disabled},destroy:function(){this.disable(),a.removeData(this.elem,b.datakey)},option:function(b,c){var d,e=this.options;if(!b)return a.extend({},e);if("string"==typeof b){if(1===arguments.length)return void 0!==e[b]?e[b]:null;d={},d[b]=c}else d=b;a.each(d,a.proxy(function(a,b){switch(a){case"namespace":this._unbind();break;case"className":this.$elem.removeClass(e.className)}switch(e[a]=b,a){case"namespace":this._bind();break;case"className":this.$elem.addClass(b)}},this))}},a.fn.onoff=function(c){var d,e,f,g;return"string"==typeof c?(g=[],e=h.call(arguments,1),this.each(function(){d=a.data(this,b.datakey),d?"_"!==c.charAt(0)&&"function"==typeof(f=d[c])&&void 0!==(f=f.apply(d,e))&&g.push(f):g.push(void 0)}),g.length?1===g.length?g[0]:g:this):this.each(function(){new b(this,c)})},a.OnOff=b}); | ||
| !function(a,b){"function"==typeof define&&define.amd?define(["jquery"],b):"object"==typeof exports?b(require("jquery")):b(a.jQuery)}(this,function(a){"use strict";function b(c,d){if(!(this instanceof b))return new b(c,d);if("input"!==c.nodeName.toLowerCase()||"checkbox"!==c.type)return a.error("OnOff should be called on checkboxes");var e=a.data(c,b.datakey);return e?e:(this.options=d=a.extend({},b.defaults,d),this.elem=c,this.$elem=a(c).addClass(d.className),this.$doc=a(c.ownerDocument||document),d.namespace+=a.guid++,c.id||(c.id="onoffswitch"+g++),this.enable(),a.data(c,b.datakey,this),void 0)}var c="over out down up move enter leave cancel".split(" "),d=a.extend({},a.event.mouseHooks),e={};if(window.PointerEvent)a.each(c,function(b,c){a.event.fixHooks[e[c]="pointer"+c]=d});else{var f=d.props;d.props=f.concat(["touches","changedTouches","targetTouches","altKey","ctrlKey","metaKey","shiftKey"]),d.filter=function(a,b){var c,d=f.length;if(!b.pageX&&b.touches&&(c=b.touches[0]))for(;d--;)a[f[d]]=c[f[d]];return a},a.each(c,function(b,c){if(2>b)e[c]="mouse"+c;else{var f="touch"+("down"===c?"start":"up"===c?"end":c);a.event.fixHooks[f]=d,e[c]=f+" mouse"+c}})}a.pointertouch=e;var g=1,h=Array.prototype.slice;return b.datakey="_onoff",b.defaults={namespace:".onoff",className:"onoffswitch-checkbox"},b.prototype={constructor:b,instance:function(){return this},wrap:function(){var b=this.elem,c=this.$elem,d=this.options,e=c.parent(".onoffswitch");e.length||(c.wrap('<div class="onoffswitch"></div>'),e=c.parent().addClass(b.className.replace(d.className,""))),this.$con=e;var f=c.next('label[for="'+b.id+'"]');f.length||(f=a("<label/>").attr("for",b.id).insertAfter(b)),this.$label=f.addClass("onoffswitch-label");var g=f.find(".onoffswitch-inner");g.length||(g=a("<div/>").addClass("onoffswitch-inner").prependTo(f)),this.$inner=g;var h=f.find(".onoffswitch-switch");h.length||(h=a("<div/>").addClass("onoffswitch-switch").appendTo(f)),this.$switch=h},_handleMove:function(a){if(!this.disabled){this.moved=!0,this.lastX=a.clientX;var b=Math.max(Math.min(this.startX-this.lastX,this.maxRight),0);this.$switch.css("right",b),this.$inner.css("marginLeft",100*-(b/this.maxRight)+"%")}},_startMove:function(b){b.preventDefault();var c,d;"pointerdown"===b.type?(c="pointermove",d="pointerup"):"touchstart"===b.type?(c="touchmove",d="touchend"):(c="mousemove",d="mouseup");var e=this.elem,f=this.options.namespace,g=this.$switch,h=g[0],i=this.$inner.add(g).css("transition","none");this.maxRight=this.$con.width()-g.width()-a.css(h,"margin-left",!0)-a.css(h,"margin-right",!0)-a.css(h,"border-left-width",!0)-a.css(h,"border-right-width",!0);var j=e.checked;this.moved=!1,this.startX=b.clientX+(j?0:this.maxRight);var k=this,l=this.$doc.on(c+f,a.proxy(this._handleMove,this)).on(d+f,function(){i.css("transition",""),l.off(f),setTimeout(function(){k.moved&&(e.checked=k.lastX>k.startX-k.maxRight/2),k.$switch.css("right",""),k.$inner.css("marginLeft","")})})},_bind:function(){this._unbind(),this.$switch.on(a.pointertouch.down,a.proxy(this._startMove,this))},enable:function(){this.wrap(),this._bind(),this.disabled=!1},_unbind:function(){this.$doc.add(this.$switch).off(this.options.namespace)},disable:function(){this.disabled=!0,this._unbind()},unwrap:function(){this.disable(),this.$label.remove(),this.$elem.unwrap().removeClass(this.options.className)},isDisabled:function(){return this.disabled},destroy:function(){this.disable(),a.removeData(this.elem,b.datakey)},option:function(b,c){var d,e=this.options;if(!b)return a.extend({},e);if("string"==typeof b){if(1===arguments.length)return void 0!==e[b]?e[b]:null;d={},d[b]=c}else d=b;a.each(d,a.proxy(function(a,b){switch(a){case"namespace":this._unbind();break;case"className":this.$elem.removeClass(e.className)}switch(e[a]=b,a){case"namespace":this._bind();break;case"className":this.$elem.addClass(b)}},this))}},a.fn.onoff=function(c){var d,e,f,g;return"string"==typeof c?(g=[],e=h.call(arguments,1),this.each(function(){d=a.data(this,b.datakey),d?"_"!==c.charAt(0)&&"function"==typeof(f=d[c])&&void 0!==(f=f.apply(d,e))&&g.push(f):g.push(void 0)}),g.length?1===g.length?g[0]:g:this):this.each(function(){new b(this,c)})},a.OnOff=b}); |
+9
-4
@@ -63,3 +63,3 @@ 'use strict'; | ||
| hostname: '*', | ||
| port: 9000 | ||
| port: 9001 | ||
| } | ||
@@ -110,3 +110,3 @@ } | ||
| options: { | ||
| urls: ['http://localhost:9000/test/index.html'] | ||
| urls: ['http://localhost:9001/test/index.html'] | ||
| } | ||
@@ -140,7 +140,7 @@ } | ||
| files: '<%= jshint.src.src %>', | ||
| tasks: ['jshint:src', 'concat', 'qunit'] | ||
| tasks: ['jshint:src', 'build', 'connect', 'qunit'] | ||
| }, | ||
| test: { | ||
| files: ['<%= jshint.test.src %>', 'test/index.html'], | ||
| tasks: ['jshint:test', 'qunit'] | ||
| tasks: ['jshint:test', 'connect', 'qunit'] | ||
| }, | ||
@@ -181,2 +181,7 @@ css: { | ||
| // Remove pointerhook dependency | ||
| compiled = compiled | ||
| .replace(', \'./pointertouch\'', '') | ||
| .replace(', require(\'./pointertouch\')', ''); | ||
| // Write source to file | ||
@@ -183,0 +188,0 @@ grunt.file.write( dest, compiled ); |
@@ -5,3 +5,3 @@ { | ||
| "description": "Interactive, accessible toggle switches for the web", | ||
| "version": "0.3.1", | ||
| "version": "0.3.2", | ||
| "homepage": "https://github.com/timmywil/jquery.onoff", | ||
@@ -8,0 +8,0 @@ "author": { |
+1
-1
| { | ||
| "name": "jquery.onoff", | ||
| "version": "0.3.1", | ||
| "version": "0.3.2", | ||
| "description": "Interactive, accessible toggle switches for the web", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
+4
-3
@@ -33,5 +33,5 @@ # On-Off Toggle Switch | ||
| [min]: https://raw.github.com/timmywil/jquery.onoff/0.3.1/dist/jquery.onoff.min.js | ||
| [max]: https://raw.github.com/timmywil/jquery.onoff/0.3.1/dist/jquery.onoff.js | ||
| [css]: https://raw.github.com/timmywil/jquery.onoff/0.3.1/dist/jquery.onoff.css | ||
| [min]: https://raw.github.com/timmywil/jquery.onoff/0.3.2/dist/jquery.onoff.min.js | ||
| [max]: https://raw.github.com/timmywil/jquery.onoff/0.3.2/dist/jquery.onoff.js | ||
| [css]: https://raw.github.com/timmywil/jquery.onoff/0.3.2/dist/jquery.onoff.css | ||
@@ -192,2 +192,3 @@ ### With AMD | ||
| **0.3.2** *3/11/2014* Container now inherits classes from the checkbox | ||
| **0.3.1** *3/3/2014* Minor pointertouch update | ||
@@ -194,0 +195,0 @@ **0.3.0** *3/3/2014* Update to full-blown pointertouch |
+6
-4
| (function(global, factory) { | ||
| // AMD | ||
| if (typeof define === 'function' && define.amd) { | ||
| define([ 'jquery' ], factory); | ||
| define([ 'jquery', './pointertouch' ], factory); | ||
| // CommonJS/Browserify | ||
| } else if (typeof exports === 'object') { | ||
| factory(require('jquery')); | ||
| factory(require('jquery'), require('./pointertouch')); | ||
| // Global | ||
@@ -95,2 +95,3 @@ } else { | ||
| var $elem = this.$elem; | ||
| var options = this.options; | ||
@@ -101,3 +102,4 @@ // Get or create elem wrapper | ||
| $elem.wrap('<div class="onoffswitch"></div>'); | ||
| $con = $elem.parent(); | ||
| $con = $elem.parent() | ||
| .addClass(elem.className.replace(options.className, '')); | ||
| } | ||
@@ -247,3 +249,3 @@ this.$con = $con; | ||
| this.$label.remove(); | ||
| this.$elem.unwrap(); | ||
| this.$elem.unwrap().removeClass(this.options.className); | ||
| }, | ||
@@ -250,0 +252,0 @@ |
@@ -78,2 +78,10 @@ require({ | ||
| test('created container inherits classes from the input', function() { | ||
| expect(2); | ||
| var cls = 'extra-class'; | ||
| this.$inputs.addClass(cls).onoff().each(function() { | ||
| ok(this.parentNode.className.indexOf(cls) > -1, 'Parent has class'); | ||
| }).removeClass(cls); | ||
| }); | ||
| /* Methods | ||
@@ -80,0 +88,0 @@ ---------------------------------------------------------------------- */ |
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 2 instances in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 2 instances in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
480948
0.19%13488
0.11%202
0.5%71
1.43%