mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
MINOR Auto-expanding nodes in TreeDropdownField, unsetting default titles when search field is focused
This commit is contained in:
parent
4baef3b892
commit
6d2b519484
@ -120,9 +120,11 @@
|
|||||||
var firstLoad = true;
|
var firstLoad = true;
|
||||||
if(status == 'success') {
|
if(status == 'success') {
|
||||||
$(this)
|
$(this)
|
||||||
|
.jstree('destroy')
|
||||||
.bind('loaded.jstree', function(e, data) {
|
.bind('loaded.jstree', function(e, data) {
|
||||||
var val = self.getValue();
|
var val = self.getValue();
|
||||||
if(val) data.inst.select_node(treeHolder.find('*[data-id=' + val + ']'));
|
if(val) data.inst.select_node(treeHolder.find('*[data-id=' + val + ']'));
|
||||||
|
data.inst.open_all();
|
||||||
firstLoad = false;
|
firstLoad = false;
|
||||||
if(callback) callback.apply(self);
|
if(callback) callback.apply(self);
|
||||||
})
|
})
|
||||||
@ -141,6 +143,7 @@
|
|||||||
|
|
||||||
// Avoid auto-closing panel on first load
|
// Avoid auto-closing panel on first load
|
||||||
if(!firstLoad) self.closePanel();
|
if(!firstLoad) self.closePanel();
|
||||||
|
firstLoad=false
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -151,7 +154,7 @@
|
|||||||
var self = this;
|
var self = this;
|
||||||
return {
|
return {
|
||||||
'core': {
|
'core': {
|
||||||
'initially_open': ['record-0'],
|
// 'initially_open': ['record-0'],
|
||||||
'animation': 0
|
'animation': 0
|
||||||
},
|
},
|
||||||
'html_data': {
|
'html_data': {
|
||||||
@ -227,7 +230,7 @@
|
|||||||
this.setTitle(title ? title : strings.searchFieldTitle);
|
this.setTitle(title ? title : strings.searchFieldTitle);
|
||||||
},
|
},
|
||||||
setTitle: function(title) {
|
setTitle: function(title) {
|
||||||
if(!title) title = strings.fieldTitle;
|
if(!title && title !== '') title = strings.fieldTitle;
|
||||||
|
|
||||||
this.find('.treedropdownfield-title').val(title);
|
this.find('.treedropdownfield-title').val(title);
|
||||||
},
|
},
|
||||||
@ -246,6 +249,14 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
$('.TreeDropdownField.searchable input.search').entwine({
|
$('.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) {
|
onkeydown: function(e) {
|
||||||
var field = this.getField();
|
var field = this.getField();
|
||||||
if(e.keyCode == 13) {
|
if(e.keyCode == 13) {
|
||||||
@ -275,6 +286,7 @@
|
|||||||
var firstLoad = true;
|
var firstLoad = true;
|
||||||
if(status == 'success') {
|
if(status == 'success') {
|
||||||
$(this)
|
$(this)
|
||||||
|
.jstree('destroy')
|
||||||
.bind('loaded.jstree', function(e, data) {
|
.bind('loaded.jstree', function(e, data) {
|
||||||
$.each(self.getValue(), function(i, val) {
|
$.each(self.getValue(), function(i, val) {
|
||||||
data.inst.check_node(treeHolder.find('*[data-id=' + val + ']'));
|
data.inst.check_node(treeHolder.find('*[data-id=' + val + ']'));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user