Skip to content

Commit

Permalink
new nodes created from the context menu are now correctly edited vaka…
Browse files Browse the repository at this point in the history
  • Loading branch information
vakata committed Apr 9, 2012
1 parent 3f76303 commit d320139
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 7 deletions.
10 changes: 7 additions & 3 deletions dist/jstree.js
Original file line number Diff line number Diff line change
Expand Up @@ -3923,6 +3923,9 @@ Some static functions and variables, unless you know exactly what you are doing
edit : function (obj, default_text) {
obj = this.get_node(obj);
if(!obj || obj === -1 || !obj.length) { return false; }
obj.parentsUntil(".jstree",".jstree-closed").each($.proxy(function (i, v) {
this.open_node(v, false, 0);
}, this));
var rtl = this.data.core.rtl,
w = this.get_container().width(),
a = obj.children('a:eq(0)'),
Expand Down Expand Up @@ -4110,7 +4113,7 @@ Adds checkboxes to the tree.

if(!c.hasClass('jstree-checked') && !c.hasClass('jstree-unchecked')) {
p = this.get_parent(obj);
if(p && p !== -1 && p.length && p.find('> a > .jstree-checked')) { c.addClass('jstree-checked'); }
if(p && p !== -1 && p.length && p.find('> a > .jstree-checked').length) { c.addClass('jstree-checked'); }
else { c.addClass('jstree-unchecked'); }
fix_up = false;
}
Expand Down Expand Up @@ -4256,8 +4259,9 @@ Enables a rightclick contextmenu.
"action" : function (data) {
var inst = $.jstree._reference(data.reference),
obj = inst.get_node(data.reference);
inst.create_node(obj);
inst.edit(obj);
inst.create_node(obj, {}, "last", function (new_node) {
setTimeout(function () { inst.edit(new_node); },0);
});
}
},
"rename" : {
Expand Down
2 changes: 1 addition & 1 deletion dist/jstree.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/jstree.checkbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ Adds checkboxes to the tree.

if(!c.hasClass('jstree-checked') && !c.hasClass('jstree-unchecked')) {
p = this.get_parent(obj);
if(p && p !== -1 && p.length && p.find('> a > .jstree-checked')) { c.addClass('jstree-checked'); }
if(p && p !== -1 && p.length && p.find('> a > .jstree-checked').length) { c.addClass('jstree-checked'); }
else { c.addClass('jstree-unchecked'); }
fix_up = false;
}
Expand Down
5 changes: 3 additions & 2 deletions src/jstree.contextmenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,9 @@ Enables a rightclick contextmenu.
"action" : function (data) {
var inst = $.jstree._reference(data.reference),
obj = inst.get_node(data.reference);
inst.create_node(obj);
inst.edit(obj);
inst.create_node(obj, {}, "last", function (new_node) {
setTimeout(function () { inst.edit(new_node); },0);
});
}
},
"rename" : {
Expand Down
3 changes: 3 additions & 0 deletions src/jstree.js
Original file line number Diff line number Diff line change
Expand Up @@ -1854,6 +1854,9 @@ Some static functions and variables, unless you know exactly what you are doing
edit : function (obj, default_text) {
obj = this.get_node(obj);
if(!obj || obj === -1 || !obj.length) { return false; }
obj.parentsUntil(".jstree",".jstree-closed").each($.proxy(function (i, v) {
this.open_node(v, false, 0);
}, this));
var rtl = this.data.core.rtl,
w = this.get_container().width(),
a = obj.children('a:eq(0)'),
Expand Down

0 comments on commit d320139

Please sign in to comment.