mobius1-selectable
Advanced tools
Comparing version 0.0.9-b to 0.0.9-c
{ | ||
"name": "mobius1-selectable", | ||
"version": "0.0.9b", | ||
"version": "0.0.9c", | ||
"ignore": [ | ||
@@ -5,0 +5,0 @@ ".gitattributes", |
{ | ||
"name": "mobius1-selectable", | ||
"version": "0.0.9b", | ||
"version": "0.0.9c", | ||
"description": "UI Selectable plugin without the bloat of jQuery and jQuery UI.", | ||
@@ -5,0 +5,0 @@ "main": "selectable.min.js", |
@@ -8,3 +8,3 @@ /*! | ||
* | ||
* Version: 0.0.9b | ||
* Version: 0.0.9c | ||
* | ||
@@ -243,3 +243,3 @@ */ | ||
this.nodes = this.container.querySelectorAll(this.config.filter); | ||
this.items = []; | ||
this.items = this.selectedItems = []; | ||
@@ -534,3 +534,3 @@ each(this.nodes, function(elem, i) { | ||
Selectable.prototype.selectAll = function() { | ||
each(this.items, this.selectItem); | ||
each(this.items, this.selectItem.bind(this)); | ||
}; | ||
@@ -543,3 +543,3 @@ | ||
Selectable.prototype.clear = function() { | ||
each(this.items, this.deselectItem); | ||
each(this.items, this.deselectItem.bind(this)); | ||
}; | ||
@@ -546,0 +546,0 @@ |
@@ -8,5 +8,5 @@ /*! | ||
* | ||
* Version: 0.0.9b | ||
* Version: 0.0.9c | ||
* | ||
*/ | ||
!function(e,t){"object"==typeof exports?module.exports=t():"function"==typeof define&&define.amd?define([],t):e.Selectable=t()}("undefined"!=typeof global?global:this.window||this.global,function(){"use strict";function e(e,t,s,i){e.addEventListener(t,s,!1)}function t(e,t,s){e.removeEventListener(t,s)}function s(e){this.config=o(i,e),h.mixin(this),this.init()}var i={appendTo:document.body,autoRefresh:!0,filter:"*",tolerance:"touch",lasso:{border:"1px solid #3498db",backgroundColor:"rgba(52, 152, 219, 0.2)"}},n=function(e){return"[object Object]"===Object.prototype.toString.call(e)},o=function(e,t){for(var s in t)if(t.hasOwnProperty(s)){var i=t[s];i&&n(i)?(e[s]=e[s]||{},o(e[s],i)):e[s]=i}return e},c=function(e,t,s){var i;if(n(e))for(i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.call(s,e[i],i);else for(i=0;i<e.length;i++)t.call(s,e[i],i)},l=function(e,t,s){var i=e&&e.style,o=n(t);if(i){if(void 0===s&&!o)return s=window.getComputedStyle(e,""),void 0===t?s:s[t];o?c(t,function(e,t){t in i||(t="-webkit-"+t),i[t]=e+("string"==typeof e?"":"opacity"===t?"":"px")}):(t in i||(t="-webkit-"+t),i[t]=s+("string"==typeof s?"":"opacity"===t?"":"px"))}},r=function(e,t,s){var i;return function(){var n=this,o=arguments,c=s&&!i;clearTimeout(i),i=setTimeout(function(){i=null,s||e.apply(n,o)},t),c&&e.apply(n,o)}},a=function(e){return e=e||window.event,e.preventDefault?e.preventDefault():e.returnValue=!1},u=function(e){return!!e.ctrlKey||!!e.metaKey},d=function(e){return!!e.shiftKey},h=function(){};return h.prototype={on:function(e,t){this._events=this._events||{},this._events[e]=this._events[e]||[],this._events[e].push(t)},off:function(e,t){this._events=this._events||{},e in this._events!=0&&this._events[e].splice(this._events[e].indexOf(t),1)},emit:function(e){if(this._events=this._events||{},e in this._events!=0)for(var t=0;t<this._events[e].length;t++)this._events[e][t].apply(this,Array.prototype.slice.call(arguments,1))}},h.mixin=function(e){for(var t=["on","off","emit"],s=t.length;s--;)"function"==typeof e?e.prototype[t[s]]=h.prototype[t[s]]:e[t[s]]=h.prototype[t[s]];return e},s.prototype.init=function(){var e=document.createElement("div");e.className="ui-lasso",e.style.position="fixed",c(this.config.lasso,function(t,s){e.style[s]=t}),this.lasso=e,"string"==typeof this.config.appendTo||this.config.appendTo instanceof String?this.container=document.querySelector(this.config.appendTo):this.config.appendTo.nodeName&&(this.container=this.config.appendTo),this.update(),this.enable()},s.prototype.update=function(){var e=this;this.nodes=this.container.querySelectorAll(this.config.filter),this.items=[],c(this.nodes,function(t,s){e.items[s]={index:s,element:t,rect:t.getBoundingClientRect(),startselected:!1,selected:t.classList.contains("ui-selected"),selecting:t.classList.contains("ui-selecting"),unselecting:t.classList.contains("ui-unselecting")},t.ondragstart=function(e){a(e)}})},s.prototype.mousedown=function(e){a(e);var t,s=this.config,i=e.target,n=i.classList.contains(s.filter.replace(".",""));if(this.container.appendChild(this.lasso),this.origin={x:e.pageX,y:e.pageY},!s.disabled){if(n&&i.classList.add("ui-selecting"),s.autoRefresh&&this.update(),d(e)){for(var o=!1,l=0;l<this.items.length;l++)if(this.items[l].element===e.target){o=this.items[l];break}for(var r=!1,l=o.index;l>=0&&(this.items[l].selected&&(r=!0),!r||this.items[l].selected);l--)this.items[l].selecting=!0}c(this.items,function(s){var n=s.element;s.selected&&(s.startselected=!0,u(e)||d(e)||(n.classList.remove("ui-selected"),s.selected=!1,n.classList.add("ui-unselecting"),s.unselecting=!0)),n===i&&(t=s)}),this.dragging=!0,n&&this.emit("selectable.down",t)}},s.prototype.mousemove=function(e){if(this.dragging){var t=this.config;if(!t.disabled){var s,i={x1:this.origin.x,y1:this.origin.y,x2:e.pageX,y2:e.pageY};i.x1>i.x2&&(s=i.x2,i.x2=i.x1,i.x1=s),i.y1>i.y2&&(s=i.y2,i.y2=i.y1,i.y1=s),l(this.lasso,{left:i.x1,width:i.x2-i.x1,top:i.y1,height:i.y2-i.y1}),c(this.items,function(s){var n=s.element,o=!1;"touch"==t.tolerance?o=!(s.rect.left>i.x2||s.rect.right<i.x1||s.rect.top>i.y2||s.rect.bottom<i.y1):"fit"==t.tolerance&&(o=s.rect.left>i.x1&&s.rect.right<i.x2&&s.rect.top>i.y1&&s.rect.bottom<i.y2),o?(s.selected&&(n.classList.remove("ui-selected"),s.selected=!1),s.unselecting&&(n.classList.remove("ui-unselecting"),s.unselecting=!1),s.selecting||(n.classList.add("ui-selecting"),s.selecting=!0)):(s.selecting&&(u(e)&&s.startselected?(n.classList.remove("ui-selecting"),s.selecting=!1,n.classList.add("ui-selected"),s.selected=!0):(n.classList.remove("ui-selecting"),s.selecting=!1,s.startselected&&(n.classList.add("ui-unselecting"),s.unselecting=!0))),n.selected&&(u(e)||s.startselected||(n.classList.remove("ui-selected"),s.selected=!1,n.classList.add("ui-unselecting"),s.unselecting=!0)))}),this.emit("selectable.drag",i)}}},s.prototype.mouseup=function(e){if(this.dragging&&(this.dragging=!1),this.container.contains(e.target)){var t=this;this.selectedItems=[],l(this.lasso,{left:0,width:0,top:0,height:0}),c(this.items,function(e){var s=e.element;e.unselecting&&(s.classList.remove("ui-unselecting"),e.unselecting=!1,e.startselected=!1),e.selecting&&t.selectItem(e)}),this.container.removeChild(this.lasso),this.emit("selectable.up",this.selectedItems)}},s.prototype.selectItem=function(e){return this.items.indexOf(e)>=0&&(e.element.classList.remove("ui-selecting"),e.element.classList.add("ui-selected"),e.selecting=!1,e.selected=e.startselected=!0,this.selectedItems.push(e),this.emit("selectable.selected",e))},s.prototype.deselectItem=function(e){return this.items.indexOf(e)>=0&&(e.selecting=e.selected=e.unselecting=e.startselected=!1,e.element.classList.remove("ui-unselecting"),e.element.classList.remove("ui-selecting"),e.element.classList.remove("ui-selected"),this.selectedItems.splice(this.selectedItems.indexOf(e),1),this.emit("selectable.deselected",e))},s.prototype.recalculate=function(){c(this.nodes,function(e,t){this.items[t].rect=e.getBoundingClientRect()},this)},s.prototype.selectAll=function(){c(this.items,this.selectItem)},s.prototype.clear=function(){c(this.items,this.deselectItem)},s.prototype.enable=function(){return this.enabled||(this.enabled=!0,this.events={mousedown:this.mousedown.bind(this),mousemove:this.mousemove.bind(this),mouseup:this.mouseup.bind(this),recalculate:r(this.recalculate,50).bind(this)},e(this.container,"mousedown",this.events.mousedown),e(document,"mousemove",this.events.mousemove),e(document,"mouseup",this.events.mouseup),e(window,"resize",this.events.recalculate),e(window,"scroll",this.events.recalculate)),this.enabled},s.prototype.disable=function(){return this.enabled&&(this.enabled=!1,t(this.container,"mousedown",this.events.mousedown),t(document,"mousemove",this.events.mousemove),t(document,"mouseup",this.events.mouseup),t(window,"resize",this.events.recalculate),t(window,"scroll",this.events.recalculate)),this.enabled},s.prototype.destroy=function(){c(this.items,function(e){var t=e.element;t.classList.remove("ui-unselecting"),t.classList.remove("ui-selecting"),t.classList.remove("ui-selected")}),this.disable()},s}); | ||
!function(e,t){"object"==typeof exports?module.exports=t():"function"==typeof define&&define.amd?define([],t):e.Selectable=t()}("undefined"!=typeof global?global:this.window||this.global,function(){"use strict";function e(e,t,s,i){e.addEventListener(t,s,!1)}function t(e,t,s){e.removeEventListener(t,s)}function s(e){this.config=o(i,e),h.mixin(this),this.init()}var i={appendTo:document.body,autoRefresh:!0,filter:"*",tolerance:"touch",lasso:{border:"1px solid #3498db",backgroundColor:"rgba(52, 152, 219, 0.2)"}},n=function(e){return"[object Object]"===Object.prototype.toString.call(e)},o=function(e,t){for(var s in t)if(t.hasOwnProperty(s)){var i=t[s];i&&n(i)?(e[s]=e[s]||{},o(e[s],i)):e[s]=i}return e},c=function(e,t,s){var i;if(n(e))for(i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.call(s,e[i],i);else for(i=0;i<e.length;i++)t.call(s,e[i],i)},l=function(e,t,s){var i=e&&e.style,o=n(t);if(i){if(void 0===s&&!o)return s=window.getComputedStyle(e,""),void 0===t?s:s[t];o?c(t,function(e,t){t in i||(t="-webkit-"+t),i[t]=e+("string"==typeof e?"":"opacity"===t?"":"px")}):(t in i||(t="-webkit-"+t),i[t]=s+("string"==typeof s?"":"opacity"===t?"":"px"))}},r=function(e,t,s){var i;return function(){var n=this,o=arguments,c=s&&!i;clearTimeout(i),i=setTimeout(function(){i=null,s||e.apply(n,o)},t),c&&e.apply(n,o)}},a=function(e){return e=e||window.event,e.preventDefault?e.preventDefault():e.returnValue=!1},u=function(e){return!!e.ctrlKey||!!e.metaKey},d=function(e){return!!e.shiftKey},h=function(){};return h.prototype={on:function(e,t){this._events=this._events||{},this._events[e]=this._events[e]||[],this._events[e].push(t)},off:function(e,t){this._events=this._events||{},e in this._events!=0&&this._events[e].splice(this._events[e].indexOf(t),1)},emit:function(e){if(this._events=this._events||{},e in this._events!=0)for(var t=0;t<this._events[e].length;t++)this._events[e][t].apply(this,Array.prototype.slice.call(arguments,1))}},h.mixin=function(e){for(var t=["on","off","emit"],s=t.length;s--;)"function"==typeof e?e.prototype[t[s]]=h.prototype[t[s]]:e[t[s]]=h.prototype[t[s]];return e},s.prototype.init=function(){var e=document.createElement("div");e.className="ui-lasso",e.style.position="fixed",c(this.config.lasso,function(t,s){e.style[s]=t}),this.lasso=e,"string"==typeof this.config.appendTo||this.config.appendTo instanceof String?this.container=document.querySelector(this.config.appendTo):this.config.appendTo.nodeName&&(this.container=this.config.appendTo),this.update(),this.enable()},s.prototype.update=function(){var e=this;this.nodes=this.container.querySelectorAll(this.config.filter),this.items=this.selectedItems=[],c(this.nodes,function(t,s){e.items[s]={index:s,element:t,rect:t.getBoundingClientRect(),startselected:!1,selected:t.classList.contains("ui-selected"),selecting:t.classList.contains("ui-selecting"),unselecting:t.classList.contains("ui-unselecting")},t.ondragstart=function(e){a(e)}})},s.prototype.mousedown=function(e){a(e);var t,s=this.config,i=e.target,n=i.classList.contains(s.filter.replace(".",""));if(this.container.appendChild(this.lasso),this.origin={x:e.pageX,y:e.pageY},!s.disabled){if(n&&i.classList.add("ui-selecting"),s.autoRefresh&&this.update(),d(e)){for(var o=!1,l=0;l<this.items.length;l++)if(this.items[l].element===e.target){o=this.items[l];break}for(var r=!1,l=o.index;l>=0&&(this.items[l].selected&&(r=!0),!r||this.items[l].selected);l--)this.items[l].selecting=!0}c(this.items,function(s){var n=s.element;s.selected&&(s.startselected=!0,u(e)||d(e)||(n.classList.remove("ui-selected"),s.selected=!1,n.classList.add("ui-unselecting"),s.unselecting=!0)),n===i&&(t=s)}),this.dragging=!0,n&&this.emit("selectable.down",t)}},s.prototype.mousemove=function(e){if(this.dragging){var t=this.config;if(!t.disabled){var s,i={x1:this.origin.x,y1:this.origin.y,x2:e.pageX,y2:e.pageY};i.x1>i.x2&&(s=i.x2,i.x2=i.x1,i.x1=s),i.y1>i.y2&&(s=i.y2,i.y2=i.y1,i.y1=s),l(this.lasso,{left:i.x1,width:i.x2-i.x1,top:i.y1,height:i.y2-i.y1}),c(this.items,function(s){var n=s.element,o=!1;"touch"==t.tolerance?o=!(s.rect.left>i.x2||s.rect.right<i.x1||s.rect.top>i.y2||s.rect.bottom<i.y1):"fit"==t.tolerance&&(o=s.rect.left>i.x1&&s.rect.right<i.x2&&s.rect.top>i.y1&&s.rect.bottom<i.y2),o?(s.selected&&(n.classList.remove("ui-selected"),s.selected=!1),s.unselecting&&(n.classList.remove("ui-unselecting"),s.unselecting=!1),s.selecting||(n.classList.add("ui-selecting"),s.selecting=!0)):(s.selecting&&(u(e)&&s.startselected?(n.classList.remove("ui-selecting"),s.selecting=!1,n.classList.add("ui-selected"),s.selected=!0):(n.classList.remove("ui-selecting"),s.selecting=!1,s.startselected&&(n.classList.add("ui-unselecting"),s.unselecting=!0))),n.selected&&(u(e)||s.startselected||(n.classList.remove("ui-selected"),s.selected=!1,n.classList.add("ui-unselecting"),s.unselecting=!0)))}),this.emit("selectable.drag",i)}}},s.prototype.mouseup=function(e){if(this.dragging&&(this.dragging=!1),this.container.contains(e.target)){var t=this;this.selectedItems=[],l(this.lasso,{left:0,width:0,top:0,height:0}),c(this.items,function(e){var s=e.element;e.unselecting&&(s.classList.remove("ui-unselecting"),e.unselecting=!1,e.startselected=!1),e.selecting&&t.selectItem(e)}),this.container.removeChild(this.lasso),this.emit("selectable.up",this.selectedItems)}},s.prototype.selectItem=function(e){return this.items.indexOf(e)>=0&&(e.element.classList.remove("ui-selecting"),e.element.classList.add("ui-selected"),e.selecting=!1,e.selected=e.startselected=!0,this.selectedItems.push(e),this.emit("selectable.selected",e))},s.prototype.deselectItem=function(e){return this.items.indexOf(e)>=0&&(e.selecting=e.selected=e.unselecting=e.startselected=!1,e.element.classList.remove("ui-unselecting"),e.element.classList.remove("ui-selecting"),e.element.classList.remove("ui-selected"),this.selectedItems.splice(this.selectedItems.indexOf(e),1),this.emit("selectable.deselected",e))},s.prototype.recalculate=function(){c(this.nodes,function(e,t){this.items[t].rect=e.getBoundingClientRect()},this)},s.prototype.selectAll=function(){c(this.items,this.selectItem.bind(this))},s.prototype.clear=function(){c(this.items,this.deselectItem.bind(this))},s.prototype.enable=function(){return this.enabled||(this.enabled=!0,this.events={mousedown:this.mousedown.bind(this),mousemove:this.mousemove.bind(this),mouseup:this.mouseup.bind(this),recalculate:r(this.recalculate,50).bind(this)},e(this.container,"mousedown",this.events.mousedown),e(document,"mousemove",this.events.mousemove),e(document,"mouseup",this.events.mouseup),e(window,"resize",this.events.recalculate),e(window,"scroll",this.events.recalculate)),this.enabled},s.prototype.disable=function(){return this.enabled&&(this.enabled=!1,t(this.container,"mousedown",this.events.mousedown),t(document,"mousemove",this.events.mousemove),t(document,"mouseup",this.events.mouseup),t(window,"resize",this.events.recalculate),t(window,"scroll",this.events.recalculate)),this.enabled},s.prototype.destroy=function(){c(this.items,function(e){var t=e.element;t.classList.remove("ui-unselecting"),t.classList.remove("ui-selecting"),t.classList.remove("ui-selected")}),this.disable()},s}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
33817