jstree-actions
Advanced tools
Comparing version 0.1.0 to 0.1.1
@@ -32,3 +32,3 @@ (function ($, undefined) { | ||
var self = this; | ||
node_id = typeof node_id === Object ? node_id : [node_id]; | ||
node_id = typeof node_id === 'object' ? node_id : [node_id]; | ||
@@ -58,3 +58,3 @@ for (var i = 0; i < node_id.length; i++) { | ||
var self = this; | ||
var node_ids = typeof node_id === Object ? node_id : | ||
var node_ids = typeof node_id === 'object' ? node_id : | ||
node_id === "all" ? Object.keys(this._actions).concat('all') : | ||
@@ -145,3 +145,3 @@ [node_id]; | ||
var self = this; | ||
var node_id = obj; | ||
var node_id = typeof obj === "object" ? obj.id : obj; | ||
var el = parent.redraw_node.call(this, obj, deep, callback, force_draw); | ||
@@ -148,0 +148,0 @@ if (el) { |
@@ -1,1 +0,1 @@ | ||
!function(t,n){"use strict";t.jstree.defaults.actions=t.noop,t.jstree.plugins.actions=function(t,n){this._actions={},this.add_action=function(t,n){var i=this;t=typeof t===Object?t:[t];for(var a=0;a<t.length;a++){var e=t[a],o=i._actions[e]=i._actions[e]||[];i._has_action(e,n.id)||o.push(n)}this.redraw(!0)},this.remove_action=function(t,n){for(var i=this,a=typeof t===Object?t:"all"===t?Object.keys(this._actions).concat("all"):[t],e=0;e<a.length;e++){t=a[e];for(var o=i._actions[t]||[],r=[],c=0;c<o.length;c++){var s=o[c];s.id!==n&&"all"!==n&&r.push(s)}i._actions[t]=r}this.redraw(!0)},this._create_action=function(t,n){var i=this,a=this._get_action(t,n);if(null===a)return null;var e=document.createElement("i");return e.className=a["class"],e.textContent=a.text,e.onclick=function(){var o=i.get_node(e);a.callback(t,o,n,e)},{action:a,action_el:e}},this._get_action=function(t,n){for(var i=this._actions[t]||[],a=null,e=0;e<i.length;e++){var o=i[e];o.id===n&&(a=o)}return a},this._set_action=function(t,n,i){if(null!==i){var a=n.querySelector(i.action.selector);i.action.after?a.parentNode.insertBefore(i.action_el,a.nextSibling):n.insertBefore(i.action_el,a)}},this._has_action=function(t,n){var i=!1,a=this._actions;if(a.hasOwnProperty(t))for(var e=0;e<a[t].length;e++)a[t][e].id===n&&(i=!0);if(this._actions.hasOwnProperty("all"))for(e=0;e<a.all.length;e++)a.all[e].id===n&&(i=!0);return i},this.redraw_node=function(t,i,a,e){var o=this,r=t,c=n.redraw_node.call(this,t,i,a,e);if(c){for(var s=this._actions[r]||[],l=0;l<s.length;l++){var _=o._create_action(r,s[l].id);o._set_action(r,c,_)}for(s=this._actions.all||[],l=0;l<s.length;l++)_=o._create_action("all",s[l].id),o._set_action(r,c,_)}return c}}}(jQuery); | ||
!function(a,b){"use strict";a.jstree.defaults.actions=a.noop,a.jstree.plugins.actions=function(a,b){this._actions={},this.add_action=function(a,b){var c=this;a="object"==typeof a?a:[a];for(var d=0;d<a.length;d++){var e=a[d],f=c._actions[e]=c._actions[e]||[];c._has_action(e,b.id)||f.push(b)}this.redraw(!0)},this.remove_action=function(a,b){for(var c=this,d="object"==typeof a?a:"all"===a?Object.keys(this._actions).concat("all"):[a],e=0;e<d.length;e++){a=d[e];for(var f=c._actions[a]||[],g=[],h=0;h<f.length;h++){var i=f[h];i.id!==b&&"all"!==b&&g.push(i)}c._actions[a]=g}this.redraw(!0)},this._create_action=function(a,b){var c=this,d=this._get_action(a,b);if(null===d)return null;var e=document.createElement("i");return e.className=d.class,e.textContent=d.text,e.onclick=function(){var f=c.get_node(e);d.callback(a,f,b,e)},{action:d,action_el:e}},this._get_action=function(a,b){for(var c=this._actions[a]||[],d=null,e=0;e<c.length;e++){var f=c[e];f.id===b&&(d=f)}return d},this._set_action=function(a,b,c){if(null!==c){var d=b.querySelector(c.action.selector);c.action.after?d.parentNode.insertBefore(c.action_el,d.nextSibling):b.insertBefore(c.action_el,d)}},this._has_action=function(a,b){var c=!1,d=this._actions;if(d.hasOwnProperty(a))for(var e=0;e<d[a].length;e++)d[a][e].id===b&&(c=!0);if(this._actions.hasOwnProperty("all"))for(e=0;e<d.all.length;e++)d.all[e].id===b&&(c=!0);return c},this.redraw_node=function(a,c,d,e){var f=this,g="object"==typeof a?a.id:a,h=b.redraw_node.call(this,a,c,d,e);if(h){for(var i=this._actions[g]||[],j=0;j<i.length;j++){var k=f._create_action(g,i[j].id);f._set_action(g,h,k)}for(i=this._actions.all||[],j=0;j<i.length;j++)k=f._create_action("all",i[j].id),f._set_action(g,h,k)}return h}}}(jQuery); |
{ | ||
"name": "jstree-actions", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"description": "jstree plugin that allows adding actions on each node", | ||
@@ -5,0 +5,0 @@ "main": "jstree-actions.js", |
92785