Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
mobius1-selectable
Advanced tools
Inspired by the jQuery UI Selectable plugin. Functionality and options are identical to the jQuery UI version with some additions and performance enhancements.
Selectable mimics the Windows file / directory behaviour, i.e. click and / or drag to select items, hold CTRL to select multiple or hold SHIFT to select consecutive groups of items.
Works in most modern browsers including IE9+.
bower install mobius1-selectable --save
npm install mobius1-selectable --save
Grab the file from one of the CDNs and include it 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:
const selectable = new Selectable(options);
By default the instance will look for any nodes with the ".ui-selectable"
class. You can redefine this with the filter
option.
Option | Type | Default | Effect |
---|---|---|---|
filter | string or array | ".ui-selectable" | The elements that can be selected. You can pass either a CSS3 selector string or a collection of nodes. |
appendTo | string or object | document.body | The container element to append the lasso to. |
tolerance | string | touch | How far the lasso overlaps an element before it's highlighted. "fit" (lasso overlaps the item entirely) or "touch" (lasso overlaps the item by any amount). |
autoRefresh | boolean | true | Recalculate the coords of the items. Set to false if you know the selectable items won't move or change size. |
lasso | object | Style the lasso. Must be an object of valid CSS declarations. Demo |
Destroy the instance. This will return the DOM to it's initial state before initialsing.
Initialise the instance after destroying.
Disable the instance. Removes all event listeners to prevent further selection / deselection.
Enable the instance.
Updates the instance.
Can be used if new items are added or old ones removed. All item coords are updated as well.
Recalculates the coords for all valid items.
If the dimensions of the item / items change then call this method otherwise the lasso will not select items correctly.
Select an item.
Deselect an item.
Select all valid items.
Deselects all valid items.
Returns an Array
of selected items.
Returns an Array
of selected HTMLElement
nodes.
// Intitialise Selectable
const selectable = new Selectable(options);
// Listen for the 'selectable.XXXX' event
selectable.on('selectable.XXXX', function() {
// Do something when 'selectable.XXXX' fires
});
selectable.down
fires on mousedown (within container)selectable.drag
fires when dragging the lassoselectable.up
fires on mouse up (within container)selectable.selected
fires on each element selected/**
* @param item - the first item selected
* @return {object}
*/
selectable.on('selectable.down', function(item) {
// Do something when selectable.down fires
});
/**
* @param coords - lasso coords (x1, x2, y1, y2)
* @return {object}
*/
selectable.on('selectable.drag', function(coords) {
// Do something when selectable.drag fires
});
/**
* @param selectedItems - returns an array of selected items (objects)
* @return {array}
*/
selectable.on('selectable.up', function(selectedItems) {
// Do something when selectable.up fires
});
/**
* @param item - the selected item (fires for each item that is selected)
* @return {object}
*/
selectable.on('selectable.selected', function(item) {
// Do something when selectable.selected fires
});
Note that items returned by these events are objects of the following format:
{
element: HTMLElement, // the element
index: Number, // the position of the item in the list
rect: DOMRect Object, // the element's bounding rects
startselected: Boolean,
selected: Boolean, // is the item currently selected
selecting: Boolean, // is the item currently being selected
unselecting: Boolean // is the item currently being deselected
}
Copyright © 2017 Karl Saunders | BSD & MIT license
FAQs
UI Selectable plugin without the bloat of jQuery and jQuery UI.
The npm package mobius1-selectable receives a total of 3 weekly downloads. As such, mobius1-selectable popularity was classified as not popular.
We found that mobius1-selectable demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.