").replaceAll(this._actionNode.jsNode);
$.get(this._getUrl(nodeDef.sourceUrl), null,
function(msg) {
if (!msg || msg.length == 0) {
@@ -416,17 +389,17 @@ Umbraco.Sys.registerNamespace("Umbraco.Controls");
var oFound = null;
for (var o in msg) {
if (msg[o].attributes != null && msg[o].attributes.id == _this._actionNode.nodeId) {
- oFound = _this._tree.parseJSON(msg[o]);
+ oFound = $.tree.datastores.json().parse(msg[o], _this._tree);
//ensure the tree type is the same too
if ($(oFound).attr("umb:type") == _this._actionNode.treeType) { break; }
else { oFound = null; }
}
}
if (oFound != null) {
- _this._debug("reloadActionNode: node is refreshed!");
+ _this._debug("reloadActionNode: node is refreshed! : " + supressSelect);
var reloaded = $(oFound).replaceAll(toReplace);
_this._configureNodes(reloaded, true);
- if (!supressSelect) _this.selectNode(reloaded);
+ if (!supressSelect) _this.selectNode(reloaded, true, true);
if (!supressChildReload) {
_this._loadChildNodes(reloaded, function() {
if (callback != null) callback.call(_this, true);
@@ -451,6 +424,7 @@ Umbraco.Sys.registerNamespace("Umbraco.Controls");
getActionNode: function() {
/// Returns the latest node interacted with
+ this._debug("getActionNode: " + this._actionNode.nodeId);
return this._actionNode;
},
@@ -527,112 +501,73 @@ Umbraco.Sys.registerNamespace("Umbraco.Controls");
},
- onOpen: function(NODE, TREE_OBJ) {
- ///
- /// Updates the image path references after data is returned from the server.
- /// Adds the overlay div to the markup if the specified style is found in the classes of this node.
- ///
-
- this._debug("onOpen: " + $(NODE).attr("id"));
-
- var nodes = $(NODE).find("ul > li");
- this._configureNodes(nodes);
-
- return true;
- },
-
onBeforeOpen: function(NODE, TREE_OBJ) {
- /// Gets the node source from the meta data and assigns it to the tree prior to loading
- var nodeDef = this._getNodeDef($(NODE));
- this._debug("onBeforeOpen: " + nodeDef.nodeId);
- this._currentAJAXRequest = true;
- TREE_OBJ.settings.data.url = this._getUrl(nodeDef.sourceUrl);
+ /// Before opening child nodes, ensure that the data method and url are set properly
+ this._currentAJAXRequest = true;
+ TREE_OBJ.settings.data.opts.url = this._dataUrl;
+ TREE_OBJ.settings.data.opts.method = "GET";
},
onJSONData: function(DATA, TREE_OBJ) {
this._debug("onJSONData");
+
this._currentAJAXRequest = false;
+
+ if (typeof DATA.d != "undefined") {
+
+ var msg = DATA.d;
+ //recreates the tree
+ if ($.inArray(msg.app, this._loadedApps) == -1) {
+ this._debug("loading js for app: " + msg.app);
+ this._loadedApps.push(msg.app);
+ //inject the scripts
+ this._container.after("");
+ }
+ return eval(msg.json);
+ }
+
return DATA;
},
-
+
+ onBeforeRequest: function(NODE, TREE_OBJ) {
+ if (TREE_OBJ.settings.data.opts.method == "POST") {
+ var parameters = "{'app':'" + this._app + "','showContextMenu':'" + this._showContext + "', 'isDialog':'" + this._isDialog + "'}"
+ return parameters;
+ }
+ else {
+ var nodeDef = this.getNodeDef($(NODE));
+ return this._getUrlParams(nodeDef.sourceUrl);
+ }
+ },
+
onChange: function(NODE, TREE_OBJ) {
- ///
- /// Some code taken from the jsTree checkbox tree theme to allow for checkboxes
- ///
- if (this._treeType == "checkbox") {
- var $this = $(NODE).is("li") ? $(NODE) : $(NODE).parent();
- if ($this.children("a").hasClass("checked")) $this.children("a").removeClass("checked")
- else $this.children("a").addClass("checked");
- }
- else if (this._treeType == "inheritedcheckbox") {
- var $this = $(NODE).is("li") ? $(NODE) : $(NODE).parent();
- if ($this.children("a.unchecked").size() == 0) {
- TREE_OBJ.container.find("a").addClass("unchecked");
- }
- $this.children("a").removeClass("clicked");
- if ($this.children("a").hasClass("checked")) {
- $this.find("li").andSelf().children("a").removeClass("checked").removeClass("undetermined").addClass("unchecked");
- var state = 0;
- }
- else {
- $this.find("li").andSelf().children("a").removeClass("unchecked").removeClass("undetermined").addClass("checked");
- var state = 1;
- }
- $this.parents("li").each(function() {
- if (state == 1) {
- if ($(this).find("a.unchecked, a.undetermined").size() - 1 > 0) {
- $(this).parents("li").andSelf().children("a").removeClass("unchecked").removeClass("checked").addClass("undetermined");
- return false;
- }
- else $(this).children("a").removeClass("unchecked").removeClass("undetermined").addClass("checked");
- }
- else {
- if ($(this).find("a.checked, a.undetermined").size() - 1 > 0) {
- $(this).parents("li").andSelf().children("a").removeClass("unchecked").removeClass("checked").addClass("undetermined");
- return false;
- }
- else $(this).children("a").removeClass("checked").removeClass("undetermined").addClass("unchecked");
- }
- });
- }
-
//bubble an event!
$(this).trigger("nodeClicked", [NODE]);
},
- onRightClick: function(NODE, TREE_OBJ, EV) {
- /// Builds the context menu based on the current node
-
+ onBeforeContext: function(NODE, TREE_OBJ, EV) {
+
//update the action node's NodeDefinition and set the active tree type
- this._actionNode = this._getNodeDef($(NODE));
+ this._actionNode = this.getNodeDef($(NODE));
this.setActiveTreeType($(NODE).attr("umb:type"));
- this._debug("onRightClick: menu = " + this._actionNode.menu);
-
- //remove the old menu from the DOM as jsTree will keep appending new ones.
- $("div").remove(".tree-default-context");
-
- if (this._actionNode.menu != "") {
-
- //if there is a menu, then rebuilt the context menu
- TREE_OBJ.settings.ui.context = this._getContextMenu(this._actionNode.menu);
- TREE_OBJ.context_menu();
-
- //now we need to bind events for hiding on a timer when lost focus
- var timeout = null;
- TREE_OBJ.context.mouseenter(function() {
- clearTimeout(timeout);
- });
- TREE_OBJ.context.mouseleave(function() {
- timeout = setTimeout(function() {
- TREE_OBJ.hide_context();
- }, 400);
- });
-
- this._checkContextMenu(TREE_OBJ);
- }
+ this._debug("onBeforeContext: " + this._actionNode.menu);
+
+ return this._actionNode.menu;
},
+ onLoad: function(TREE_OBJ) {
+ /// When the application first loads, load the child nodes
+
+ this._debug("onLoad");
+
+ this._container.show();
+ //ensure the static data is gone
+ this._tree.settings.data.opts.static = null;
+ var _this = this;
+ _this._loadChildNodes($(_this._container).find("li"), null);
+ },
+
onBeforeMove: function(NODE,REF_NODE,TYPE,TREE_OBJ) {
///
/// First, check if it's a move or a sort
@@ -640,11 +575,11 @@ Umbraco.Sys.registerNamespace("Umbraco.Controls");
/// Third,
///
- var nodeDef = this._getNodeDef($(NODE));
+ var nodeDef = this.getNodeDef($(NODE));
var nodeParent = nodeDef.jsNode.parents("li:first");
- var nodeParentDef = this._getNodeDef(nodeParent);
+ var nodeParentDef = this.getNodeDef(nodeParent);
- var refNodeDef = this._getNodeDef($(REF_NODE));
+ var refNodeDef = this.getNodeDef($(REF_NODE));
this._debug("onBeforeMove, TYPE: " + TYPE);
this._debug("onBeforeMove, NODE ID: " + nodeDef.nodeId);
@@ -674,35 +609,15 @@ Umbraco.Sys.registerNamespace("Umbraco.Controls");
return false;
},
- _checkContextMenu: function(TREE_OBJ, count) {
- ///
- /// we need to check if the menu is too low in the browser.
- /// in order for this to work, we need to set a timer because there is no event
- /// for when the context menu is displayed.
- ///
-
- //this ensures there's no infinite loop looking for the context menu if an exception occurs
- if (count > 20)
- return;
-
- var isVisible = TREE_OBJ.context.is(":visible");
- if (!isVisible) {
- this._debug("_checkContextMenu - waiting for visible menu");
- var _this = this;
- setTimeout(function() { _this._checkContextMenu(TREE_OBJ, ++count); }, 50);
- return;
- }
- var offset = TREE_OBJ.context.offset();
- var bodyHeight = $("body").innerHeight();
- var ctxHeight = TREE_OBJ.context.height();
- this._debug("_checkContextMenu - offset top: " + offset.top + ", bodyHeight: " + bodyHeight + ", ctxHeight: " + ctxHeight);
- var diff = (offset.top + ctxHeight) - bodyHeight;
- if (diff > 0) {
- this._debug("_checkContextMenu - Menu needs adjusting, new top: " + diff);
- TREE_OBJ.context.css("top", (offset.top - diff - 10) + "px");
- }
+ onParse: function(STR, TREE_OBJ) {
+ this._debug("onParse");
+
+ var obj = $(STR);
+ this._configureNodes(obj);
+ //this will return the full html of the configured node
+ return $('
').append($(obj).clone()).remove().html();
},
-
+
_debug: function(strMsg) {
if (this._isDebug) {
Sys.Debug.trace("UmbracoTree: " + strMsg);
@@ -741,20 +656,30 @@ Umbraco.Sys.registerNamespace("Umbraco.Controls");
$(this).children("a:first").before("");
}
}
- //create a div element inside the anchor and move the inner text into it
- var txt = $(this).children("a").html();
- $(this).children("a").html("
" + txt + "
");
+ //create a div for the text
+ var a = $(this).children("a");
+ var ins = a.children("ins");
+ var txt = $("
" + a.text() + "
");
+ //check if it's not a sprite, if not then move the ins node just after the anchor, otherwise remove
+ if (a.hasClass("noSpr")) {
+ a.attr("style", ins.attr("style"));
+ }
+ else {
+
+ }
+ a.html(txt);
+ ins.remove();
//add the loaded class to each element so we know not to process it again
$(this).addClass("loaded");
});
},
- _getNodeDef: function(NODE) {
+ getNodeDef: function(NODE) {
/// Converts a jquery node with metadata to a NodeDefinition
//get our meta data stored with our node
var nodedata = $(NODE).children("a").metadata({ type: 'attr', name: 'umb:nodedata' });
- this._debug("_getNodeDef: " + $(NODE).attr("id") + ", " + nodedata.nodeType + ", " + nodedata.source);
+ this._debug("getNodeDef: " + $(NODE).attr("id") + ", " + nodedata.nodeType + ", " + nodedata.source);
var def = new Umbraco.Controls.NodeDefinition();
def.updateDefinition(this._tree, $(NODE), $(NODE).attr("id"), $(NODE).find("a > div").html(), nodedata.nodeType, nodedata.source, nodedata.menu, $(NODE).attr("umb:type"));
return def;
@@ -765,7 +690,7 @@ Umbraco.Sys.registerNamespace("Umbraco.Controls");
var rNode = this.findNode(this._recycleBinId, true);
if (rNode) {
- this._actionNode = this._getNodeDef(rNode);
+ this._actionNode = this.getNodeDef(rNode);
var _this = this;
this.reloadActionNode(true, true, function(success) {
if (success) {
@@ -837,8 +762,8 @@ Umbraco.Sys.registerNamespace("Umbraco.Controls");
var doReload = (forceReload && (numAsync == null || numAsync < 1));
this._debug("_syncTree: found! numAsync: " + numAsync + ", forceReload: " + forceReload);
if (doReload) {
- this._actionNode = this._getNodeDef(found);
- this.reloadActionNode(true, true, null);
+ this._actionNode = this.getNodeDef(found);
+ this.reloadActionNode(false, true, null);
}
else {
//we have found our node, select it but supress the selecting event
@@ -850,34 +775,6 @@ Umbraco.Sys.registerNamespace("Umbraco.Controls");
}
},
- _getContextMenu: function(strMenu) {
- /// Builds a new context menu object (array) based on the string representation passed in
-
- this._debug("_getContextMenu: " + strMenu);
-
- var newMenu = new Array();
- for (var i = 0; i < strMenu.length; i++) {
- var letter = strMenu.charAt(i);
- //get a js menu item by letter
- var menuItem = this._getMenuItemByLetter(letter);
- if (menuItem != null) newMenu.push(menuItem);
- }
- return newMenu;
- },
-
- _getMenuItemByLetter: function(letter) {
- /// Finds the menu item in our full menu by the letter and returns object
-
- //insert selector if it's a comma
- if (letter == ",") return "separator";
- for (var m in this._fullMenu) {
- if (this._fullMenu[m].id == letter) {
- return this._fullMenu[m];
- }
- }
- return null;
- },
-
_init: function(jFullMenu, jInitNode, treeContainer, appActions, uiKeys, app, showContext, isDialog, treeType, serviceUrl, dataUrl, umbClientFolder, recycleBinId) {
/// initialization method, must be called on page ready.
/// JSON markup for the full context menu in accordance with the jsTree context menu object standard
@@ -919,71 +816,83 @@ Umbraco.Sys.registerNamespace("Umbraco.Controls");
//initializes the jsTree
this._container = treeContainer;
- this._tree = $.tree_create();
+ this._tree = $.tree.create();
this._tree.init(this._container, this._getInitOptions());
- this._tree.rename = this._umbracoRename; //replaces the jsTree rename method
+ //this._tree.rename = this._umbracoRename; //replaces the jsTree rename method
//add this app to the loaded apps array
- if ($.inArray(app, this._loadedApps) == -1) {
- this._loadedApps.push(app);
- }
+ //if ($.inArray(app, this._loadedApps) == -1) {
+ // this._loadedApps.push(app);
+ //}
//load child nodes of the init node
- this._loadChildNodes(this._container.find("li:first"), null);
+ //this._loadChildNodes(this._container.find("li:first"), null);
},
- _umbracoRename : function (obj) {
- /// A modified version of the original jsTree rename method. We need to use our own since
- /// we've modified the rendering so much. This method replaces the tree rename method.
- /// 'this' in this method context is jsTree.
- ///
- if(this.locked) return this.error("LOCKED");
- obj = obj ? this.get_node(obj) : this.selected;
- var _this = this;
- if(!obj || !obj.size()) return this.error("RENAME: NO NODE SELECTED");
- if(!this.check("renameable", obj)) return this.error("RENAME: NODE NOT RENAMABLE");
- if(!this.settings.callback.beforerename.call(null,obj.get(0), _this.current_lang, _this)) return this.error("RENAME: STOPPED BY USER");
+// _umbracoRename : function (obj) {
+// /// A modified version of the original jsTree rename method. We need to use our own since
+// /// we've modified the rendering so much. This method replaces the tree rename method.
+// /// 'this' in this method context is jsTree.
+// ///
+// if(this.locked) return this.error("LOCKED");
+// obj = obj ? this.get_node(obj) : this.selected;
+// var _this = this;
+// if(!obj || !obj.size()) return this.error("RENAME: NO NODE SELECTED");
+// if(!this.check("renameable", obj)) return this.error("RENAME: NODE NOT RENAMABLE");
+// if(!this.settings.callback.beforerename.call(null,obj.get(0), _this.current_lang, _this)) return this.error("RENAME: STOPPED BY USER");
- obj.parents("li.closed").each(function () { _this.open_branch(this) });
- //if(this.current_lang) obj = obj.find("a." + this.current_lang).get(0);
- //else obj = obj.find("a:first").get(0);
- obj = obj.find("a:first div");
- last_value = obj.html();
- _this.inp = $("");
- _this.inp
- .val(last_value.replace(/&/g,"&").replace(/>/g,">").replace(/</g,"<"))
- .bind("mousedown", function (event) { event.stopPropagation(); })
- .bind("mouseup", function (event) { event.stopPropagation(); })
- .bind("click", function (event) { event.stopPropagation(); })
- .bind("keyup", function (event) {
- var key = event.keyCode || event.which;
- if(key == 27) { this.value = last_value; this.blur(); return }
- if(key == 13) { this.blur(); return }
- });
- // Rollback
- var rb = {};
- rb[this.container.attr("id")] = this.get_rollback();
-
-
- var spn = $("").addClass($(obj).parent().attr("class")).addClass("renaming").append(_this.inp);
- spn.attr("style", $(obj).attr("style"));
- obj.parent().hide();
-
- obj.parents("li:first").prepend(spn);
- //_this.inp.get(0).focus();
- //_this.inp.get(0).select();
-
-// _this.inp.blur(function(event) {
-// if(this.value == "") this.value = last_value;
-// var li = obj.parents("li:first")
-// obj.html(li.find("input").val());
-// obj.parent().show();
-// li.find("div.renaming").remove();
-// _this.settings.callback.onrename.call(null, _this.get_node(li).get(0), _this.current_lang, _this, rb);
-// _this.inp = false;
-// });
- },
+// obj.parents("li.closed").each(function () { _this.open_branch(this) });
+// //if(this.current_lang) obj = obj.find("a." + this.current_lang).get(0);
+// //else obj = obj.find("a:first").get(0);
+// obj = obj.find("a:first div");
+// last_value = obj.html();
+// _this.inp = $("");
+// _this.inp
+// .val(last_value.replace(/&/g,"&").replace(/>/g,">").replace(/</g,"<"))
+// .bind("mousedown", function (event) { event.stopPropagation(); })
+// .bind("mouseup", function (event) { event.stopPropagation(); })
+// .bind("click", function (event) { event.stopPropagation(); })
+// .bind("keyup", function (event) {
+// var key = event.keyCode || event.which;
+// if(key == 27) { this.value = last_value; this.blur(); return }
+// if(key == 13) { this.blur(); return }
+// });
+// // Rollback
+// var rb = {};
+// rb[this.container.attr("id")] = this.get_rollback();
+//
+//
+// var spn = $("").addClass($(obj).parent().attr("class")).addClass("renaming").append(_this.inp);
+// spn.attr("style", $(obj).attr("style"));
+// obj.parent().hide();
+//
+// obj.parents("li:first").prepend(spn);
+// //_this.inp.get(0).focus();
+// //_this.inp.get(0).select();
+//
+//// _this.inp.blur(function(event) {
+//// if(this.value == "") this.value = last_value;
+//// var li = obj.parents("li:first")
+//// obj.html(li.find("input").val());
+//// obj.parent().show();
+//// li.find("div.renaming").remove();
+//// _this.settings.callback.onrename.call(null, _this.get_node(li).get(0), _this.current_lang, _this, rb);
+//// _this.inp = false;
+//// });
+// },
+ _getUrlParams: function(nodeSource) {
+ /// This converts Url query string params to json
+ var p = {};
+ var sp = nodeSource.split("?")[1].split("&");
+ for(var i=0;iReturns the json service url
@@ -994,7 +903,7 @@ Umbraco.Sys.registerNamespace("Umbraco.Controls");
return this._dataUrl + "?" + params + "&rnd2=" + Umbraco.Utils.generateRandom();
},
- _getInitOptions: function() {
+ _getInitOptions: function(initData) {
/// return the initialization objects for the tree
this._debug("_getInitOptions");
@@ -1005,44 +914,61 @@ Umbraco.Sys.registerNamespace("Umbraco.Controls");
data: {
type: "json",
async: true,
- url: "",
- json: this._initNode,
- async_data: function(NODE) { return null; } //ensures that the node id isn't appended to the async url
+ opts : {
+ static: initData == null ? null: initData,
+ method: "POST",
+ url: _this._serviceUrl,
+ outer_attrib: ["id", "umb:type", "class", "rel"],
+ inner_attrib: ["umb:nodedata", "href", "class", "style"]
+ }
},
ui: {
dots: false,
rtl: false,
animation: false,
hover_mode: true,
- theme_path: this._umb_clientFolderRoot + "/Tree/Themes/",
- theme_name: "umbraco",
- context: null //no context menu by default
+ //theme_path: this._umb_clientFolderRoot + "/Tree/Themes/",
+ theme_name: "umbraco"
+ //context: null //no context menu by default
},
- lang: {
+ langs: {
new_node: "New folder",
loading: "
").html(str));obj.find("li:last-child").addClass("last").end().find("li:has(ul)").not(".open").addClass("closed");obj.find("li").not(".open").not(".closed").addClass("leaf");_this.open_branch.apply(_this,[obj]);if(callback)callback.call()})});return true}else{if(!this.settings.data.async){if(this.callback("beforeopen",[obj.get(0),this])===false)return this.error("OPEN: STOPPED BY USER")}if(parseInt(this.settings.ui.animation)>0&&!disable_animation){obj.children("ul:eq(0)").css("display","none");obj.removeClass("closed").addClass("open");obj.children("ul:eq(0)").slideDown(parseInt(this.settings.ui.animation),function(){$(this).css("display","");if(callback)callback.call()})}else{obj.removeClass("closed").addClass("open");if(callback)callback.call()}this.callback("onopen",[obj.get(0),this]);return true}},close_branch:function(obj,disable_animation){if(this.locked)return this.error("LOCKED");var _this=this;var obj=this.get_node(obj);if(!obj.size())return this.error("CLOSE: NO SUCH NODE");if(_this.callback("beforeclose",[obj.get(0),_this])===false)return this.error("CLOSE: STOPPED BY USER");if(parseInt(this.settings.ui.animation)>0&&!disable_animation&&obj.children("ul:eq(0)").size()==1){obj.children("ul:eq(0)").slideUp(parseInt(this.settings.ui.animation),function(){if(obj.hasClass("open"))obj.removeClass("open").addClass("closed");$(this).css("display","")})}else{if(obj.hasClass("open"))obj.removeClass("open").addClass("closed")}if(this.selected&&this.settings.ui.selected_parent_close!==false&&obj.children("ul:eq(0)").find("a.clicked").size()>0){obj.find("li:has(a.clicked)").each(function(){_this.deselect_branch(this)});if(this.settings.ui.selected_parent_close=="select_parent"&&obj.children("a.clicked").size()==0)this.select_branch(obj,(this.settings.rules.multiple!=false&&this.selected_arr.length>0))}this.callback("onclose",[obj.get(0),this])},open_all:function(obj,callback){if(this.locked)return this.error("LOCKED");var _this=this;obj=obj?this.get_node(obj):this.container;var s=obj.find("li.closed").size();if(!callback)this.cl_count=0;else this.cl_count--;if(s>0){this.cl_count+=s;obj.find("li.closed").each(function(){var __this=this;_this.open_branch.apply(_this,[this,true,function(){_this.open_all.apply(_this,[__this,true])}])})}else if(this.cl_count==0)this.callback("onopen_all",[this])},close_all:function(obj){if(this.locked)return this.error("LOCKED");var _this=this;obj=obj?this.get_node(obj):this.container;obj.find("li.open").each(function(){_this.close_branch(this,true)});this.callback("onclose_all",[this])},set_lang:function(i){if(!$.isArray(this.settings.languages)||this.settings.languages.length==0)return false;if(this.locked)return this.error("LOCKED");if(!$.inArray(i,this.settings.languages)&&typeof this.settings.languages[i]!="undefined")i=this.settings.languages[i];if(typeof i=="undefined")return false;if(i==this.current_lang)return true;var st=false;var id="#"+this.container.attr("id");st=tree_component.get_css(id+" ."+this.current_lang);if(st!==false)st.style.display="none";st=tree_component.get_css(id+" ."+i);if(st!==false)st.style.display="";this.current_lang=i;return true},get_lang:function(){if(!$.isArray(this.settings.languages)||this.settings.languages.length==0)return false;return this.current_lang},create:function(obj,ref_node,position){if(this.locked)return this.error("LOCKED");var root=false;if(ref_node==-1){root=true;ref_node=this.container}else ref_node=ref_node?this.get_node(ref_node):this.selected;if(!root&&(!ref_node||!ref_node.size()))return this.error("CREATE: NO NODE SELECTED");var pos=position;var tmp=ref_node;if(position=="before"){position=ref_node.parent().children().index(ref_node);ref_node=ref_node.parents("li:eq(0)")}if(position=="after"){position=ref_node.parent().children().index(ref_node)+1;ref_node=ref_node.parents("li:eq(0)")}if(!root&&ref_node.size()==0){root=true;ref_node=this.container}if(!root){if(!this.check("creatable",ref_node))return this.error("CREATE: CANNOT CREATE IN NODE");if(ref_node.hasClass("closed")){if(this.settings.data.async&&ref_node.children("ul").size()==0){var _this=this;return this.open_branch(ref_node,true,function(){_this.create.apply(_this,[obj,ref_node,position])})}else this.open_branch(ref_node,true)}}var torename=false;if(!obj)obj={};else obj=$.extend(true,{},obj);if(!obj.attributes)obj.attributes={};if(!obj.attributes[this.settings.rules.type_attr])obj.attributes[this.settings.rules.type_attr]=this.get_type(tmp)||"default";if(this.settings.languages.length){if(!obj.data){obj.data={};torename=true}for(var i=0;i=this.children(ref_node).size())return this.error("CREATE: MAX_CHILDREN REACHED")}if(this.settings.rules.use_max_depth){if(typeof r.max_depth!="undefined"&&r.max_depth===0)return this.error("CREATE: MAX-DEPTH REACHED");var mx=(r.max_depth>0)?r.max_depth:false;var i=0;var t=ref_node;while(t!==-1&&!root){t=this.parent(t);i++;var m=this.check("max_depth",t);if(m>=0){mx=(mx===false)?(m-i):Math.min(mx,m-i)}if(mx!==false&&mx<=0)return this.error("CREATE: MAX-DEPTH REACHED")}if(mx!==false&&mx<=0)return this.error("CREATE: MAX-DEPTH REACHED");if(mx!==false){var incr=1;var t=$li;while(t.size()>0){if(mx-incr<0)return this.error("CREATE: MAX-DEPTH REACHED");t=t.children("ul").children("li");incr++}}}if((typeof position).toLowerCase()=="undefined"||position=="inside")position=(this.settings.rules.createat=="top")?0:ref_node.children("ul:eq(0)").children("li").size();if(ref_node.children("ul").size()==0||(root==true&&ref_node.children("ul").children("li").size()==0)){if(!root)var a=this.moved($li,ref_node.children("a:eq(0)"),"inside",true);else var a=this.moved($li,this.container.children("ul:eq(0)"),"inside",true)}else if(pos=="before"&&ref_node.children("ul:eq(0)").children("li:nth-child("+(position+1)+")").size())var a=this.moved($li,ref_node.children("ul:eq(0)").children("li:nth-child("+(position+1)+")").children("a:eq(0)"),"before",true);else if(pos=="after"&&ref_node.children("ul:eq(0)").children("li:nth-child("+(position)+")").size())var a=this.moved($li,ref_node.children("ul:eq(0)").children("li:nth-child("+(position)+")").children("a:eq(0)"),"after",true);else if(ref_node.children("ul:eq(0)").children("li:nth-child("+(position+1)+")").size())var a=this.moved($li,ref_node.children("ul:eq(0)").children("li:nth-child("+(position+1)+")").children("a:eq(0)"),"before",true);else var a=this.moved($li,ref_node.children("ul:eq(0)").children("li:last").children("a:eq(0)"),"after",true);if(a===false)return this.error("CREATE: ABORTED");if(torename){this.select_branch($li.children("a:eq(0)"));this.rename()}return $li},rename:function(obj,new_name){if(this.locked)return this.error("LOCKED");obj=obj?this.get_node(obj):this.selected;var _this=this;if(!obj||!obj.size())return this.error("RENAME: NO NODE SELECTED");if(!this.check("renameable",obj))return this.error("RENAME: NODE NOT RENAMABLE");if(!this.callback("beforerename",[obj.get(0),_this.current_lang,_this]))return this.error("RENAME: STOPPED BY USER");obj.parents("li.closed").each(function(){_this.open_branch(this)});if(this.current_lang)obj=obj.find("a."+this.current_lang);else obj=obj.find("a:first");var rb={};rb[this.container.attr("id")]=this.get_rollback();var icn=obj.children("ins").clone();if((typeof new_name).toLowerCase()=="string"){obj.text(new_name).prepend(icn);_this.callback("onrename",[_this.get_node(obj).get(0),_this,rb])}else{var last_value="";obj.contents().each(function(){if(this.nodeType==3){last_value=this.data;return false}});_this.inp=$("");_this.inp.val(last_value.replace(/&/g,"&").replace(/>/g,">").replace(/</g,"<")).bind("mousedown",function(event){event.stopPropagation()}).bind("mouseup",function(event){event.stopPropagation()}).bind("click",function(event){event.stopPropagation()}).bind("keyup",function(event){var key=event.keyCode||event.which;if(key==27){this.value=last_value;this.blur();return}if(key==13){this.blur();return}});_this.inp.blur(function(event){if(this.value=="")this.value=last_value;obj.text(this.value).prepend(icn);obj.get(0).style.display="";obj.prevAll("span").remove();_this.inp=false;_this.callback("onrename",[_this.get_node(obj).get(0),_this,rb])});var spn=$("").addClass(obj.attr("class")).append(icn).append(_this.inp);obj.get(0).style.display="none";obj.parent().prepend(spn);_this.inp.get(0).focus();_this.inp.get(0).select()}},remove:function(obj){if(this.locked)return this.error("LOCKED");var _this=this;var rb={};rb[this.container.attr("id")]=this.get_rollback();if(obj&&(!this.selected||this.get_node(obj).get(0)!=this.selected.get(0))){obj=this.get_node(obj);if(obj.size()){if(!this.check("deletable",obj))return this.error("DELETE: NODE NOT DELETABLE");if(!this.callback("beforedelete",[obj.get(0),_this]))return this.error("DELETE: STOPPED BY USER");$parent=obj.parent();if(obj.find("a.clicked").size()){var reset_selected=false;_this.selected_arr=[];this.container.find("a.clicked").filter(":first-child").parent().each(function(){if(!reset_selected&&this==_this.selected.get(0))reset_selected=true;if($(this).parents().index(obj)!=-1)return true;_this.selected_arr.push($(this))});if(reset_selected)this.selected=this.selected_arr[0]||false}obj=obj.remove();$parent.children("li:last").addClass("last");if($parent.children("li").size()==0){$li=$parent.parents("li:eq(0)");$li.removeClass("open").removeClass("closed").addClass("leaf").children("ul").remove()}this.callback("ondelete",[obj.get(0),this,rb])}}else if(this.selected){if(!this.check("deletable",this.selected))return this.error("DELETE: NODE NOT DELETABLE");if(!this.callback("beforedelete",[this.selected.get(0),_this]))return this.error("DELETE: STOPPED BY USER");$parent=this.selected.parent();var obj=this.selected;if(this.settings.rules.multiple==false||this.selected_arr.length==1){var stop=true;var tmp=this.settings.ui.selected_delete=="select_previous"?this.prev(this.selected):false}obj=obj.remove();$parent.children("li:last").addClass("last");if($parent.children("li").size()==0){$li=$parent.parents("li:eq(0)");$li.removeClass("open").removeClass("closed").addClass("leaf").children("ul").remove()}if(!stop&&this.settings.rules.multiple!=false){var _this=this;this.selected_arr=[];this.container.find("a.clicked").filter(":first-child").parent().each(function(){_this.selected_arr.push($(this))});if(this.selected_arr.length>0){this.selected=this.selected_arr[0];this.remove()}}if(stop&&tmp)this.select_branch(tmp);this.callback("ondelete",[obj.get(0),this,rb])}else return this.error("DELETE: NO NODE SELECTED")},next:function(obj,strict){obj=this.get_node(obj);if(!obj.size())return false;if(strict)return(obj.nextAll("li").size()>0)?obj.nextAll("li:eq(0)"):false;if(obj.hasClass("open"))return obj.find("li:eq(0)");else if(obj.nextAll("li").size()>0)return obj.nextAll("li:eq(0)");else return obj.parents("li").next("li").eq(0)},prev:function(obj,strict){obj=this.get_node(obj);if(!obj.size())return false;if(strict)return(obj.prevAll("li").size()>0)?obj.prevAll("li:eq(0)"):false;if(obj.prev("li").size()){var obj=obj.prev("li").eq(0);while(obj.hasClass("open"))obj=obj.children("ul:eq(0)").children("li:last");return obj}else return obj.parents("li:eq(0)").size()?obj.parents("li:eq(0)"):false},parent:function(obj){obj=this.get_node(obj);if(!obj.size())return false;return obj.parents("li:eq(0)").size()?obj.parents("li:eq(0)"):-1},children:function(obj){if(obj===-1)return this.container.children("ul:eq(0)").children("li");obj=this.get_node(obj);if(!obj.size())return false;return obj.children("ul:eq(0)").children("li")},toggle_dots:function(){if(this.settings.ui.dots){this.settings.ui.dots=false;this.container.children("ul:eq(0)").addClass("no_dots")}else{this.settings.ui.dots=true;this.container.children("ul:eq(0)").removeClass("no_dots")}},callback:function(cb,args){var p=false;var r=null;for(var i in this.settings.plugins){if(typeof $.tree.plugins[i]!="object")continue;p=$.tree.plugins[i];if(p.callbacks&&typeof p.callbacks[cb]=="function")r=p.callbacks[cb].apply(this,args);if(typeof r!=="undefined"&&r!==null){if(cb=="ondata"||cb=="onparse")args[0]=r;else return r}}p=this.settings.callback[cb];if(typeof p=="function")return p.apply(null,args)},get_rollback:function(){var rb={};rb.html=this.container.html();rb.selected=this.selected?this.selected.attr("id"):false;return rb},moved:function(what,where,how,is_new,is_copy,rb){var what=$(what);var $parent=$(what).parents("ul:eq(0)");var $where=$(where);if($where.is("ins"))$where=$where.parent();if(!rb){var rb={};rb[this.container.attr("id")]=this.get_rollback();if(!is_new){var tmp=what.size()>1?what.eq(0).parents(".tree:eq(0)"):what.parents(".tree:eq(0)");if(tmp.get(0)!=this.container.get(0)){tmp=tree_component.inst[tmp.attr("id")];rb[tmp.container.attr("id")]=tmp.get_rollback()}delete tmp}}if(how=="inside"&&this.settings.data.async){var _this=this;if(this.get_node($where).hasClass("closed")){return this.open_branch(this.get_node($where),true,function(){_this.moved.apply(_this,[what,where,how,is_new,is_copy,rb])})}if(this.get_node($where).find("> ul > li > a.loading").size()==1){setTimeout(function(){_this.moved.apply(_this,[what,where,how,is_new,is_copy])},200);return}}if(what.size()>1){var _this=this;var tmp=this.moved(what.eq(0),where,how,false,is_copy,rb);what.each(function(i){if(i==0)return;if(tmp){tmp=_this.moved(this,tmp.children("a:eq(0)"),"after",false,is_copy,rb)}});return what}if(is_copy){_what=what.clone();_what.each(function(i){this.id=this.id+"_copy";$(this).find("li").each(function(){this.id=this.id+"_copy"});$(this).removeClass("dragged").find("a.clicked").removeClass("clicked").end().find("li.dragged").removeClass("dragged")})}else _what=what;if(is_new){if(!this.callback("beforecreate",[this.get_node(what).get(0),this.get_node(where).get(0),how,this]))return false}else{if(!this.callback("beforemove",[this.get_node(what).get(0),this.get_node(where).get(0),how,this]))return false}if(!is_new){var tmp=what.parents(".tree:eq(0)");if(tmp.get(0)!=this.container.get(0)){tmp=tree_component.inst[tmp.attr("id")];if(tmp.settings.languages.length){var res=[];if(this.settings.languages.length==0)res.push("."+tmp.current_lang);else{for(var i in this.settings.languages){if(!this.settings.languages.hasOwnProperty(i))continue;for(var j in tmp.settings.languages){if(!tmp.settings.languages.hasOwnProperty(j))continue;if(this.settings.languages[i]==tmp.settings.languages[j])res.push("."+this.settings.languages[i])}}}if(res.length==0)return this.error("MOVE: NO COMMON LANGUAGES");_what.find("a").not(res.join(",")).remove()}_what.find("a.clicked").removeClass("clicked")}}what=_what;switch(how){case"before":$where.parents("ul:eq(0)").children("li.last").removeClass("last");$where.parent().before(what.removeClass("last"));$where.parents("ul:eq(0)").children("li:last").addClass("last");break;case"after":$where.parents("ul:eq(0)").children("li.last").removeClass("last");$where.parent().after(what.removeClass("last"));$where.parents("ul:eq(0)").children("li:last").addClass("last");break;case"inside":if($where.parent().children("ul:first").size()){if(this.settings.rules.createat=="top"){$where.parent().children("ul:first").prepend(what.removeClass("last")).children("li:last").addClass("last");var tmp_node=$where.parent().children("ul:first").children("li:first");if(tmp_node.size()){how="before";where=tmp_node}}else{var tmp_node=$where.parent().children("ul:first").children(".last");if(tmp_node.size()){how="after";where=tmp_node}$where.parent().children("ul:first").children(".last").removeClass("last").end().append(what.removeClass("last")).children("li:last").addClass("last")}}else{what.addClass("last");$where.parent().removeClass("leaf").append("
");if(!$where.parent().hasClass("open"))$where.parent().addClass("closed");$where.parent().children("ul:first").prepend(what)}if($where.parent().hasClass("closed")){this.open_branch($where)}break;default:break}if($parent.find("li").size()==0){var $li=$parent.parent();$li.removeClass("open").removeClass("closed").addClass("leaf");if(!$li.is(".tree"))$li.children("ul").remove();$li.parents("ul:eq(0)").children("li.last").removeClass("last").end().children("li:last").addClass("last")}else{$parent.children("li.last").removeClass("last");$parent.children("li:last").addClass("last")}if(is_copy)this.callback("oncopy",[this.get_node(what).get(0),this.get_node(where).get(0),how,this,rb]);else if(is_new)this.callback("oncreate",[this.get_node(what).get(0),($where.is("ul")?-1:this.get_node(where).get(0)),how,this,rb]);else this.callback("onmove",[this.get_node(what).get(0),this.get_node(where).get(0),how,this,rb]);return what},error:function(code){this.callback("error",[code,this]);return false},lock:function(state){this.locked=state;if(this.locked)this.container.children("ul:eq(0)").addClass("locked");else this.container.children("ul:eq(0)").removeClass("locked")},cut:function(obj){if(this.locked)return this.error("LOCKED");obj=obj?this.get_node(obj):this.container.find("a.clicked").filter(":first-child").parent();if(!obj||!obj.size())return this.error("CUT: NO NODE SELECTED");tree_component.cut_copy.copy_nodes=false;tree_component.cut_copy.cut_nodes=obj},copy:function(obj){if(this.locked)return this.error("LOCKED");obj=obj?this.get_node(obj):this.container.find("a.clicked").filter(":first-child").parent();if(!obj||!obj.size())return this.error("COPY: NO NODE SELECTED");tree_component.cut_copy.copy_nodes=obj;tree_component.cut_copy.cut_nodes=false},paste:function(obj,position){if(this.locked)return this.error("LOCKED");var root=false;if(obj==-1){root=true;obj=this.container}else obj=obj?this.get_node(obj):this.selected;if(!root&&(!obj||!obj.size()))return this.error("PASTE: NO NODE SELECTED");if(!tree_component.cut_copy.copy_nodes&&!tree_component.cut_copy.cut_nodes)return this.error("PASTE: NOTHING TO DO");var _this=this;var pos=position;if(position=="before"){position=obj.parent().children().index(obj);obj=obj.parents("li:eq(0)")}else if(position=="after"){position=obj.parent().children().index(obj)+1;obj=obj.parents("li:eq(0)")}else if((typeof position).toLowerCase()=="undefined"||position=="inside"){position=(this.settings.rules.createat=="top")?0:obj.children("ul:eq(0)").children("li").size()}if(!root&&obj.size()==0){root=true;obj=this.container}if(tree_component.cut_copy.copy_nodes&&tree_component.cut_copy.copy_nodes.size()){var ok=true;if(!root&&!this.check_move(tree_component.cut_copy.copy_nodes,obj.children("a:eq(0)"),"inside"))return false;if(obj.children("ul").size()==0||(root==true&&obj.children("ul").children("li").size()==0)){if(!root)var a=this.moved(tree_component.cut_copy.copy_nodes,obj.children("a:eq(0)"),"inside",false,true);else var a=this.moved(tree_component.cut_copy.copy_nodes,this.container.children("ul:eq(0)"),"inside",false,true)}else if(pos=="before"&&obj.children("ul:eq(0)").children("li:nth-child("+(position+1)+")").size())var a=this.moved(tree_component.cut_copy.copy_nodes,obj.children("ul:eq(0)").children("li:nth-child("+(position+1)+")").children("a:eq(0)"),"before",false,true);else if(pos=="after"&&obj.children("ul:eq(0)").children("li:nth-child("+(position)+")").size())var a=this.moved(tree_component.cut_copy.copy_nodes,obj.children("ul:eq(0)").children("li:nth-child("+(position)+")").children("a:eq(0)"),"after",false,true);else if(obj.children("ul:eq(0)").children("li:nth-child("+(position+1)+")").size())var a=this.moved(tree_component.cut_copy.copy_nodes,obj.children("ul:eq(0)").children("li:nth-child("+(position+1)+")").children("a:eq(0)"),"before",false,true);else var a=this.moved(tree_component.cut_copy.copy_nodes,obj.children("ul:eq(0)").children("li:last").children("a:eq(0)"),"after",false,true);tree_component.cut_copy.copy_nodes=false}if(tree_component.cut_copy.cut_nodes&&tree_component.cut_copy.cut_nodes.size()){var ok=true;obj.parents().andSelf().each(function(){if(tree_component.cut_copy.cut_nodes.index(this)!=-1){ok=false;return false}});if(!ok)return this.error("Invalid paste");if(!root&&!this.check_move(tree_component.cut_copy.cut_nodes,obj.children("a:eq(0)"),"inside"))return false;if(obj.children("ul").size()==0||(root==true&&obj.children("ul").children("li").size()==0)){if(!root)var a=this.moved(tree_component.cut_copy.cut_nodes,obj.children("a:eq(0)"),"inside");else var a=this.moved(tree_component.cut_copy.cut_nodes,this.container.children("ul:eq(0)"),"inside")}else if(pos=="before"&&obj.children("ul:eq(0)").children("li:nth-child("+(position+1)+")").size())var a=this.moved(tree_component.cut_copy.cut_nodes,obj.children("ul:eq(0)").children("li:nth-child("+(position+1)+")").children("a:eq(0)"),"before");else if(pos=="after"&&obj.children("ul:eq(0)").children("li:nth-child("+(position)+")").size())var a=this.moved(tree_component.cut_copy.cut_nodes,obj.children("ul:eq(0)").children("li:nth-child("+(position)+")").children("a:eq(0)"),"after");else if(obj.children("ul:eq(0)").children("li:nth-child("+(position+1)+")").size())var a=this.moved(tree_component.cut_copy.cut_nodes,obj.children("ul:eq(0)").children("li:nth-child("+(position+1)+")").children("a:eq(0)"),"before");else var a=this.moved(tree_component.cut_copy.cut_nodes,obj.children("ul:eq(0)").children("li:last").children("a:eq(0)"),"after");tree_component.cut_copy.cut_nodes=false}},search:function(str,func){var _this=this;if(!str||(this.srch&&str!=this.srch)){this.srch="";this.srch_opn=false;this.container.find("a.search").removeClass("search")}this.srch=str;if(!str)return;if(!func)func="contains";if(this.settings.data.async){if(!this.srch_opn){var dd=$.extend({"search":str},this.callback("beforedata",[false,this]));$.ajax({type:this.settings.data.opts.method,url:this.settings.data.opts.url,data:dd,dataType:"text",success:function(data){_this.srch_opn=$.unique(data.split(","));_this.search.apply(_this,[str,func])}})}else if(this.srch_opn.length){if(this.srch_opn&&this.srch_opn.length){var opn=false;for(var j=0;j0){opn=true;var tmp="#"+this.srch_opn[j];delete this.srch_opn[j];this.open_branch(tmp,true,function(){_this.search.apply(_this,[str,func])})}}if(!opn){this.srch_opn=[];_this.search.apply(_this,[str,func])}}}else{this.srch_opn=false;var selector="a";if(this.settings.languages.length)selector+="."+this.current_lang;this.callback("onsearch",[this.container.find(selector+":"+func+"('"+str+"')"),this])}}else{var selector="a";if(this.settings.languages.length)selector+="."+this.current_lang;var nn=this.container.find(selector+":"+func+"('"+str+"')");nn.parents("li.closed").each(function(){_this.open_branch(this,true)});this.callback("onsearch",[nn,this])}},add_sheet:tree_component.add_sheet,destroy:function(){this.callback("ondestroy",[this]);this.container.unbind(".jstree");$("#"+this.container.attr("id")).die("click.jstree").die("dblclick.jstree").die("mouseover.jstree").die("mouseout.jstree").die("mousedown.jstree");this.container.removeClass("tree ui-widget ui-widget-content tree-default tree-"+this.settings.ui.theme_name).children("ul").removeClass("no_dots ltr locked").find("li").removeClass("leaf").removeClass("open").removeClass("closed").removeClass("last").children("a").removeClass("clicked hover search");if(this.cntr==tree_component.focused){for(var i in tree_component.inst){if(i!=this.cntr&&i!=this.container.attr("id")){tree_component.inst[i].focus();break}}}tree_component.inst[this.cntr]=false;tree_component.inst[this.container.attr("id")]=false;delete tree_component.inst[this.cntr];delete tree_component.inst[this.container.attr("id")];tree_component.cntr--}}};tree_component.cntr=0;tree_component.inst={};tree_component.themes=[];tree_component.drag_drop={isdown:false,drag_node:false,drag_help:false,dragged:false,init_x:false,init_y:false,moving:false,origin_tree:false,marker:false,move_type:false,ref_node:false,appended:false,foreign:false,droppable:[],open_time:false,scroll_time:false};tree_component.mouseup=function(event){var tmp=tree_component.drag_drop;if(tmp.open_time)clearTimeout(tmp.open_time);if(tmp.scroll_time)clearTimeout(tmp.scroll_time);if(tmp.moving&&$.tree.drag_end!==false)$.tree.drag_end.call(null,event,tmp);if(tmp.foreign===false&&tmp.drag_node&&tmp.drag_node.size()){tmp.drag_help.remove();if(tmp.move_type){var tree1=tree_component.inst[tmp.ref_node.parents(".tree:eq(0)").attr("id")];if(tree1)tree1.moved(tmp.dragged,tmp.ref_node,tmp.move_type,false,(tmp.origin_tree.settings.rules.drag_copy=="on"||(tmp.origin_tree.settings.rules.drag_copy=="ctrl"&&event.ctrlKey)))}tmp.move_type=false;tmp.ref_node=false}if(tmp.foreign!==false){if(tmp.drag_help)tmp.drag_help.remove();if(tmp.move_type){var tree1=tree_component.inst[tmp.ref_node.parents(".tree:eq(0)").attr("id")];if(tree1)tree1.callback("ondrop",[tmp.f_data,tree1.get_node(tmp.ref_node).get(0),tmp.move_type,tree1])}tmp.foreign=false;tmp.move_type=false;tmp.ref_node=false}if(tree_component.drag_drop.marker)tree_component.drag_drop.marker.hide();if(tmp.dragged&&tmp.dragged.size())tmp.dragged.removeClass("dragged");tmp.dragged=false;tmp.drag_help=false;tmp.drag_node=false;tmp.f_type=false;tmp.f_data=false;tmp.init_x=false;tmp.init_y=false;tmp.moving=false;tmp.appended=false;tmp.origin_tree=false;if(tmp.isdown){tmp.isdown=false;event.preventDefault();event.stopPropagation();return false}};tree_component.mousemove=function(event){var tmp=tree_component.drag_drop;var is_start=false;if(tmp.isdown){if(!tmp.moving&&Math.abs(tmp.init_x-event.pageX)<5&&Math.abs(tmp.init_y-event.pageY)<5){event.preventDefault();event.stopPropagation();return false}else{if(!tmp.moving){tree_component.drag_drop.moving=true;is_start=true}}if(tmp.open_time)clearTimeout(tmp.open_time);if(tmp.drag_help!==false){if(!tmp.appended){if(tmp.foreign!==false)tmp.origin_tree=$.tree.focused();$("body").append(tmp.drag_help);tmp.w=tmp.drag_help.width();tmp.appended=true}tmp.drag_help.css({"left":(event.pageX+5),"top":(event.pageY+15)})}if(is_start&&$.tree.drag_start!==false)$.tree.drag_start.call(null,event,tmp);if($.tree.drag!==false)$.tree.drag.call(null,event,tmp);if(event.target.tagName=="DIV"&&event.target.id=="jstree-marker")return false;var et=$(event.target);if(et.is("ins"))et=et.parent();var cnt=et.is(".tree")?et:et.parents(".tree:eq(0)");if(cnt.size()==0||!tree_component.inst[cnt.attr("id")]){if(tmp.scroll_time)clearTimeout(tmp.scroll_time);if(tmp.drag_help!==false)tmp.drag_help.find("li:eq(0) ins").addClass("forbidden");tmp.move_type=false;tmp.ref_node=false;tree_component.drag_drop.marker.hide();return false}var tree2=tree_component.inst[cnt.attr("id")];tree2.off_height();if(tmp.scroll_time)clearTimeout(tmp.scroll_time);tmp.scroll_time=setTimeout(function(){tree2.scroll_check(event.pageX,event.pageY)},50);var mov=false;var st=cnt.scrollTop();if(event.target.tagName=="A"||event.target.tagName=="INS"){if(et.is("#jstree-dragged"))return false;if(tree2.get_node(event.target).hasClass("closed")){tmp.open_time=setTimeout(function(){tree2.open_branch(et)},500)}var et_off=et.offset();var goTo={x:(et_off.left-1),y:(event.pageY-et_off.top)};var arr=[];if(goTo.ytree2.li_height*2/3-1)arr=["after","inside","before"];else{if(goTo.ycss_rules.length+5)return false;if(css_rules[j].selectorText&&css_rules[j].selectorText.toLowerCase()==rule_name){if(delete_flag==true){if(tree_component.css.removeRule)document.styleSheets[i].removeRule(j);if(tree_component.css.deleteRule)document.styleSheets[i].deleteRule(j);return true}else return css_rules[j]}}while(css_rules[++j]);return false};tree_component.add_css=function(rule_name){if(tree_component.get_css(rule_name))return false;(tree_component.css.insertRule)?tree_component.css.insertRule(rule_name+' { }',0):tree_component.css.addRule(rule_name,null,0);return tree_component.get_css(rule_name)};tree_component.remove_css=function(rule_name){return tree_component.get_css(rule_name,true)};tree_component.add_sheet=function(opts){if(opts.str){var tmp=document.createElement("style");tmp.type="text/css";if(tmp.styleSheet)tmp.styleSheet.cssText=opts.str;else tmp.appendChild(document.createTextNode(opts.str));document.getElementsByTagName("head")[0].appendChild(tmp);return tmp.sheet}if(opts.url){if(document.createStyleSheet){try{document.createStyleSheet(opts.url)}catch(e){}}else{var newSS=document.createElement('link');newSS.rel='stylesheet';newSS.type='text/css';newSS.media="all";newSS.href=opts.url;document.getElementsByTagName("head")[0].appendChild(newSS);return newSS.styleSheet}}};$(function(){var u=navigator.userAgent.toLowerCase();var v=(u.match(/.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/)||[0,'0'])[1];var css='/* TREE LAYOUT */ .tree ul { margin:0 0 0 5px; padding:0 0 0 0; list-style-type:none; } .tree li { display:block; min-height:18px; line-height:18px; padding:0 0 0 15px; margin:0 0 0 0; /* Background fix */ clear:both; } .tree li ul { display:none; } .tree li a, .tree li span { display:inline-block;line-height:16px;height:16px;color:black;white-space:nowrap;text-decoration:none;padding:1px 4px 1px 4px;margin:0; } .tree li a:focus { outline: none; } .tree li a input, .tree li span input { margin:0;padding:0 0;display:inline-block;height:12px !important;border:1px solid white;background:white;font-size:10px;font-family:Verdana; } .tree li a input:not([class="xxx"]), .tree li span input:not([class="xxx"]) { padding:1px 0; } /* FOR DOTS */ .tree .ltr li.last { float:left; } .tree > ul li.last { overflow:visible; } /* OPEN OR CLOSE */ .tree li.open ul { display:block; } .tree li.closed ul { display:none !important; } /* FOR DRAGGING */ #jstree-dragged { position:absolute; top:-10px; left:-10px; margin:0; padding:0; } #jstree-dragged ul ul ul { display:none; } #jstree-marker { padding:0; margin:0; line-height:5px; font-size:1px; overflow:hidden; height:5px; position:absolute; left:-45px; top:-30px; z-index:1000; background-color:transparent; background-repeat:no-repeat; display:none; } #jstree-marker.marker { width:45px; background-position:-32px top; } #jstree-marker.marker_plus { width:5px; background-position:right top; } /* BACKGROUND DOTS */ .tree li li { overflow:hidden; } .tree > .ltr > li { display:table; } /* ICONS */ .tree ul ins { display:inline-block; text-decoration:none; width:16px; height:16px; } .tree .ltr ins { margin:0 4px 0 0px; } ';if(/msie/.test(u)&&!/opera/.test(u)){if(parseInt(v)==6)css+='.tree li { height:18px; zoom:1; } .tree li li { overflow:visible; } .tree .ltr li.last { margin-top: expression( (this.previousSibling && /open/.test(this.previousSibling.className) ) ? "-2px" : "0"); } .marker { width:45px; background-position:-32px top; } .marker_plus { width:5px; background-position:right top; }';if(parseInt(v)==7)css+='.tree li li { overflow:visible; } .tree .ltr li.last { margin-top: expression( (this.previousSibling && /open/.test(this.previousSibling.className) ) ? "-2px" : "0"); }'}if(/opera/.test(u))css+='.tree > ul > li.last:after { content:"."; display: block; height:1px; clear:both; visibility:hidden; }';if(/mozilla/.test(u)&&!/(compatible|webkit)/.test(u)&&v.indexOf("1.8")==0)css+='.tree .ltr li a { display:inline; float:left; } .tree li ul { clear:both; }';tree_component.css=tree_component.add_sheet({str:css})})})(jQuery);(function($){$.extend($.tree.datastores,{"html":function(){return{get:function(obj,tree,opts){return obj&&$(obj).size()?$('
').append(tree.get_node(obj).clone()).html():tree.container.children("ul:eq(0)").html()},parse:function(data,tree,opts,callback){if(callback)callback.call(null,data);return data},load:function(data,tree,opts,callback){if(opts.url){$.ajax({'type':opts.method,'url':opts.url,'data':data,'dataType':"html",'success':function(d,textStatus){callback.call(null,d)},'error':function(xhttp,textStatus,errorThrown){callback.call(null,false);tree.error(errorThrown+" "+textStatus)}})}else{callback.call(null,opts.static||tree.container.children("ul:eq(0)").html())}}}},"json":function(){return{get:function(obj,tree,opts){var _this=this;if(!obj||$(obj).size()==0)obj=tree.container.children("ul").children("li");else obj=$(obj);if(!opts)opts={};if(!opts.outer_attrib)opts.outer_attrib=["id","rel","class"];if(!opts.inner_attrib)opts.inner_attrib=[];if(obj.size()>1){var arr=[];obj.each(function(){arr.push(_this.get(this,tree,opts))});return arr}if(obj.size()==0)return[];var json={attributes:{},data:{}};if(obj.hasClass("open"))json.data.state="open";if(obj.hasClass("closed"))json.data.state="closed";for(var i in opts.outer_attrib){if(!opts.outer_attrib.hasOwnProperty(i))continue;var val=(opts.outer_attrib[i]=="class")?obj.attr(opts.outer_attrib[i]).replace(/(^| )last( |$)/ig," ").replace(/(^| )(leaf|closed|open)( |$)/ig," "):obj.attr(opts.outer_attrib[i]);if(typeof val!="undefined"&&val.toString().replace(" ","").length>0)json.attributes[opts.outer_attrib[i]]=val;delete val}if(tree.settings.languages.length){for(var i in tree.settings.languages){if(!tree.settings.languages.hasOwnProperty(i))continue;var a=obj.children("a."+tree.settings.languages[i]);if(opts.force||opts.inner_attrib.length||a.children("ins").get(0).style.backgroundImage.toString().length||a.children("ins").get(0).className.length){json.data[tree.settings.languages[i]]={};json.data[tree.settings.languages[i]].title=tree.get_text(obj,tree.settings.languages[i]);if(a.children("ins").get(0).style.className.length){json.data[tree.settings.languages[i]].icon=a.children("ins").get(0).style.className}if(a.children("ins").get(0).style.backgroundImage.length){json.data[tree.settings.languages[i]].icon=a.children("ins").get(0).style.backgroundImage.replace("url(","").replace(")","")}if(opts.inner_attrib.length){json.data[tree.settings.languages[i]].attributes={};for(var j in opts.inner_attrib){if(!opts.inner_attrib.hasOwnProperty(j))continue;var val=a.attr(opts.inner_attrib[j]);if(typeof val!="undefined"&&val.toString().replace(" ","").length>0)json.data[tree.settings.languages[i]].attributes[opts.inner_attrib[j]]=val;delete val}}}else{json.data[tree.settings.languages[i]]=tree.get_text(obj,tree.settings.languages[i])}}}else{var a=obj.children("a");json.data.title=tree.get_text(obj);if(a.children("ins").size()&&a.children("ins").get(0).className.length){json.data.icon=a.children("ins").get(0).className}if(a.children("ins").size()&&a.children("ins").get(0).style.backgroundImage.length){json.data.icon=a.children("ins").get(0).style.backgroundImage.replace("url(","").replace(")","")}if(opts.inner_attrib.length){json.data.attributes={};for(var j in opts.inner_attrib){if(!opts.inner_attrib.hasOwnProperty(j))continue;var val=a.attr(opts.inner_attrib[j]);if(typeof val!="undefined"&&val.toString().replace(" ","").length>0)json.data.attributes[opts.inner_attrib[j]]=val;delete val}}}if(obj.children("ul").size()>0){json.children=[];obj.children("ul").children("li").each(function(){json.children.push(_this.get(this,tree,opts))})}return json},parse:function(data,tree,opts,callback){if(Object.prototype.toString.apply(data)==="[object Array]"){var str='';for(var i=0;i";if(tree.settings.languages.length){for(var i=0;i";if(data.data[tree.settings.languages[i]]&&data.data[tree.settings.languages[i]].icon){str+=" "}else str+=" ";str+=((typeof data.data[tree.settings.languages[i]].title).toLowerCase()!="undefined"?data.data[tree.settings.languages[i]].title:data.data[tree.settings.languages[i]])+""}}else{var attr={};attr["href"]="";attr["style"]="";attr["class"]="";if((typeof data.data.attributes).toLowerCase()!="undefined"){for(var i in data.data.attributes){if(!data.data.attributes.hasOwnProperty(i))continue;if(i=="style"||i=="class")attr[i]+=" "+data.data.attributes[i];else attr[i]=data.data.attributes[i]}}str+="";if(data.data.icon){str+=" "}else str+=" ";str+=((typeof data.data.title).toLowerCase()!="undefined"?data.data.title:data.data)+""}if(data.children&&data.children.length){str+='
';for(var i=0;i'}str+="";if(callback)callback.call(null,str);return str},load:function(data,tree,opts,callback){if(opts.static){callback.call(null,opts.static)}else{$.ajax({'type':opts.method,'url':opts.url,'data':data,'dataType':"json",'success':function(d,textStatus){callback.call(null,d)},'error':function(xhttp,textStatus,errorThrown){callback.call(null,false);tree.error(errorThrown+" "+textStatus)}})}}}}})})(jQuery);
\ No newline at end of file