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

jstree-actions

Package Overview
Dependencies
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jstree-actions - npm Package Compare versions

Comparing version 0.1.3 to 0.1.4

24

jstree-actions.js

@@ -43,6 +43,7 @@ (function (factory) {

var self = this;
node_id = typeof node_id === 'object' ? node_id : [node_id];
var node_ids = typeof node_id === 'object' ? node_id : [node_id];
for (var i = 0; i < node_id.length; i++) {
var _node_id = node_id[i];
var should_redraw_all = node_ids.indexOf("all") > -1;
for (var i = 0; i < node_ids.length; i++) {
var _node_id = node_ids[i];
var actions = self._actions[_node_id] = self._actions[_node_id] || [];

@@ -52,5 +53,7 @@

actions.push(action);
this.redraw_node(_node_id);
if (!should_redraw_all) this.redraw_node(_node_id);
}
}
if (should_redraw_all) this.redraw(true);
};

@@ -71,5 +74,5 @@

var node_ids = typeof node_id === 'object' ? node_id :
node_id === "all" ? Object.keys(this._actions).concat('all') :
[node_id];
node_id === "all" ? Object.keys(this._actions) : [node_id];
var should_redraw_all = node_ids.indexOf("all") > -1;
for (var i = 0; i < node_ids.length; i++) {

@@ -86,9 +89,16 @@ node_id = node_ids[i];

}
var ids = actions.map(function(x) { return x.id; });
var new_ids = new_actions.map(function(x) { return x.id; });
if (ids.length != new_ids.length || ids.filter(function(n) { return new_ids.indexOf(n) === -1; }).length) {
self._actions[node_id] = new_actions;
this.redraw_node(node_id);
if (!should_redraw_all) this.redraw_node(node_id);
}
}
if (should_redraw_all) {
this.redraw(true);
}
};

@@ -95,0 +105,0 @@

@@ -1,1 +0,1 @@

!function(t){"use strict";"function"==typeof define&&define.amd?define(["jquery"],t):"undefined"!=typeof module&&module.exports?module.exports=t(require("jquery")):t(jQuery)}(function(t){"use strict";t.jstree.defaults.actions=t.noop,t.jstree.plugins.actions=function(t,n){this._actions={},this.add_action=function(t,n){var e=this;t="object"==typeof t?t:[t];for(var i=0;i<t.length;i++){var o=t[i],a=e._actions[o]=e._actions[o]||[];e._has_action(o,n.id)||(a.push(n),this.redraw_node(o))}},this.remove_action=function(t,n){for(var e=this,i="object"==typeof t?t:"all"===t?Object.keys(this._actions).concat("all"):[t],o=0;o<i.length;o++){t=i[o];for(var a=e._actions[t]||[],r=[],c=0;c<a.length;c++){var s=a[c];s.id!==n&&"all"!==n&&r.push(s)}var l=a.map(function(t){return t.id}),f=r.map(function(t){return t.id});(l.length!=f.length||l.filter(function(t){return-1===f.indexOf(t)}).length)&&(e._actions[t]=r,this.redraw_node(t))}},this._create_action=function(t,n){var e=this,i=this._get_action(t,n);if(null===i)return null;var o=document.createElement("i");return o.className=i["class"],o.textContent=i.text,o.onclick=function(){var a=e.get_node(o);i.callback(t,a,n,o)},{action:i,action_el:o}},this._get_action=function(t,n){for(var e=this._actions[t]||[],i=null,o=0;o<e.length;o++){var a=e[o];a.id===n&&(i=a)}return i},this._set_action=function(t,n,e){if(null!==e){var i=n.querySelector(e.action.selector);e.action.after?i.parentNode.insertBefore(e.action_el,i.nextSibling):n.insertBefore(e.action_el,i)}},this._has_action=function(t,n){var e=!1,i=this._actions;if(i.hasOwnProperty(t))for(var o=0;o<i[t].length;o++)i[t][o].id===n&&(e=!0);if(this._actions.hasOwnProperty("all"))for(o=0;o<i.all.length;o++)i.all[o].id===n&&(e=!0);return e},this.redraw_node=function(t,e,i,o){var a=this,r="object"==typeof t?t.id:t,c=n.redraw_node.call(this,t,e,i,o);if(c){for(var s=this._actions[r]||[],l=0;l<s.length;l++){var f=a._create_action(r,s[l].id);a._set_action(r,c,f)}for(s=this._actions.all||[],l=0;l<s.length;l++)f=a._create_action("all",s[l].id),a._set_action(r,c,f)}return c}}});
!function(t){"use strict";"function"==typeof define&&define.amd?define(["jquery"],t):"undefined"!=typeof module&&module.exports?module.exports=t(require("jquery")):t(jQuery)}(function(t){"use strict";t.jstree.defaults.actions=t.noop,t.jstree.plugins.actions=function(t,e){this._actions={},this.add_action=function(t,e){for(var n=this,i="object"==typeof t?t:[t],o=i.indexOf("all")>-1,a=0;a<i.length;a++){var r=i[a],c=n._actions[r]=n._actions[r]||[];n._has_action(r,e.id)||(c.push(e),o||this.redraw_node(r))}o&&this.redraw(!0)},this.remove_action=function(t,e){for(var n=this,i="object"==typeof t?t:"all"===t?Object.keys(this._actions):[t],o=i.indexOf("all")>-1,a=0;a<i.length;a++){t=i[a];for(var r=n._actions[t]||[],c=[],s=0;s<r.length;s++){var l=r[s];l.id!==e&&"all"!==e&&c.push(l)}var f=r.map(function(t){return t.id}),u=c.map(function(t){return t.id});(f.length!=u.length||f.filter(function(t){return-1===u.indexOf(t)}).length)&&(n._actions[t]=c,o||this.redraw_node(t))}o&&this.redraw(!0)},this._create_action=function(t,e){var n=this,i=this._get_action(t,e);if(null===i)return null;var o=document.createElement("i");return o.className=i["class"],o.textContent=i.text,o.onclick=function(){var a=n.get_node(o);i.callback(t,a,e,o)},{action:i,action_el:o}},this._get_action=function(t,e){for(var n=this._actions[t]||[],i=null,o=0;o<n.length;o++){var a=n[o];a.id===e&&(i=a)}return i},this._set_action=function(t,e,n){if(null!==n){var i=e.querySelector(n.action.selector);n.action.after?i.parentNode.insertBefore(n.action_el,i.nextSibling):e.insertBefore(n.action_el,i)}},this._has_action=function(t,e){var n=!1,i=this._actions;if(i.hasOwnProperty(t))for(var o=0;o<i[t].length;o++)i[t][o].id===e&&(n=!0);if(this._actions.hasOwnProperty("all"))for(o=0;o<i.all.length;o++)i.all[o].id===e&&(n=!0);return n},this.redraw_node=function(t,n,i,o){var a=this,r="object"==typeof t?t.id:t,c=e.redraw_node.call(this,t,n,i,o);if(c){for(var s=this._actions[r]||[],l=0;l<s.length;l++){var f=a._create_action(r,s[l].id);a._set_action(r,c,f)}for(s=this._actions.all||[],l=0;l<s.length;l++)f=a._create_action("all",s[l].id),a._set_action(r,c,f)}return c}}});
{
"name": "jstree-actions",
"version": "0.1.3",
"version": "0.1.4",
"description": "jstree plugin that allows adding actions on each node",

@@ -5,0 +5,0 @@ "main": "jstree-actions.js",

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