MINOR Wrapping LeftAndMain.Tree.js in entwine block

This commit is contained in:
Ingo Schommer 2011-03-10 23:53:59 +13:00
parent ea0f8b0e65
commit cfb83e4e47

View File

@ -3,7 +3,13 @@
*/
(function($) {
$(document).ready(function() {
$.entwine('ss', function($){
$('#sitetree_ul').entwine({
onmatch: function() {
this._super();
/**
* @todo Selectable tree with multiselect (toggled via "Batch Actions" panel)
* @todo Fix initial, unnecessary html_data replacement of existing tree (see below)
@ -30,8 +36,7 @@
* @todo When new edit form is loaded, automatically: Select matching node, set correct parent,
* update icon and title
*/
var treeContainer = $('#sitetree_ul');
treeContainer
this
.jstree({
'core': {
'initially_open': ['record-0'],
@ -39,9 +44,9 @@
},
'html_data': {
// TODO Hack to avoid ajax load on init, see http://code.google.com/p/jstree/issues/detail?id=911
'data': treeContainer.html(),
'data': this.html(),
'ajax': {
'url': treeContainer.data('url-tree'),
'url': this.data('url-tree'),
'data': function(node) {
return { ID : $(node).data("id") ? $(node).data("id") : 0 , ajax: 1};
}
@ -49,7 +54,7 @@
},
'ui': {
"select_limit" : 1,
'initially_select': [treeContainer.find('.current').attr('id')]
'initially_select': [this.find('.current').attr('id')]
},
"crrm": {
'move': {
@ -72,7 +77,7 @@
"drop_target" : false,
"drag_target" : false
},
'plugins': ['themes', 'html_data', 'ui', 'dnd', 'crrm']
'plugins': ['html_data', 'ui', 'dnd', 'crrm']
})
.bind('before.jstree', function(e, data) {
if(data.func == 'start_drag') {
@ -93,12 +98,12 @@
var url = $(node).find('a:first').attr('href');
if(url && url != '#') {
var xmlhttp = $('#Form_EditForm').entwine('ss').loadForm(
var xmlhttp = $('#Form_EditForm').loadForm(
url,
function(response) {}
);
} else {
$('#Form_EditForm').entwine('ss').removeForm();
$('#Form_EditForm').removeForm();
}
})
.bind('move_node.jstree', function(e, data) {
@ -108,7 +113,7 @@
});
$.ajax({
'url': treeContainer.data('url-savetreenode'),
'url': this.data('url-savetreenode'),
'data': {
ID: $(movedNode).data('id'),
ParentID: $(newParentNode).data('id') || 0,
@ -116,7 +121,10 @@
}
});
});
}
});
});
}(jQuery));