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.0.6 to 0.0.7

2

bower.json
{
"name": "mobius1-selectable",
"version": "0.0.6",
"version": "0.0.7",
"ignore": [

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

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

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

@@ -8,2 +8,4 @@ # Selectable [![npm version](https://badge.fury.io/js/mobius1-selectable.svg)](https://badge.fury.io/js/mobius1-selectable) [![license](https://img.shields.io/github/license/mashape/apistatus.svg)](https://github.com/Mobius1/Selectable/blob/master/LICENSE)

---
## Install

@@ -21,10 +23,20 @@

## Quick Start
---
Include the JS file:
### Browser
```html
<script type="text/javascript" src="path/to/selectable.min.js"></script>
Grab the files from one of the CDNs and include them in your page:
```
https://unpkg.com/mobius1-selectable@latest/selectable.min.js
//or
https://cdn.jsdelivr.net/npm/mobius1-selectable@latest/selectable.min.js
```
You can replace `latest` with the required release number if needed.
---
Initialise the plugin

@@ -31,0 +43,0 @@

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

*
* Version: 0.0.6
* Version: 0.0.7
*

@@ -18,7 +18,7 @@ */

} else if (typeof define === "function" && define.amd) {
define([], factory(plugin));
define([], factory);
} else {
root[plugin] = factory(plugin);
}
})(typeof global !== 'undefined' ? global : this.window || this.global, function(plugin) {
})(typeof global !== 'undefined' ? global : this.window || this.global, function() {
"use strict";

@@ -202,3 +202,3 @@

this.options = extend(defaultConfig, options);
this.config = extend(defaultConfig, options);

@@ -221,3 +221,3 @@ /* Enable emitter */

each(this.options.lasso, function(val, prop) {
each(this.config.lasso, function(val, prop) {
lasso.style[prop] = val;

@@ -228,6 +228,6 @@ });

if (typeof this.options.appendTo === 'string' || this.options.appendTo instanceof String) {
this.container = document.querySelector(this.options.appendTo);
} else if (this.options.appendTo.nodeName) {
this.container = this.options.appendTo;
if (typeof this.config.appendTo === 'string' || this.config.appendTo instanceof String) {
this.container = document.querySelector(this.config.appendTo);
} else if (this.config.appendTo.nodeName) {
this.container = this.config.appendTo;
} else {

@@ -258,3 +258,3 @@ this.container = document.body;

var that = this;
this.nodes = this.container.querySelectorAll(this.options.selector);
this.nodes = this.container.querySelectorAll(this.config.filter);
this.items = [];

@@ -281,5 +281,5 @@

preventDefault(e);
var o = this.options,
var o = this.config,
originalEl, tgt = e.target;
var validEl = tgt.classList.contains(o.selector.replace('.', ''));
var validEl = tgt.classList.contains(o.filter.replace('.', ''));

@@ -357,3 +357,3 @@ this.container.appendChild(this.lasso);

var o = this.options;
var o = this.config;
if (o.disabled) {

@@ -360,0 +360,0 @@ return;

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

*
* Version: 0.0.6
* Version: 0.0.7
*
*/
!function(e,t){var s="Selectable";"object"==typeof exports?module.exports=t(s):"function"==typeof define&&define.amd?define([],t(s)):e[s]=t(s)}("undefined"!=typeof global?global:this.window||this.global,function(e){"use strict";function t(e,t,s,i){e.addEventListener(t,s,!1)}function s(e,t,s){e.removeEventListener(t,s)}function i(e){this.options=c(n,e),p.mixin(this),this.init()}var n={appendTo:"body",autoRefresh:!0,filter:"*",tolerance:"touch",lasso:{border:"1px solid #3498db",backgroundColor:"rgba(52, 152, 219, 0.2)"}},o=function(e){return"[object Object]"===Object.prototype.toString.call(e)},c=function(e,t){for(var s in t)if(t.hasOwnProperty(s)){var i=t[s];i&&o(i)?(e[s]=e[s]||{},c(e[s],i)):e[s]=i}return e},l=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?l(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"))}},a=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)}},u=function(e){return e=e||window.event,e.preventDefault?e.preventDefault():e.returnValue=!1},d=function(e){return!!e.ctrlKey||!!e.metaKey},h=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},i.prototype.init=function(){var e=document.createElement("div");e.className="ui-lasso",e.style.position="fixed",l(this.options.lasso,function(t,s){e.style[s]=t}),this.lasso=e,"string"==typeof this.options.appendTo||this.options.appendTo instanceof String?this.container=document.querySelector(this.options.appendTo):this.options.appendTo.nodeName?this.container=this.options.appendTo:this.container=document.body,this.refresh(),this.events={mousedown:this.mousedown.bind(this),mousemove:this.mousemove.bind(this),mouseup:this.mouseup.bind(this),update:a(this.update,50).bind(this)},t(this.container,"mousedown",this.events.mousedown),t(document,"mousemove",this.events.mousemove),t(document,"mouseup",this.events.mouseup),t(window,"resize",this.events.update),t(window,"scroll",this.events.update)},i.prototype.refresh=function(){var e=this;this.nodes=this.container.querySelectorAll(this.options.selector),this.items=[],l(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){u(e)}})},i.prototype.mousedown=function(e){u(e);var t,s=this.options,i=e.target,n=i.classList.contains(s.selector.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.refresh(),h(e)){for(var o=!1,c=0;c<this.items.length;c++)if(this.items[c].element===e.target){o=this.items[c];break}for(var r=!1,c=o.index;c>=0&&(this.items[c].selected&&(r=!0),!r||this.items[c].selected);c--)this.items[c].selecting=!0}l(this.items,function(s){var n=s.element;s.selected&&(s.startselected=!0,d(e)||h(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)}},i.prototype.mousemove=function(e){if(this.dragging){var t=this.options;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,{left:i.x1,width:i.x2-i.x1,top:i.y1,height:i.y2-i.y1}),l(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&&(d(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&&(d(e)||s.startselected||(n.classList.remove("ui-selected"),s.selected=!1,n.classList.add("ui-unselecting"),s.unselecting=!0)))}),this.emit("selectable.drag",i)}}},i.prototype.mouseup=function(e){if(this.dragging&&(this.dragging=!1),this.container.contains(e.target)){var t=this;this.selectedItems=[],r(this.lasso,{left:0,width:0,top:0,height:0}),l(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),e.selected&&(t.selectedItems.push(e),t.emit("selectable.selected",e))}),this.container.removeChild(this.lasso),this.emit("selectable.up",this.selectedItems)}},i.prototype.selectItem=function(e){e.element.classList.remove("ui-selecting"),e.element.classList.add("ui-selected"),e.selecting=!1,e.selected=e.startselected=!0},i.prototype.update=function(){l(this.nodes,function(e,t){this.items[t].rect=e.getBoundingClientRect()},this)},i.prototype.destroy=function(){l(this.items,function(e){var t=e.element;t.classList.remove("ui-unselecting"),t.classList.remove("ui-selecting"),t.classList.remove("ui-selected")}),s(this.container,"mousedown",this.events.mousedown),s(document,"mousemove",this.events.mousemove),s(document,"mouseup",this.events.mouseup),s(window,"resize",this.events.update),s(window,"scroll",this.events.update)},i});
!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:"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 t=document.createElement("div");t.className="ui-lasso",t.style.position="fixed",c(this.config.lasso,function(e,s){t.style[s]=e}),this.lasso=t,"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.container=document.body,this.refresh(),this.events={mousedown:this.mousedown.bind(this),mousemove:this.mousemove.bind(this),mouseup:this.mouseup.bind(this),update:r(this.update,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.update),e(window,"scroll",this.events.update)},s.prototype.refresh=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.refresh(),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),e.selected&&(t.selectedItems.push(e),t.emit("selectable.selected",e))}),this.container.removeChild(this.lasso),this.emit("selectable.up",this.selectedItems)}},s.prototype.selectItem=function(e){e.element.classList.remove("ui-selecting"),e.element.classList.add("ui-selected"),e.selecting=!1,e.selected=e.startselected=!0},s.prototype.update=function(){c(this.nodes,function(e,t){this.items[t].rect=e.getBoundingClientRect()},this)},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")}),t(this.container,"mousedown",this.events.mousedown),t(document,"mousemove",this.events.mousemove),t(document,"mouseup",this.events.mouseup),t(window,"resize",this.events.update),t(window,"scroll",this.events.update)},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