Skip to content

Commit

Permalink
nodes can be deselected when multiple is false
Browse files Browse the repository at this point in the history
  • Loading branch information
vakata committed Feb 14, 2014
1 parent 389c882 commit f819c4c
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 16 deletions.
11 changes: 8 additions & 3 deletions dist/jstree.js
Original file line number Diff line number Diff line change
Expand Up @@ -2033,9 +2033,14 @@
return false;
}
if(!this.settings.core.multiple || (!e.metaKey && !e.ctrlKey && !e.shiftKey) || (e.shiftKey && (!this._data.core.last_clicked || !this.get_parent(obj) || this.get_parent(obj) !== this._data.core.last_clicked.parent ) )) {
this.deselect_all(true);
this.select_node(obj, false, false, e);
this._data.core.last_clicked = this.get_node(obj);
if(!this.settings.core.multiple && (e.metaKey || e.ctrlKey || e.shiftKey) && this.is_selected(obj)) {
this.deselect_node(obj, false, false, e);
}
else {
this.deselect_all(true);
this.select_node(obj, false, false, e);
this._data.core.last_clicked = this.get_node(obj);
}
}
else {
if(e.shiftKey) {
Expand Down
6 changes: 3 additions & 3 deletions dist/jstree.min.js

Large diffs are not rendered by default.

11 changes: 8 additions & 3 deletions docs/assets/dist/jstree.js
Original file line number Diff line number Diff line change
Expand Up @@ -2033,9 +2033,14 @@
return false;
}
if(!this.settings.core.multiple || (!e.metaKey && !e.ctrlKey && !e.shiftKey) || (e.shiftKey && (!this._data.core.last_clicked || !this.get_parent(obj) || this.get_parent(obj) !== this._data.core.last_clicked.parent ) )) {
this.deselect_all(true);
this.select_node(obj, false, false, e);
this._data.core.last_clicked = this.get_node(obj);
if(!this.settings.core.multiple && (e.metaKey || e.ctrlKey || e.shiftKey) && this.is_selected(obj)) {
this.deselect_node(obj, false, false, e);
}
else {
this.deselect_all(true);
this.select_node(obj, false, false, e);
this._data.core.last_clicked = this.get_node(obj);
}
}
else {
if(e.shiftKey) {
Expand Down
6 changes: 3 additions & 3 deletions docs/assets/dist/jstree.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/jstree.json
Original file line number Diff line number Diff line change
Expand Up @@ -2563,7 +2563,7 @@
},
"isPrivate": false,
"ignore": false,
"code": "activate_node : function (obj, e) {\n\t\t\tif(this.is_disabled(obj)) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tif(!this.settings.core.multiple || (!e.metaKey && !e.ctrlKey && !e.shiftKey) || (e.shiftKey && (!this._data.core.last_clicked || !this.get_parent(obj) || this.get_parent(obj) !== this._data.core.last_clicked.parent ) )) {\n\t\t\t\tthis.deselect_all(true);\n\t\t\t\tthis.select_node(obj, false, false, e);\n\t\t\t\tthis._data.core.last_clicked = this.get_node(obj);\n\t\t\t}\n\t\t\telse {\n\t\t\t\tif(e.shiftKey) {\n\t\t\t\t\tvar o = this.get_node(obj).id,\n\t\t\t\t\t\tl = this._data.core.last_clicked.id,\n\t\t\t\t\t\tp = this.get_node(this._data.core.last_clicked.parent).children,\n\t\t\t\t\t\tc = false,\n\t\t\t\t\t\ti, j;\n\t\t\t\t\tfor(i = 0, j = p.length; i < j; i += 1) {\n\t\t\t\t\t\t// separate IFs work whem o and l are the same\n\t\t\t\t\t\tif(p[i] === o) {\n\t\t\t\t\t\t\tc = !c;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif(p[i] === l) {\n\t\t\t\t\t\t\tc = !c;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif(c || p[i] === o || p[i] === l) {\n\t\t\t\t\t\t\tthis.select_node(p[i], false, false, e);\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse {\n\t\t\t\t\t\t\tthis.deselect_node(p[i], false, false, e);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tif(!this.is_selected(obj)) {\n\t\t\t\t\t\tthis.select_node(obj, false, false, e);\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\tthis.deselect_node(obj, false, false, e);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}"
"code": "activate_node : function (obj, e) {\n\t\t\tif(this.is_disabled(obj)) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tif(!this.settings.core.multiple || (!e.metaKey && !e.ctrlKey && !e.shiftKey) || (e.shiftKey && (!this._data.core.last_clicked || !this.get_parent(obj) || this.get_parent(obj) !== this._data.core.last_clicked.parent ) )) {\n\t\t\t\tif(!this.settings.core.multiple && (e.metaKey || e.ctrlKey || e.shiftKey) && this.is_selected(obj)) {\n\t\t\t\t\tthis.deselect_node(obj, false, false, e);\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tthis.deselect_all(true);\n\t\t\t\t\tthis.select_node(obj, false, false, e);\n\t\t\t\t\tthis._data.core.last_clicked = this.get_node(obj);\n\t\t\t\t}\n\t\t\t}\n\t\t\telse {\n\t\t\t\tif(e.shiftKey) {\n\t\t\t\t\tvar o = this.get_node(obj).id,\n\t\t\t\t\t\tl = this._data.core.last_clicked.id,\n\t\t\t\t\t\tp = this.get_node(this._data.core.last_clicked.parent).children,\n\t\t\t\t\t\tc = false,\n\t\t\t\t\t\ti, j;\n\t\t\t\t\tfor(i = 0, j = p.length; i < j; i += 1) {\n\t\t\t\t\t\t// separate IFs work whem o and l are the same\n\t\t\t\t\t\tif(p[i] === o) {\n\t\t\t\t\t\t\tc = !c;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif(p[i] === l) {\n\t\t\t\t\t\t\tc = !c;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif(c || p[i] === o || p[i] === l) {\n\t\t\t\t\t\t\tthis.select_node(p[i], false, false, e);\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse {\n\t\t\t\t\t\t\tthis.deselect_node(p[i], false, false, e);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tif(!this.is_selected(obj)) {\n\t\t\t\t\t\tthis.select_node(obj, false, false, e);\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\tthis.deselect_node(obj, false, false, e);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}"
},
{
"tags": [
Expand Down
11 changes: 8 additions & 3 deletions src/jstree.js
Original file line number Diff line number Diff line change
Expand Up @@ -2033,9 +2033,14 @@
return false;
}
if(!this.settings.core.multiple || (!e.metaKey && !e.ctrlKey && !e.shiftKey) || (e.shiftKey && (!this._data.core.last_clicked || !this.get_parent(obj) || this.get_parent(obj) !== this._data.core.last_clicked.parent ) )) {
this.deselect_all(true);
this.select_node(obj, false, false, e);
this._data.core.last_clicked = this.get_node(obj);
if(!this.settings.core.multiple && (e.metaKey || e.ctrlKey || e.shiftKey) && this.is_selected(obj)) {
this.deselect_node(obj, false, false, e);
}
else {
this.deselect_all(true);
this.select_node(obj, false, false, e);
this._data.core.last_clicked = this.get_node(obj);
}
}
else {
if(e.shiftKey) {
Expand Down

0 comments on commit f819c4c

Please sign in to comment.