Commit 1d00c378 authored by Ryan Herbert's avatar Ryan Herbert

database.js split jstree init into own function

parent 6c3f8ec0
......@@ -499,6 +499,26 @@ Database.prototype = {
},
set_jstree: function(elem) {
elem.jstree({
"plugins" : ["sort"],
'core' : {
'multiple': false,
'data' : {
'url' : function(node){
var address = DB_ADDRESS + '/file/filesystem'
return node.id === '#' ? address
: address + '?node=' + node.id
},
'dataType' : 'json',
},
}
});
elem.on('select_node.jstree', function(event, data){
$('#filename').val(data.selected);
});
},
toggle_upload_fields: function() {
var elem = $('.upload_field');
var disable = !elem.prop('disabled');
......@@ -519,23 +539,7 @@ Database.prototype = {
var enable = tree.parents("tr").prop('hidden');
tree.parents("tr").prop('hidden', !enable);
if (enable) {
tree.jstree({
"plugins" : ["sort"],
'core' : {
'multiple': false,
'data' : {
'url' : function(node){
var address = DB_ADDRESS + '/file/filesystem'
return node.id === '#' ? address
: address + '?node=' + node.id
},
'dataType' : 'json',
},
}
});
tree.on('select_node.jstree', function(event, data){
$('#filename').val(data.selected);
});
this.set_jstree(tree);
} else {
$.jstree.destroy();
tree.off('select_node.jstree');
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment