Comparing version 3.3.3 to 3.3.4
{ | ||
"name": "jstree", | ||
"version": "3.3.3", | ||
"version": "3.3.4", | ||
"main" : [ | ||
@@ -5,0 +5,0 @@ "./dist/jstree.js", |
@@ -5,3 +5,3 @@ { | ||
"description": "jsTree is jquery plugin, that provides interactive trees.", | ||
"version": "3.3.3", | ||
"version": "3.3.4", | ||
"license": "MIT", | ||
@@ -8,0 +8,0 @@ "keywords": [ |
@@ -5,3 +5,3 @@ { | ||
"description": "Tree view for jQuery", | ||
"version": "3.3.3", | ||
"version": "3.3.4", | ||
"homepage": "http://jstree.com", | ||
@@ -8,0 +8,0 @@ "keywords": [ |
@@ -5,3 +5,3 @@ { | ||
"description": "jQuery tree plugin", | ||
"version": "3.3.3", | ||
"version": "3.3.4", | ||
"homepage": "http://jstree.com", | ||
@@ -8,0 +8,0 @@ "main": "./dist/jstree.js", |
@@ -46,2 +46,3 @@ # jstree | ||
- [More plugins](#more-plugins) | ||
- [PHP demos moved to new repository](#php-demos-moved-to-new-repository) | ||
- [License & Contributing](#license--contributing) | ||
@@ -650,2 +651,5 @@ | ||
## PHP demos moved to new repository | ||
https://github.com/vakata/jstree-php-demos | ||
## License & Contributing | ||
@@ -652,0 +656,0 @@ |
@@ -70,3 +70,17 @@ /** | ||
*/ | ||
tie_selection : true | ||
tie_selection : true, | ||
/** | ||
* This setting controls if cascading down affects disabled checkboxes | ||
* @name $.jstree.defaults.checkbox.cascade_to_disabled | ||
* @plugin checkbox | ||
*/ | ||
cascade_to_disabled : true, | ||
/** | ||
* This setting controls if cascading down affects hidden checkboxes | ||
* @name $.jstree.defaults.checkbox.cascade_to_hidden | ||
* @plugin checkbox | ||
*/ | ||
cascade_to_hidden : true | ||
}; | ||
@@ -132,2 +146,3 @@ $.jstree.plugins.checkbox = function (options, parent) { | ||
} | ||
this._data[ t ? 'core' : 'checkbox' ].selected = this._data[ t ? 'core' : 'checkbox' ].selected.concat(dpc); | ||
@@ -181,6 +196,6 @@ } | ||
.on(this.settings.checkbox.tie_selection ? 'select_node.jstree' : 'check_node.jstree', $.proxy(function (e, data) { | ||
var obj = data.node, | ||
var self = this, | ||
obj = data.node, | ||
m = this._model.data, | ||
par = this.get_node(obj.parent), | ||
dom = this.get_node(obj, true), | ||
i, j, c, tmp, s = this.settings.checkbox.cascade, t = this.settings.checkbox.tie_selection, | ||
@@ -192,13 +207,15 @@ sel = {}, cur = this._data[ t ? 'core' : 'checkbox' ].selected; | ||
} | ||
// apply down | ||
if(s.indexOf('down') !== -1) { | ||
//this._data[ t ? 'core' : 'checkbox' ].selected = $.vakata.array_unique(this._data[ t ? 'core' : 'checkbox' ].selected.concat(obj.children_d)); | ||
for(i = 0, j = obj.children_d.length; i < j; i++) { | ||
sel[obj.children_d[i]] = true; | ||
tmp = m[obj.children_d[i]]; | ||
tmp.state[ t ? 'selected' : 'checked' ] = true; | ||
if(tmp && tmp.original && tmp.original.state && tmp.original.state.undetermined) { | ||
tmp.original.state.undetermined = false; | ||
} | ||
} | ||
var selectedIds = this._cascade_new_checked_state(obj.id, true); | ||
obj.children_d.concat(obj.id).forEach(function(id) { | ||
if (selectedIds.indexOf(id) > -1) { | ||
sel[id] = true; | ||
} | ||
else { | ||
delete sel[id]; | ||
} | ||
}); | ||
} | ||
@@ -236,7 +253,2 @@ | ||
this._data[ t ? 'core' : 'checkbox' ].selected = cur; | ||
// apply down (process .children separately?) | ||
if(s.indexOf('down') !== -1 && dom.length) { | ||
dom.find('.jstree-anchor').addClass(t ? 'jstree-clicked' : 'jstree-checked').parent().attr('aria-selected', true); | ||
} | ||
}, this)) | ||
@@ -255,23 +267,22 @@ .on(this.settings.checkbox.tie_selection ? 'deselect_all.jstree' : 'uncheck_all.jstree', $.proxy(function (e, data) { | ||
.on(this.settings.checkbox.tie_selection ? 'deselect_node.jstree' : 'uncheck_node.jstree', $.proxy(function (e, data) { | ||
var obj = data.node, | ||
var self = this, | ||
obj = data.node, | ||
dom = this.get_node(obj, true), | ||
i, j, tmp, s = this.settings.checkbox.cascade, t = this.settings.checkbox.tie_selection, | ||
cur = this._data[ t ? 'core' : 'checkbox' ].selected, sel = {}; | ||
if(obj && obj.original && obj.original.state && obj.original.state.undetermined) { | ||
obj.original.state.undetermined = false; | ||
} | ||
cur = this._data[ t ? 'core' : 'checkbox' ].selected, sel = {}, | ||
stillSelectedIds = [], | ||
allIds = obj.children_d.concat(obj.id); | ||
// apply down | ||
if(s.indexOf('down') !== -1) { | ||
for(i = 0, j = obj.children_d.length; i < j; i++) { | ||
tmp = this._model.data[obj.children_d[i]]; | ||
tmp.state[ t ? 'selected' : 'checked' ] = false; | ||
if(tmp && tmp.original && tmp.original.state && tmp.original.state.undetermined) { | ||
tmp.original.state.undetermined = false; | ||
} | ||
} | ||
var selectedIds = this._cascade_new_checked_state(obj.id, false); | ||
cur = cur.filter(function(id) { | ||
return allIds.indexOf(id) === -1 || selectedIds.indexOf(id) > -1; | ||
}); | ||
} | ||
// apply up | ||
if(s.indexOf('up') !== -1) { | ||
// only apply up if cascade up is enabled and if this node is not selected | ||
// (if all child nodes are disabled and cascade_to_disabled === false then this node will till be selected). | ||
if(s.indexOf('up') !== -1 && cur.indexOf(obj.id) === -1) { | ||
for(i = 0, j = obj.parents.length; i < j; i++) { | ||
@@ -288,25 +299,9 @@ tmp = this._model.data[obj.parents[i]]; | ||
} | ||
cur = cur.filter(function(id) { | ||
return obj.parents.indexOf(id) === -1; | ||
}); | ||
} | ||
sel = {}; | ||
for(i = 0, j = cur.length; i < j; i++) { | ||
// apply down + apply up | ||
if( | ||
(s.indexOf('down') === -1 || $.inArray(cur[i], obj.children_d) === -1) && | ||
(s.indexOf('up') === -1 || $.inArray(cur[i], obj.parents) === -1) | ||
) { | ||
sel[cur[i]] = true; | ||
} | ||
} | ||
cur = []; | ||
for (i in sel) { | ||
if (sel.hasOwnProperty(i)) { | ||
cur.push(i); | ||
} | ||
} | ||
this._data[ t ? 'core' : 'checkbox' ].selected = cur; | ||
// apply down (process .children separately?) | ||
if(s.indexOf('down') !== -1 && dom.length) { | ||
dom.find('.jstree-anchor').removeClass(t ? 'jstree-clicked' : 'jstree-checked').parent().attr('aria-selected', false); | ||
} | ||
}, this)); | ||
@@ -402,2 +397,3 @@ } | ||
}; | ||
/** | ||
@@ -429,2 +425,5 @@ * set the undetermined state where and if necessary. Used internally. | ||
var tmp = tt.get_node(this), tmp2; | ||
if(!tmp) { return; } | ||
if(!tmp.state.loaded) { | ||
@@ -632,2 +631,85 @@ if(tmp.original && tmp.original.state && tmp.original.state.undetermined && tmp.original.state.undetermined === true) { | ||
/** | ||
* Unchecks a node and all its descendants. This function does NOT affect hidden and disabled nodes (or their descendants). | ||
* However if these unaffected nodes are already selected their ids will be included in the returned array. | ||
* @param id | ||
* @param checkedState | ||
* @returns {Array} Array of all node id's (in this tree branch) that are checked. | ||
*/ | ||
this._cascade_new_checked_state = function(id, checkedState) { | ||
var self = this; | ||
var t = this.settings.checkbox.tie_selection; | ||
var node = this._model.data[id]; | ||
var selectedNodeIds = []; | ||
var selectedChildrenIds = []; | ||
if ( | ||
(this.settings.checkbox.cascade_to_disabled || !node.state.disabled) && | ||
(this.settings.checkbox.cascade_to_hidden || !node.state.hidden) | ||
) { | ||
//First try and check/uncheck the children | ||
if (node.children) { | ||
node.children.forEach(function(childId) { | ||
var selectedChildIds = self._cascade_new_checked_state(childId, checkedState); | ||
selectedNodeIds = selectedNodeIds.concat(selectedChildIds); | ||
if (selectedChildIds.indexOf(childId) > -1) { | ||
selectedChildrenIds.push(childId); | ||
} | ||
}); | ||
} | ||
var dom = self.get_node(node, true); | ||
//A node's state is undetermined if some but not all of it's children are checked/selected . | ||
var undetermined = selectedChildrenIds.length > 0 && selectedChildrenIds.length < node.children.length; | ||
if(node.original && node.original.state && node.original.state.undetermined) { | ||
node.original.state.undetermined = undetermined; | ||
} | ||
//If a node is undetermined then remove selected class | ||
if (undetermined) { | ||
node.state[ t ? 'selected' : 'checked' ] = false; | ||
dom.attr('aria-selected', false).children('.jstree-anchor').removeClass(t ? 'jstree-clicked' : 'jstree-checked'); | ||
} | ||
//Otherwise, if the checkedState === true (i.e. the node is being checked now) and all of the node's children are checked (if it has any children), | ||
//check the node and style it correctly. | ||
else if (checkedState && selectedChildrenIds.length === node.children.length) { | ||
node.state[ t ? 'selected' : 'checked' ] = checkedState; | ||
selectedNodeIds.push(node.id); | ||
dom.attr('aria-selected', true).children('.jstree-anchor').addClass(t ? 'jstree-clicked' : 'jstree-checked'); | ||
} | ||
else { | ||
node.state[ t ? 'selected' : 'checked' ] = false; | ||
dom.attr('aria-selected', false).children('.jstree-anchor').removeClass(t ? 'jstree-clicked' : 'jstree-checked'); | ||
} | ||
} | ||
else { | ||
var selectedChildIds = this.get_checked_descendants(id); | ||
if (node.state[ t ? 'selected' : 'checked' ]) { | ||
selectedChildIds.push(node.id); | ||
} | ||
selectedNodeIds = selectedNodeIds.concat(selectedChildIds); | ||
} | ||
return selectedNodeIds; | ||
}; | ||
/** | ||
* Gets ids of nodes selected in branch (of tree) specified by id (does not include the node specified by id) | ||
* @param id | ||
*/ | ||
this.get_checked_descendants = function(id) { | ||
var self = this; | ||
var t = self.settings.checkbox.tie_selection; | ||
var node = self._model.data[id]; | ||
return node.children_d.filter(function(_id) { | ||
return self._model.data[_id].state[ t ? 'selected' : 'checked' ]; | ||
}); | ||
}; | ||
/** | ||
* check a node (only if tie_selection in checkbox settings is false, otherwise select_node will be called internally) | ||
@@ -712,2 +794,3 @@ * @name check_node(obj) | ||
}; | ||
/** | ||
@@ -882,2 +965,2 @@ * checks all nodes in the tree (only if tie_selection in checkbox settings is false, otherwise select_all will be called internally) | ||
// $.jstree.defaults.plugins.push("checkbox"); | ||
})); | ||
})); |
@@ -71,3 +71,7 @@ /** | ||
inst.create_node(obj, {}, "last", function (new_node) { | ||
setTimeout(function () { inst.edit(new_node); },0); | ||
try { | ||
inst.edit(new_node); | ||
} catch (ex) { | ||
setTimeout(function () { inst.edit(new_node); },0); | ||
} | ||
}); | ||
@@ -173,2 +177,5 @@ } | ||
this.element | ||
.on("init.jstree loading.jstree ready.jstree", $.proxy(function () { | ||
this.get_container_ul().addClass('jstree-contextmenu'); | ||
}, this)) | ||
.on("contextmenu.jstree", ".jstree-anchor", $.proxy(function (e, data) { | ||
@@ -640,3 +647,3 @@ if (e.target.tagName.toLowerCase() === 'input') { | ||
.on("mousedown.vakata.jstree", function (e) { | ||
if(vakata_context.is_visible && !$.contains(vakata_context.element[0], e.target)) { | ||
if(vakata_context.is_visible && vakata_context.element[0] !== e.target && !$.contains(vakata_context.element[0], e.target)) { | ||
$.vakata.context.hide(); | ||
@@ -643,0 +650,0 @@ } |
@@ -191,4 +191,5 @@ /** | ||
.on('dnd_move.vakata.jstree', function (e, data) { | ||
var isDifferentNode = data.event.target !== lastev.target; | ||
if(opento) { | ||
if (!data.event || data.event.type !== 'dragover' || data.event.target !== lastev.target) { | ||
if (!data.event || data.event.type !== 'dragover' || isDifferentNode) { | ||
clearTimeout(opento); | ||
@@ -292,3 +293,6 @@ } | ||
if(v === 'i' && ref.parent().is('.jstree-closed') && ins.settings.dnd.open_timeout) { | ||
opento = setTimeout((function (x, z) { return function () { x.open_node(z); }; }(ins, ref)), ins.settings.dnd.open_timeout); | ||
if (!data.event || data.event.type !== 'dragover' || isDifferentNode) { | ||
if (opento) { clearTimeout(opento); } | ||
opento = setTimeout((function (x, z) { return function () { x.open_node(z); }; }(ins, ref)), ins.settings.dnd.open_timeout); | ||
} | ||
} | ||
@@ -295,0 +299,0 @@ if(ok) { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
24906
663
1203077
68