Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

mobius1-selectable

Package Overview
Dependencies
Maintainers
1
Versions
54
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mobius1-selectable - npm Package Compare versions

Comparing version 0.4.1 to 0.5.0

2

bower.json
{
"name": "mobius1-selectable",
"version": "0.4.1",
"version": "0.5.0",
"ignore": [

@@ -5,0 +5,0 @@ ".gitattributes",

{
"name": "mobius1-selectable",
"version": "0.4.1",
"version": "0.5.0",
"description": "UI Selectable plugin without the bloat of jQuery and jQuery UI.",

@@ -5,0 +5,0 @@ "main": "selectable.min.js",

@@ -84,3 +84,3 @@ # Selectable

index: Number, // the position of the item in the list
rect: DOMRect Object, // the element's bounding rects
rect: DOMRect, // the element's bounding rects
startselected: Boolean,

@@ -93,3 +93,3 @@ selected: Boolean, // is the item currently selected

| Method | Args | Return | Effect |
| Method | Arg | Return | Effect |
|----------------------|----------|------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------|

@@ -106,2 +106,4 @@ | `destroy()` | | | Destroy the instance. This will return the DOM to it's initial state before initialsing. |

| `clear()` | | | Deselects all valid items. |
| `add()` | `Object` | | Add a new item. Must me a valid `HTMLElement` node. |
| `remove()` | `Mixed` | | Removes an item or items. Can be an index, node, item or collection. |
| `getItem()` | `Mixed` | `Object` | Returns a reference to the item if found or `false` if not. You can pass the same mixed argument as with `select()` and `unselect()`. |

@@ -122,5 +124,5 @@ | `getItems()` | | `Array` | Returns an `Array` of all items. |

// Listen for the 'XXXX' event
selectable.on('XXXX', function(/* args */) {
// Do something when 'XXXX' fires
// Listen for the 'selectable.XXXX' event
selectable.on('selectable.XXXX', function(/* params */) {
// Do something when 'selectable.XXXX' fires
});

@@ -127,0 +129,0 @@ ```

@@ -8,3 +8,3 @@ /*!

*
* Version: 0.4.1
* Version: 0.5.0
*

@@ -332,2 +332,3 @@ */

classList.add(el, o.classes.selectable);
that.items[i] = {

@@ -341,3 +342,3 @@ index: i,

unselecting: classList.contains(el, o.classes.unselecting)
}
};
});

@@ -640,2 +641,48 @@

Selectable.prototype.add = function(node) {
var o = this.config;
if (isCollection(node)) {
each(node, function(i) {
this.add(i);
}, this);
} else {
if (this.nodes.indexOf(node) < 0) {
classList.add(node, o.classes.selectable);
this.items.push({
index: this.items.length,
element: node,
rect: rect(node),
startselected: false,
selected: classList.contains(node, o.classes.selected),
selecting: classList.contains(node, o.classes.selecting),
unselecting: classList.contains(node, o.classes.unselecting)
});
}
}
this.update();
};
Selectable.prototype.remove = function(item) {
item = this.getItem(item);
if (item) {
if (isCollection(item)) {
for (var i = item.length - 1; i >= 0; i--) {
this.remove(item[i]);
}
} else {
var el = item.element,
o = this.config.classes;
classList.remove(el, o.selectable);
classList.remove(el, o.unselecting);
classList.remove(el, o.selecting);
classList.remove(el, o.selected);
this.items.splice(this.items.indexOf(item), 1);
}
}
};
/**

@@ -678,16 +725,24 @@ * Update item coords

var found = false;
// item is an index
if (!isNaN(item)) {
if (this.items.indexOf(this.items[item]) >= 0) {
found = this.items[item];
if (isCollection(item)) {
found = [];
each(item, function(i) {
found.push(this.getItem(i));
}, this);
} else {
// item is an index
if (!isNaN(item)) {
if (this.items.indexOf(this.items[item]) >= 0) {
found = this.items[item];
}
}
// item is a node
else if (item instanceof Element) {
found = this.items[this.nodes.indexOf(item)];
}
// item is an item
else if (isObject(item) && this.items.indexOf(item) >= 0) {
found = item;
}
}
// item is a node
else if (item instanceof Element) {
found = this.items[this.nodes.indexOf(item)];
}
// item is an item
else if (isObject(item) && this.items.indexOf(item) >= 0) {
found = item;
}
return found;

@@ -694,0 +749,0 @@ };

@@ -8,5 +8,5 @@ /*!

*
* Version: 0.4.1
* Version: 0.5.0
*
*/
!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=l(i,e),p.mixin(this),this.init()}var i={appendTo:document.body,autoRefresh:!0,filter:".ui-selectable",tolerance:"touch",lasso:{border:"1px dotted #3498db",backgroundColor:"rgba(52, 152, 219, 0.2)"},classes:{container:"ui-container",selectable:"ui-selectable",selecting:"ui-selecting",unselecting:"ui-unselecting",selected:"ui-selected"}},n=function(e,t){return e&&e!==document.body&&(t(e)?e:n(e.parentNode,t))},o=function(e){return"[object Object]"===Object.prototype.toString.call(e)},c=function(e){return Array.isArray(e)||e instanceof NodeList||e instanceof HTMLCollection},l=function(e,t){for(var s in t)if(t.hasOwnProperty(s)){var i=t[s];i&&o(i)?(e[s]=e[s]||{},l(e[s],i)):e[s]=i}return e},a=function(e,t,s){var i;if(o(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)},r=function(e,t,s){var i=e&&e.style,n=o(t);if(i){if(void 0===s&&!n)return s=window.getComputedStyle(e,""),void 0===t?s:s[t];n?a(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"))}},u=function(e){var t=window,s=e.getBoundingClientRect(),i=document.documentElement||document.body.parentNode||document.body,n=void 0!==t.pageXOffset?t.pageXOffset:i.scrollLeft,o=void 0!==t.pageYOffset?t.pageYOffset:i.scrollTop;return{x1:s.left+n,x2:s.left+s.width+n,y1:s.top+o,y2:s.top+s.height+o,height:s.height,width:s.width}},d=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)}},h={add:function(e,t){e.classList?e.classList.add(t):h.contains(e,t)||(e.className=e.className.trim()+" "+t)},remove:function(e,t){e.classList?e.classList.remove(t):h.contains(e,t)&&(e.className=e.className.replace(new RegExp("(^|\\s)"+t.split(" ").join("|")+"(\\s|$)","gi")," "))},contains:function(e,t){if(e)return e.classList?e.classList.contains(t):!!e.className&&!!e.className.match(new RegExp("(\\s|^)"+t+"(\\s|$)"))}},f=function(e){return!!e.ctrlKey||!!e.metaKey},m=function(e){return!!e.shiftKey},p=function(){};return p.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))}},p.mixin=function(e){for(var t=["on","off","emit"],s=t.length;s--;)"function"==typeof e?e.prototype[t[s]]=p.prototype[t[s]]:e[t[s]]=p.prototype[t[s]];return e},s.prototype.init=function(){var e=this,t=this.config;this.lasso=document.createElement("div"),this.lasso.className="ui-lasso",r(this.lasso,l({position:"fixed",opacity:0},t.lasso)),"string"==typeof t.appendTo?this.container=document.querySelector(t.appendTo):t.appendTo.nodeName&&(this.container=t.appendTo),this.update(),this.enable(),setTimeout(function(){e.emit("selectable.init")},10)},s.prototype.update=function(){var e=this,t=this.config;t.filter instanceof NodeList||t.filter instanceof HTMLCollection?this.nodes=t.filter:"string"==typeof t.filter&&(this.nodes=[].slice.call(this.container.querySelectorAll(t.filter))),this.items=[],a(this.nodes,function(s,i){h.add(s,t.classes.selectable),e.items[i]={index:i,element:s,rect:u(s),startselected:!1,selected:h.contains(s,t.classes.selected),selecting:h.contains(s,t.classes.selecting),unselecting:h.contains(s,t.classes.unselecting)}}),e.emit("selectable.update")},s.prototype.mousedown=function(e){e.preventDefault();var t,s=this.config,i=n(e.target,function(e){return h.contains(e,s.classes.selectable)});if(this.container.appendChild(this.lasso),this.origin={x:e.pageX,y:e.pageY},!s.disabled){if(i&&h.add(i,s.classes.selecting),s.autoRefresh&&this.update(),m(e))for(var o=!1,c=this.items.length-1;c>=0&&(this.items[c].element===i&&(o=!0),!o||!this.items[c].selected);c--)o&&(this.items[c].selecting=!0);a(this.items,function(n){var o=n.element;n.selected&&o!==i&&(n.startselected=!0,f(e)||m(e)||(h.remove(o,s.classes.selected),n.selected=!1,h.add(o,s.classes.unselecting),n.unselecting=!0)),o===i&&(t=n)}),this.dragging=!0,i&&this.emit("selectable.mousedown",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),r(this.lasso,{opacity:1,left:i.x1,width:i.x2-i.x1,top:i.y1,height:i.y2-i.y1}),a(this.items,function(s){var n=s.element,o=!1;"touch"==t.tolerance?o=!(s.rect.x1>i.x2||s.rect.x2<i.x1||s.rect.y1>i.y2||s.rect.y2<i.y1):"fit"==t.tolerance&&(o=s.rect.x1>i.x1&&s.rect.x2<i.x2&&s.rect.y1>i.y1&&s.rect.y2<i.y2),o?(s.selected&&(h.remove(n,t.classes.selected),s.selected=!1),s.unselecting&&(h.remove(n,t.classes.unselecting),s.unselecting=!1),s.selecting||(h.add(n,t.classes.selecting),s.selecting=!0)):(s.selecting&&(f(e)&&s.startselected?(h.remove(n,t.classes.selecting),s.selecting=!1,h.add(n,t.classes.selected),s.selected=!0):(h.remove(n,t.classes.selecting),s.selecting=!1,s.startselected&&(h.add(n,t.classes.unselecting),s.unselecting=!0))),n.selected&&(f(e)||s.startselected||(h.remove(n,t.classes.selected),s.selected=!1,h.add(n,t.classes.unselecting),s.unselecting=!0)))}),this.emit("selectable.mousemove",i)}}},s.prototype.mouseup=function(e){if(this.dragging&&(this.dragging=!1),this.container.contains(e.target)){var t=this;r(this.lasso,{opacity:0,left:0,width:0,top:0,height:0});var s=[];a(this.items,function(e){e.element;e.unselecting&&t.unselect(e),e.selecting&&(s.push(e),t.select(e))}),this.container.removeChild(this.lasso),this.emit("selectable.mouseup",s)}},s.prototype.select=function(e){if(c(e))return a(e,function(e){this.select(e)},this),this.getSelectedItems();if(e=this.getItem(e)){var t=e.element,s=this.config.classes;return h.remove(t,s.selecting),h.add(t,s.selected),e.selecting=!1,e.selected=!0,e.startselected=!0,this.emit("selectable.select",e),e}return!1},s.prototype.unselect=function(e){if(c(e))return a(e,function(e){this.unselect(e)},this),this.getSelectedItems();if(e=this.getItem(e)){var t=e.element,s=this.config.classes;return e.selecting=!1,e.selected=!1,e.unselecting=!1,e.startselected=!1,h.remove(t,s.unselecting),h.remove(t,s.selecting),h.remove(t,s.selected),this.emit("selectable.unselect",e),e}return!1},s.prototype.recalculate=function(){a(this.nodes,function(e,t){this.items[t].rect=u(e)},this),this.emit("selectable.recalculate")},s.prototype.selectAll=function(){a(this.items,function(e){this.select(e)},this)},s.prototype.clear=function(){for(var e=this.items.length-1;e>=0;e--)this.unselect(this.items[e])},s.prototype.getItem=function(e){var t=!1;return isNaN(e)?e instanceof Element?t=this.items[this.nodes.indexOf(e)]:o(e)&&this.items.indexOf(e)>=0&&(t=e):this.items.indexOf(this.items[e])>=0&&(t=this.items[e]),t},s.prototype.getItems=function(){return this.items},s.prototype.getNodes=function(){return this.nodes},s.prototype.getSelectedItems=function(){return this.getItems().filter(function(e){return e.selected})},s.prototype.getSelectedNodes=function(){return this.getSelectedItems().map(function(e){return e.element})},s.prototype.enable=function(){if(!this.enabled){this.enabled=!0;var t={mousedown:this.mousedown.bind(this),mousemove:this.mousemove.bind(this),mouseup:this.mouseup.bind(this),recalculate:d(this.recalculate,50).bind(this)};e(this.container,"mousedown",t.mousedown),e(document,"mousemove",t.mousemove),e(document,"mouseup",t.mouseup),e(window,"resize",t.recalculate),e(window,"scroll",t.recalculate),this.events=t,h.add(this.container,this.config.classes.container),this.emit("selectable.enable")}return this.enabled},s.prototype.disable=function(){if(this.enabled){var e=this.events;this.enabled=!1,t(this.container,"mousedown",e.mousedown),t(document,"mousemove",e.mousemove),t(document,"mouseup",e.mouseup),t(window,"resize",e.recalculate),t(window,"scroll",e.recalculate),h.remove(this.container,this.config.classes.container),this.emit("selectable.disable")}return this.enabled},s.prototype.destroy=function(){var e=this.config.classes;a(this.items,function(t){var s=t.element;h.remove(s,e.selectable),h.remove(s,e.unselecting),h.remove(s,e.selecting),h.remove(s,e.selected)}),this.disable(),this.emit("selectable.destroy")},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=l(i,e),p.mixin(this),this.init()}var i={appendTo:document.body,autoRefresh:!0,filter:".ui-selectable",tolerance:"touch",lasso:{border:"1px dotted #3498db",backgroundColor:"rgba(52, 152, 219, 0.2)"},classes:{container:"ui-container",selectable:"ui-selectable",selecting:"ui-selecting",unselecting:"ui-unselecting",selected:"ui-selected"}},n=function(e,t){return e&&e!==document.body&&(t(e)?e:n(e.parentNode,t))},o=function(e){return"[object Object]"===Object.prototype.toString.call(e)},c=function(e){return Array.isArray(e)||e instanceof NodeList||e instanceof HTMLCollection},l=function(e,t){for(var s in t)if(t.hasOwnProperty(s)){var i=t[s];i&&o(i)?(e[s]=e[s]||{},l(e[s],i)):e[s]=i}return e},a=function(e,t,s){var i;if(o(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)},r=function(e,t,s){var i=e&&e.style,n=o(t);if(i){if(void 0===s&&!n)return s=window.getComputedStyle(e,""),void 0===t?s:s[t];n?a(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"))}},u=function(e){var t=window,s=e.getBoundingClientRect(),i=document.documentElement||document.body.parentNode||document.body,n=void 0!==t.pageXOffset?t.pageXOffset:i.scrollLeft,o=void 0!==t.pageYOffset?t.pageYOffset:i.scrollTop;return{x1:s.left+n,x2:s.left+s.width+n,y1:s.top+o,y2:s.top+s.height+o,height:s.height,width:s.width}},d=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)}},h={add:function(e,t){e.classList?e.classList.add(t):h.contains(e,t)||(e.className=e.className.trim()+" "+t)},remove:function(e,t){e.classList?e.classList.remove(t):h.contains(e,t)&&(e.className=e.className.replace(new RegExp("(^|\\s)"+t.split(" ").join("|")+"(\\s|$)","gi")," "))},contains:function(e,t){if(e)return e.classList?e.classList.contains(t):!!e.className&&!!e.className.match(new RegExp("(\\s|^)"+t+"(\\s|$)"))}},f=function(e){return!!e.ctrlKey||!!e.metaKey},m=function(e){return!!e.shiftKey},p=function(){};return p.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))}},p.mixin=function(e){for(var t=["on","off","emit"],s=t.length;s--;)"function"==typeof e?e.prototype[t[s]]=p.prototype[t[s]]:e[t[s]]=p.prototype[t[s]];return e},s.prototype.init=function(){var e=this,t=this.config;this.lasso=document.createElement("div"),this.lasso.className="ui-lasso",r(this.lasso,l({position:"fixed",opacity:0},t.lasso)),"string"==typeof t.appendTo?this.container=document.querySelector(t.appendTo):t.appendTo.nodeName&&(this.container=t.appendTo),this.update(),this.enable(),setTimeout(function(){e.emit("selectable.init")},10)},s.prototype.update=function(){var e=this,t=this.config;t.filter instanceof NodeList||t.filter instanceof HTMLCollection?this.nodes=t.filter:"string"==typeof t.filter&&(this.nodes=[].slice.call(this.container.querySelectorAll(t.filter))),this.items=[],a(this.nodes,function(s,i){h.add(s,t.classes.selectable),e.items[i]={index:i,element:s,rect:u(s),startselected:!1,selected:h.contains(s,t.classes.selected),selecting:h.contains(s,t.classes.selecting),unselecting:h.contains(s,t.classes.unselecting)}}),e.emit("selectable.update")},s.prototype.mousedown=function(e){e.preventDefault();var t,s=this.config,i=n(e.target,function(e){return h.contains(e,s.classes.selectable)});if(this.container.appendChild(this.lasso),this.origin={x:e.pageX,y:e.pageY},!s.disabled){if(i&&h.add(i,s.classes.selecting),s.autoRefresh&&this.update(),m(e))for(var o=!1,c=this.items.length-1;c>=0&&(this.items[c].element===i&&(o=!0),!o||!this.items[c].selected);c--)o&&(this.items[c].selecting=!0);a(this.items,function(n){var o=n.element;n.selected&&o!==i&&(n.startselected=!0,f(e)||m(e)||(h.remove(o,s.classes.selected),n.selected=!1,h.add(o,s.classes.unselecting),n.unselecting=!0)),o===i&&(t=n)}),this.dragging=!0,i&&this.emit("selectable.mousedown",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),r(this.lasso,{opacity:1,left:i.x1,width:i.x2-i.x1,top:i.y1,height:i.y2-i.y1}),a(this.items,function(s){var n=s.element,o=!1;"touch"==t.tolerance?o=!(s.rect.x1>i.x2||s.rect.x2<i.x1||s.rect.y1>i.y2||s.rect.y2<i.y1):"fit"==t.tolerance&&(o=s.rect.x1>i.x1&&s.rect.x2<i.x2&&s.rect.y1>i.y1&&s.rect.y2<i.y2),o?(s.selected&&(h.remove(n,t.classes.selected),s.selected=!1),s.unselecting&&(h.remove(n,t.classes.unselecting),s.unselecting=!1),s.selecting||(h.add(n,t.classes.selecting),s.selecting=!0)):(s.selecting&&(f(e)&&s.startselected?(h.remove(n,t.classes.selecting),s.selecting=!1,h.add(n,t.classes.selected),s.selected=!0):(h.remove(n,t.classes.selecting),s.selecting=!1,s.startselected&&(h.add(n,t.classes.unselecting),s.unselecting=!0))),n.selected&&(f(e)||s.startselected||(h.remove(n,t.classes.selected),s.selected=!1,h.add(n,t.classes.unselecting),s.unselecting=!0)))}),this.emit("selectable.mousemove",i)}}},s.prototype.mouseup=function(e){if(this.dragging&&(this.dragging=!1),this.container.contains(e.target)){var t=this;r(this.lasso,{opacity:0,left:0,width:0,top:0,height:0});var s=[];a(this.items,function(e){e.element;e.unselecting&&t.unselect(e),e.selecting&&(s.push(e),t.select(e))}),this.container.removeChild(this.lasso),this.emit("selectable.mouseup",s)}},s.prototype.select=function(e){if(c(e))return a(e,function(e){this.select(e)},this),this.getSelectedItems();if(e=this.getItem(e)){var t=e.element,s=this.config.classes;return h.remove(t,s.selecting),h.add(t,s.selected),e.selecting=!1,e.selected=!0,e.startselected=!0,this.emit("selectable.select",e),e}return!1},s.prototype.unselect=function(e){if(c(e))return a(e,function(e){this.unselect(e)},this),this.getSelectedItems();if(e=this.getItem(e)){var t=e.element,s=this.config.classes;return e.selecting=!1,e.selected=!1,e.unselecting=!1,e.startselected=!1,h.remove(t,s.unselecting),h.remove(t,s.selecting),h.remove(t,s.selected),this.emit("selectable.unselect",e),e}return!1},s.prototype.add=function(e){var t=this.config;c(e)?a(e,function(e){this.add(e)},this):this.nodes.indexOf(e)<0&&(h.add(e,t.classes.selectable),this.items.push({index:this.items.length,element:e,rect:u(e),startselected:!1,selected:h.contains(e,t.classes.selected),selecting:h.contains(e,t.classes.selecting),unselecting:h.contains(e,t.classes.unselecting)})),this.update()},s.prototype.remove=function(e){if(e=this.getItem(e))if(c(e))for(var t=e.length-1;t>=0;t--)this.remove(e[t]);else{var s=e.element,i=this.config.classes;h.remove(s,i.selectable),h.remove(s,i.unselecting),h.remove(s,i.selecting),h.remove(s,i.selected),this.items.splice(this.items.indexOf(e),1)}},s.prototype.recalculate=function(){a(this.nodes,function(e,t){this.items[t].rect=u(e)},this),this.emit("selectable.recalculate")},s.prototype.selectAll=function(){a(this.items,function(e){this.select(e)},this)},s.prototype.clear=function(){for(var e=this.items.length-1;e>=0;e--)this.unselect(this.items[e])},s.prototype.getItem=function(e){var t=!1;return c(e)?(t=[],a(e,function(e){t.push(this.getItem(e))},this)):isNaN(e)?e instanceof Element?t=this.items[this.nodes.indexOf(e)]:o(e)&&this.items.indexOf(e)>=0&&(t=e):this.items.indexOf(this.items[e])>=0&&(t=this.items[e]),t},s.prototype.getItems=function(){return this.items},s.prototype.getNodes=function(){return this.nodes},s.prototype.getSelectedItems=function(){return this.getItems().filter(function(e){return e.selected})},s.prototype.getSelectedNodes=function(){return this.getSelectedItems().map(function(e){return e.element})},s.prototype.enable=function(){if(!this.enabled){this.enabled=!0;var t={mousedown:this.mousedown.bind(this),mousemove:this.mousemove.bind(this),mouseup:this.mouseup.bind(this),recalculate:d(this.recalculate,50).bind(this)};e(this.container,"mousedown",t.mousedown),e(document,"mousemove",t.mousemove),e(document,"mouseup",t.mouseup),e(window,"resize",t.recalculate),e(window,"scroll",t.recalculate),this.events=t,h.add(this.container,this.config.classes.container),this.emit("selectable.enable")}return this.enabled},s.prototype.disable=function(){if(this.enabled){var e=this.events;this.enabled=!1,t(this.container,"mousedown",e.mousedown),t(document,"mousemove",e.mousemove),t(document,"mouseup",e.mouseup),t(window,"resize",e.recalculate),t(window,"scroll",e.recalculate),h.remove(this.container,this.config.classes.container),this.emit("selectable.disable")}return this.enabled},s.prototype.destroy=function(){var e=this.config.classes;a(this.items,function(t){var s=t.element;h.remove(s,e.selectable),h.remove(s,e.unselecting),h.remove(s,e.selecting),h.remove(s,e.selected)}),this.disable(),this.emit("selectable.destroy")},s});
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc