Skip to content

Commit

Permalink
MINOR Auto-expanding nodes in TreeDropdownField, unsetting default ti…
Browse files Browse the repository at this point in the history
…tles when search field is focused
  • Loading branch information
chillu committed Jan 2, 2012
1 parent 4baef3b commit 6d2b519
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions javascript/TreeDropdownField.js
Expand Up @@ -120,9 +120,11 @@
var firstLoad = true;
if(status == 'success') {
$(this)
.jstree('destroy')
.bind('loaded.jstree', function(e, data) {
var val = self.getValue();
if(val) data.inst.select_node(treeHolder.find('*[data-id=' + val + ']'));
data.inst.open_all();
firstLoad = false;
if(callback) callback.apply(self);
})
Expand All @@ -141,6 +143,7 @@

// Avoid auto-closing panel on first load
if(!firstLoad) self.closePanel();
firstLoad=false
});
}

Expand All @@ -151,7 +154,7 @@
var self = this;
return {
'core': {
'initially_open': ['record-0'],
// 'initially_open': ['record-0'],
'animation': 0
},
'html_data': {
Expand Down Expand Up @@ -227,7 +230,7 @@
this.setTitle(title ? title : strings.searchFieldTitle);
},
setTitle: function(title) {
if(!title) title = strings.fieldTitle;
if(!title && title !== '') title = strings.fieldTitle;

this.find('.treedropdownfield-title').val(title);
},
Expand All @@ -246,6 +249,14 @@
});

$('.TreeDropdownField.searchable input.search').entwine({
onfocusin: function(e) {
var field = this.getField();
field.setTitle('');
},
onfocusout: function(e) {
var field = this.getField();
if(!field.getTitle()) field.setTitle(false);
},
onkeydown: function(e) {
var field = this.getField();
if(e.keyCode == 13) {
Expand Down Expand Up @@ -275,6 +286,7 @@
var firstLoad = true;
if(status == 'success') {
$(this)
.jstree('destroy')
.bind('loaded.jstree', function(e, data) {
$.each(self.getValue(), function(i, val) {
data.inst.check_node(treeHolder.find('*[data-id=' + val + ']'));
Expand Down

0 comments on commit 6d2b519

Please sign in to comment.