jquery.onoff
Advanced tools
+1
-1
| { | ||
| "name": "onoff", | ||
| "version": "0.3.0", | ||
| "version": "0.3.1", | ||
| "ignore": [ | ||
@@ -5,0 +5,0 @@ "**/.*", |
+23
-17
@@ -1,2 +0,2 @@ | ||
| /** jquery.onoff - v0.3.0 - 2014-03-03 | ||
| /** jquery.onoff - v0.3.1 - 2014-03-04 | ||
| * https://github.com/timmywil/jquery.onoff | ||
@@ -19,7 +19,5 @@ * Copyright (c) 2014 Timmy Willison; Licensed MIT */ | ||
| // Common properties to lift for touch or pointer events | ||
| var hook = $.event.mouseHooks; | ||
| var props = hook.props; | ||
| var list = 'over out down up move enter leave cancel'.split(' '); | ||
| var hook = $.extend({}, $.event.mouseHooks); | ||
| var events = {}; | ||
| var list = 'over out down up move enter leave cancel'.split(' '); | ||
| var touchReplace = { down: 'start', up: 'end' }; | ||
@@ -35,4 +33,5 @@ // Support pointer events in IE11+ if available | ||
| } else { | ||
| // Add touches property for the touch hook | ||
| props.push('touches', 'changedTouches', 'targetTouches', 'altKey', 'ctrlKey', 'metaKey', 'shiftKey'); | ||
| var mouseProps = hook.props; | ||
| // Add touch properties for the touch hook | ||
| hook.props = mouseProps.concat(['touches', 'changedTouches', 'targetTouches', 'altKey', 'ctrlKey', 'metaKey', 'shiftKey']); | ||
@@ -46,7 +45,8 @@ /** | ||
| var touch; | ||
| var i = mouseProps.length; | ||
| if ( !originalEvent.pageX && originalEvent.touches && (touch = originalEvent.touches[0]) ) { | ||
| event.pageX = touch.pageX; | ||
| event.pageY = touch.pageY; | ||
| event.clientX = touch.clientX; | ||
| event.clientY = touch.clientY; | ||
| // Copy over all mouse properties | ||
| while(i--) { | ||
| event[mouseProps[i]] = touch[mouseProps[i]]; | ||
| } | ||
| } | ||
@@ -57,8 +57,14 @@ return event; | ||
| // Take off 'over' and 'out' when attaching touch hooks | ||
| $.each(list.slice(2), function( i, name ) { | ||
| var touch = 'touch' + (touchReplace[name] || name); | ||
| // Add fixHook | ||
| $.event.fixHooks[ touch ] = hook; | ||
| // Add event names to events property | ||
| events[ name ] = touch + ' mouse' + name; | ||
| $.each(list, function( i, name ) { | ||
| // No equivalent touch events for over and out | ||
| if (i < 2) { | ||
| events[ name ] = 'mouse' + name; | ||
| } else { | ||
| var touch = 'touch' + | ||
| (name === 'down' ? 'start' : name === 'up' ? 'end' : name); | ||
| // Add fixHook | ||
| $.event.fixHooks[ touch ] = hook; | ||
| // Add event names to events property | ||
| events[ name ] = touch + ' mouse' + name; | ||
| } | ||
| }); | ||
@@ -65,0 +71,0 @@ } |
@@ -1,4 +0,4 @@ | ||
| /** jquery.onoff - v0.3.0 - 2014-03-03 | ||
| /** jquery.onoff - v0.3.1 - 2014-03-04 | ||
| * 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"+h++),this.enable(),a.data(c,b.datakey,this),void 0)}var c=a.event.mouseHooks,d=c.props,e={},f="over out down up move enter leave cancel".split(" "),g={down:"start",up:"end"};window.PointerEvent?a.each(f,function(b,d){a.event.fixHooks[e[d]="pointer"+d]=c}):(d.push("touches","changedTouches","targetTouches","altKey","ctrlKey","metaKey","shiftKey"),c.filter=function(a,b){var c;return!b.pageX&&b.touches&&(c=b.touches[0])&&(a.pageX=c.pageX,a.pageY=c.pageY,a.clientX=c.clientX,a.clientY=c.clientY),a},a.each(f.slice(2),function(b,d){var f="touch"+(g[d]||d);a.event.fixHooks[f]=c,e[d]=f+" mouse"+d})),a.pointertouch=e;var h=1,i=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=i.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=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}); |
@@ -5,3 +5,3 @@ { | ||
| "description": "Interactive, accessible toggle switches for the web", | ||
| "version": "0.3.0", | ||
| "version": "0.3.1", | ||
| "homepage": "https://github.com/timmywil/jquery.onoff", | ||
@@ -8,0 +8,0 @@ "author": { |
+1
-1
| { | ||
| "name": "jquery.onoff", | ||
| "version": "0.3.0", | ||
| "version": "0.3.1", | ||
| "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.0/dist/jquery.onoff.min.js | ||
| [max]: https://raw.github.com/timmywil/jquery.onoff/0.3.0/dist/jquery.onoff.js | ||
| [css]: https://raw.github.com/timmywil/jquery.onoff/0.3.0/dist/jquery.onoff.css | ||
| [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 | ||
@@ -192,2 +192,3 @@ ### With AMD | ||
| **0.3.1** *3/3/2014* Minor pointertouch update | ||
| **0.3.0** *3/3/2014* Update to full-blown pointertouch | ||
@@ -194,0 +195,0 @@ **0.2.4** *3/3/2014* Integrate [jquery.event.pointertouch](https://github.com/timmywil/jquery.event.pointertouch) into build. |
+23
-17
| /** | ||
| * jquery.event.pointertouch | ||
| * Lift touch and pointer event properties to the jQuery event object | ||
| * @version v0.1.0 | ||
| * @version v0.1.1 | ||
| * @license MIT | ||
@@ -22,7 +22,5 @@ */ | ||
| // Common properties to lift for touch or pointer events | ||
| var hook = $.event.mouseHooks; | ||
| var props = hook.props; | ||
| var list = 'over out down up move enter leave cancel'.split(' '); | ||
| var hook = $.extend({}, $.event.mouseHooks); | ||
| var events = {}; | ||
| var list = 'over out down up move enter leave cancel'.split(' '); | ||
| var touchReplace = { down: 'start', up: 'end' }; | ||
@@ -38,4 +36,5 @@ // Support pointer events in IE11+ if available | ||
| } else { | ||
| // Add touches property for the touch hook | ||
| props.push('touches', 'changedTouches', 'targetTouches', 'altKey', 'ctrlKey', 'metaKey', 'shiftKey'); | ||
| var mouseProps = hook.props; | ||
| // Add touch properties for the touch hook | ||
| hook.props = mouseProps.concat(['touches', 'changedTouches', 'targetTouches', 'altKey', 'ctrlKey', 'metaKey', 'shiftKey']); | ||
@@ -49,7 +48,8 @@ /** | ||
| var touch; | ||
| var i = mouseProps.length; | ||
| if ( !originalEvent.pageX && originalEvent.touches && (touch = originalEvent.touches[0]) ) { | ||
| event.pageX = touch.pageX; | ||
| event.pageY = touch.pageY; | ||
| event.clientX = touch.clientX; | ||
| event.clientY = touch.clientY; | ||
| // Copy over all mouse properties | ||
| while(i--) { | ||
| event[mouseProps[i]] = touch[mouseProps[i]]; | ||
| } | ||
| } | ||
@@ -60,8 +60,14 @@ return event; | ||
| // Take off 'over' and 'out' when attaching touch hooks | ||
| $.each(list.slice(2), function( i, name ) { | ||
| var touch = 'touch' + (touchReplace[name] || name); | ||
| // Add fixHook | ||
| $.event.fixHooks[ touch ] = hook; | ||
| // Add event names to events property | ||
| events[ name ] = touch + ' mouse' + name; | ||
| $.each(list, function( i, name ) { | ||
| // No equivalent touch events for over and out | ||
| if (i < 2) { | ||
| events[ name ] = 'mouse' + name; | ||
| } else { | ||
| var touch = 'touch' + | ||
| (name === 'down' ? 'start' : name === 'up' ? 'end' : name); | ||
| // Add fixHook | ||
| $.event.fixHooks[ touch ] = hook; | ||
| // Add event names to events property | ||
| events[ name ] = touch + ' mouse' + name; | ||
| } | ||
| }); | ||
@@ -68,0 +74,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
480036
0.08%13473
0.09%201
0.5%