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