X-Git-Url: http://git.ithinksw.org/extjs.git/blobdiff_plain/c930e9176a5a85509c5b0230e2bff5c22a591432..6e39d509471fe9b4e2660e0d1631b350d0c66f40:/pkgs/pkg-tree-debug.js diff --git a/pkgs/pkg-tree-debug.js b/pkgs/pkg-tree-debug.js index 848afea5..2553a85a 100644 --- a/pkgs/pkg-tree-debug.js +++ b/pkgs/pkg-tree-debug.js @@ -1,5 +1,5 @@ /*! - * Ext JS Library 3.0.0 + * Ext JS Library 3.1.0 * Copyright(c) 2006-2009 Ext JS, LLC * licensing@extjs.com * http://www.extjs.com/license @@ -118,11 +118,19 @@ new Ext.Viewport({ */ Ext.tree.TreePanel = Ext.extend(Ext.Panel, { rootVisible : true, - animate: Ext.enableFx, + animate : Ext.enableFx, lines : true, enableDD : false, hlDrop : Ext.enableFx, - pathSeparator: "/", + pathSeparator : '/', + + /** + * @cfg {Array} bubbleEvents + *

An array of events that, when fired, should be bubbled to any parent container. + * See {@link Ext.util.Observable#enableBubble}. + * Defaults to []. + */ + bubbleEvents : [], initComponent : function(){ Ext.tree.TreePanel.superclass.initComponent.call(this); @@ -138,7 +146,7 @@ Ext.tree.TreePanel = Ext.extend(Ext.Panel, { dataUrl: this.dataUrl, requestMethod: this.requestMethod }); - }else if(typeof l == 'object' && !l.load){ + }else if(Ext.isObject(l) && !l.load){ l = new Ext.tree.TreeLoader(l); } this.loader = l; @@ -167,7 +175,7 @@ Ext.tree.TreePanel = Ext.extend(Ext.Panel, { * @param {Node} node The newly appended node * @param {Number} index The index of the newly appended node */ - "append", + 'append', /** * @event remove * Fires when a child node is removed from a node in this tree. @@ -175,7 +183,7 @@ Ext.tree.TreePanel = Ext.extend(Ext.Panel, { * @param {Node} parent The parent node * @param {Node} node The child node removed */ - "remove", + 'remove', /** * @event movenode * Fires when a node is moved to a new location in the tree @@ -185,7 +193,7 @@ Ext.tree.TreePanel = Ext.extend(Ext.Panel, { * @param {Node} newParent The new parent of this node * @param {Number} index The index it was moved to */ - "movenode", + 'movenode', /** * @event insert * Fires when a new child node is inserted in a node in this tree. @@ -194,7 +202,7 @@ Ext.tree.TreePanel = Ext.extend(Ext.Panel, { * @param {Node} node The child node inserted * @param {Node} refNode The child node the node was inserted before */ - "insert", + 'insert', /** * @event beforeappend * Fires before a new child is appended to a node in this tree, return false to cancel the append. @@ -202,7 +210,7 @@ Ext.tree.TreePanel = Ext.extend(Ext.Panel, { * @param {Node} parent The parent node * @param {Node} node The child node to be appended */ - "beforeappend", + 'beforeappend', /** * @event beforeremove * Fires before a child is removed from a node in this tree, return false to cancel the remove. @@ -210,7 +218,7 @@ Ext.tree.TreePanel = Ext.extend(Ext.Panel, { * @param {Node} parent The parent node * @param {Node} node The child node to be removed */ - "beforeremove", + 'beforeremove', /** * @event beforemovenode * Fires before a node is moved to a new location in the tree. Return false to cancel the move. @@ -220,7 +228,7 @@ Ext.tree.TreePanel = Ext.extend(Ext.Panel, { * @param {Node} newParent The new parent the node is moving to * @param {Number} index The index it is being moved to */ - "beforemovenode", + 'beforemovenode', /** * @event beforeinsert * Fires before a new child is inserted in a node in this tree, return false to cancel the insert. @@ -229,20 +237,20 @@ Ext.tree.TreePanel = Ext.extend(Ext.Panel, { * @param {Node} node The child node to be inserted * @param {Node} refNode The child node the node is being inserted before */ - "beforeinsert", + 'beforeinsert', /** * @event beforeload * Fires before a node is loaded, return false to cancel * @param {Node} node The node being loaded */ - "beforeload", + 'beforeload', /** * @event load * Fires when a node is loaded * @param {Node} node The node that was loaded */ - "load", + 'load', /** * @event textchange * Fires when the text for a node is changed @@ -250,7 +258,7 @@ Ext.tree.TreePanel = Ext.extend(Ext.Panel, { * @param {String} text The new text * @param {String} oldText The old text */ - "textchange", + 'textchange', /** * @event beforeexpandnode * Fires before a node is expanded, return false to cancel. @@ -258,7 +266,7 @@ Ext.tree.TreePanel = Ext.extend(Ext.Panel, { * @param {Boolean} deep * @param {Boolean} anim */ - "beforeexpandnode", + 'beforeexpandnode', /** * @event beforecollapsenode * Fires before a node is collapsed, return false to cancel. @@ -266,54 +274,75 @@ Ext.tree.TreePanel = Ext.extend(Ext.Panel, { * @param {Boolean} deep * @param {Boolean} anim */ - "beforecollapsenode", + 'beforecollapsenode', /** * @event expandnode * Fires when a node is expanded * @param {Node} node The node */ - "expandnode", + 'expandnode', /** * @event disabledchange * Fires when the disabled status of a node changes * @param {Node} node The node * @param {Boolean} disabled */ - "disabledchange", + 'disabledchange', /** * @event collapsenode * Fires when a node is collapsed * @param {Node} node The node */ - "collapsenode", + 'collapsenode', /** * @event beforeclick * Fires before click processing on a node. Return false to cancel the default action. * @param {Node} node The node * @param {Ext.EventObject} e The event object */ - "beforeclick", + 'beforeclick', /** * @event click * Fires when a node is clicked * @param {Node} node The node * @param {Ext.EventObject} e The event object */ - "click", + 'click', + /** + * @event containerclick + * Fires when the tree container is clicked + * @param {Tree} this + * @param {Ext.EventObject} e The event object + */ + 'containerclick', /** * @event checkchange * Fires when a node with a checkbox's checked property changes * @param {Node} this This node * @param {Boolean} checked */ - "checkchange", + 'checkchange', + /** + * @event beforedblclick + * Fires before double click processing on a node. Return false to cancel the default action. + * @param {Node} node The node + * @param {Ext.EventObject} e The event object + */ + 'beforedblclick', /** * @event dblclick * Fires when a node is double clicked * @param {Node} node The node * @param {Ext.EventObject} e The event object */ - "dblclick", + 'dblclick', + /** + * @event containerdblclick + * Fires when the tree container is double clicked + * @param {Tree} this + * @param {Ext.EventObject} e The event object + */ + 'containerdblclick', /** * @event contextmenu * Fires when a node is right clicked. To display a context menu in response to this @@ -361,13 +390,20 @@ new Ext.tree.TreePanel({ * @param {Node} node The node * @param {Ext.EventObject} e The event object */ - "contextmenu", + 'contextmenu', + /** + * @event containercontextmenu + * Fires when the tree container is right clicked + * @param {Tree} this + * @param {Ext.EventObject} e The event object + */ + 'containercontextmenu', /** * @event beforechildrenrendered * Fires right before the child nodes for a node are rendered * @param {Node} node The node */ - "beforechildrenrendered", + 'beforechildrenrendered', /** * @event startdrag * Fires when a node starts being dragged @@ -375,7 +411,7 @@ new Ext.tree.TreePanel({ * @param {Ext.tree.TreeNode} node * @param {event} e The raw browser event */ - "startdrag", + 'startdrag', /** * @event enddrag * Fires when a drag operation is complete @@ -383,7 +419,7 @@ new Ext.tree.TreePanel({ * @param {Ext.tree.TreeNode} node * @param {event} e The raw browser event */ - "enddrag", + 'enddrag', /** * @event dragdrop * Fires when a dragged node is dropped on a valid DD target @@ -392,7 +428,7 @@ new Ext.tree.TreePanel({ * @param {DD} dd The dd it was dropped on * @param {event} e The raw browser event */ - "dragdrop", + 'dragdrop', /** * @event beforenodedrop * Fires when a DD object is dropped on a node in this tree for preprocessing. Return false to cancel the drop. The dropEvent @@ -408,11 +444,11 @@ new Ext.tree.TreePanel({ * to be inserted by setting them on this object. *

  • cancel - Set this to true to cancel the drop.
  • *
  • dropStatus - If the default drop action is cancelled but the drop is valid, setting this to true - * will prevent the animated "repair" from appearing.
  • + * will prevent the animated 'repair' from appearing. * * @param {Object} dropEvent */ - "beforenodedrop", + 'beforenodedrop', /** * @event nodedrop * Fires after a DD object is dropped on a node in this tree. The dropEvent @@ -428,7 +464,7 @@ new Ext.tree.TreePanel({ * * @param {Object} dropEvent */ - "nodedrop", + 'nodedrop', /** * @event nodedragover * Fires when a tree node is being targeted for a drag drop, return false to signal drop not allowed. The dragOverEvent @@ -445,10 +481,10 @@ new Ext.tree.TreePanel({ * * @param {Object} dragOverEvent */ - "nodedragover" + 'nodedragover' ); if(this.singleExpand){ - this.on("beforeexpandnode", this.restrictExpand, this); + this.on('beforeexpandnode', this.restrictExpand, this); } }, @@ -517,7 +553,7 @@ new Ext.tree.TreePanel({ // private toString : function(){ - return "[Tree"+(this.id?" "+this.id:"")+"]"; + return '[Tree'+(this.id?' '+this.id:'')+']'; }, // private @@ -532,7 +568,7 @@ new Ext.tree.TreePanel({ }, /** - * Retrieve an array of checked nodes, or an array of a specific attribute of checked nodes (e.g. "id") + * Retrieve an array of checked nodes, or an array of a specific attribute of checked nodes (e.g. 'id') * @param {String} attribute (optional) Defaults to null (return the actual nodes) * @param {TreeNode} startNode (optional) The node to start from, defaults to the root * @return {Array} @@ -549,14 +585,6 @@ new Ext.tree.TreePanel({ return r; }, - /** - * Returns the container element for this TreePanel. - * @return {Element} The container element for this TreePanel. - */ - getEl : function(){ - return this.el; - }, - /** * Returns the default {@link Ext.tree.TreeLoader} for this TreePanel. * @return {Ext.tree.TreeLoader} The TreeLoader for this TreePanel. @@ -598,7 +626,7 @@ new Ext.tree.TreePanel({ * (bSuccess, oLastNode) where bSuccess is if the expand was successful and oLastNode is the last node that was expanded. */ expandPath : function(path, attr, callback){ - attr = attr || "id"; + attr = attr || 'id'; var keys = path.split(this.pathSeparator); var curNode = this.root; if(curNode.attributes[attr] != keys[1]){ // invalid root @@ -636,10 +664,10 @@ new Ext.tree.TreePanel({ * (bSuccess, oSelNode) where bSuccess is if the selection was successful and oSelNode is the selected node. */ selectPath : function(path, attr, callback){ - attr = attr || "id"; - var keys = path.split(this.pathSeparator); - var v = keys.pop(); - if(keys.length > 0){ + attr = attr || 'id'; + var keys = path.split(this.pathSeparator), + v = keys.pop(); + if(keys.length > 1){ var f = function(success, node){ if(success && node){ var n = node.findChild(attr, v); @@ -678,9 +706,9 @@ new Ext.tree.TreePanel({ onRender : function(ct, position){ Ext.tree.TreePanel.superclass.onRender.call(this, ct, position); this.el.addClass('x-tree'); - this.innerCt = this.body.createChild({tag:"ul", - cls:"x-tree-root-ct " + - (this.useArrows ? 'x-tree-arrows' : this.lines ? "x-tree-lines" : "x-tree-no-lines")}); + this.innerCt = this.body.createChild({tag:'ul', + cls:'x-tree-root-ct ' + + (this.useArrows ? 'x-tree-arrows' : this.lines ? 'x-tree-lines' : 'x-tree-no-lines')}); }, // private @@ -697,7 +725,7 @@ new Ext.tree.TreePanel({ * @type Ext.tree.TreeDropZone */ this.dropZone = new Ext.tree.TreeDropZone(this, this.dropConfig || { - ddGroup: this.ddGroup || "TreeDD", appendOnly: this.ddAppendOnly === true + ddGroup: this.ddGroup || 'TreeDD', appendOnly: this.ddAppendOnly === true }); } if((this.enableDD || this.enableDrag) && !this.dragZone){ @@ -707,7 +735,7 @@ new Ext.tree.TreePanel({ * @type Ext.tree.TreeDragZone */ this.dragZone = new Ext.tree.TreeDragZone(this, this.dragConfig || { - ddGroup: this.ddGroup || "TreeDD", + ddGroup: this.ddGroup || 'TreeDD', scroll: this.ddScroll }); } @@ -723,20 +751,14 @@ new Ext.tree.TreePanel({ } }, - onDestroy : function(){ + beforeDestroy : function(){ if(this.rendered){ - this.body.removeAllListeners(); Ext.dd.ScrollManager.unregister(this.body); - if(this.dropZone){ - this.dropZone.unreg(); - } - if(this.dragZone){ - this.dragZone.unreg(); - } + Ext.destroy(this.dropZone, this.dragZone); } - this.root.destroy(); - this.nodeHash = null; - Ext.tree.TreePanel.superclass.onDestroy.call(this); + Ext.destroy(this.root, this.loader); + this.nodeHash = this.root = this.loader = null; + Ext.tree.TreePanel.superclass.beforeDestroy.call(this); } /** @@ -922,14 +944,21 @@ Ext.reg('treepanel', Ext.tree.TreePanel);Ext.tree.TreeEventModel = function(tree Ext.tree.TreeEventModel.prototype = { initEvents : function(){ - var el = this.tree.getTreeEl(); - el.on('click', this.delegateClick, this); - if(this.tree.trackMouseOver !== false){ - this.tree.innerCt.on('mouseover', this.delegateOver, this); - this.tree.innerCt.on('mouseout', this.delegateOut, this); + var t = this.tree; + + if(t.trackMouseOver !== false){ + t.mon(t.innerCt, { + scope: this, + mouseover: this.delegateOver, + mouseout: this.delegateOut + }); } - el.on('dblclick', this.delegateDblClick, this); - el.on('contextmenu', this.delegateContextMenu, this); + t.mon(t.getTreeEl(), { + scope: this, + click: this.delegateClick, + dblclick: this.delegateDblClick, + contextmenu: this.delegateContextMenu + }); }, getNode : function(e){ @@ -998,32 +1027,42 @@ Ext.tree.TreeEventModel.prototype = { }, delegateClick : function(e, t){ - if(!this.beforeEvent(e)){ - return; - } - - if(e.getTarget('input[type=checkbox]', 1)){ - this.onCheckboxClick(e, this.getNode(e)); - } - else if(e.getTarget('.x-tree-ec-icon', 1)){ - this.onIconClick(e, this.getNode(e)); - } - else if(this.getNodeTarget(e)){ - this.onNodeClick(e, this.getNode(e)); + if(this.beforeEvent(e)){ + if(e.getTarget('input[type=checkbox]', 1)){ + this.onCheckboxClick(e, this.getNode(e)); + }else if(e.getTarget('.x-tree-ec-icon', 1)){ + this.onIconClick(e, this.getNode(e)); + }else if(this.getNodeTarget(e)){ + this.onNodeClick(e, this.getNode(e)); + }else{ + this.onContainerEvent(e, 'click'); + } } }, delegateDblClick : function(e, t){ - if(this.beforeEvent(e) && this.getNodeTarget(e)){ - this.onNodeDblClick(e, this.getNode(e)); + if(this.beforeEvent(e)){ + if(this.getNodeTarget(e)){ + this.onNodeDblClick(e, this.getNode(e)); + }else{ + this.onContainerEvent(e, 'dblclick'); + } } }, delegateContextMenu : function(e, t){ - if(this.beforeEvent(e) && this.getNodeTarget(e)){ - this.onNodeContextMenu(e, this.getNode(e)); + if(this.beforeEvent(e)){ + if(this.getNodeTarget(e)){ + this.onNodeContextMenu(e, this.getNode(e)); + }else{ + this.onContainerEvent(e, 'contextmenu'); + } } }, + + onContainerEvent: function(e, type){ + this.tree.fireEvent('container' + type, this.tree, e); + }, onNodeClick : function(e, node){ node.ui.onClick(e); @@ -1092,7 +1131,7 @@ Ext.tree.DefaultSelectionModel = function(config){ * @param {DefaultSelectionModel} this * @param {TreeNode} node the new selection */ - "selectionchange", + 'selectionchange', /** * @event beforeselect @@ -1101,7 +1140,7 @@ Ext.tree.DefaultSelectionModel = function(config){ * @param {TreeNode} node the new selection * @param {TreeNode} node the old selection */ - "beforeselect" + 'beforeselect' ); Ext.apply(this, config); @@ -1111,8 +1150,8 @@ Ext.tree.DefaultSelectionModel = function(config){ Ext.extend(Ext.tree.DefaultSelectionModel, Ext.util.Observable, { init : function(tree){ this.tree = tree; - tree.getTreeEl().on("keydown", this.onKeyDown, this); - tree.on("click", this.onNodeClick, this); + tree.mon(tree.getTreeEl(), 'keydown', this.onKeyDown, this); + tree.on('click', this.onNodeClick, this); }, onNodeClick : function(node, e){ @@ -1124,17 +1163,21 @@ Ext.extend(Ext.tree.DefaultSelectionModel, Ext.util.Observable, { * @param {TreeNode} node The node to select * @return {TreeNode} The selected node */ - select : function(node){ + select : function(node, /* private*/ selectNextNode){ + // If node is hidden, select the next node in whatever direction was being moved in. + if (!Ext.fly(node.ui.wrap).isVisible() && selectNextNode) { + return selectNextNode.call(this, node); + } var last = this.selNode; if(node == last){ node.ui.onSelectedChange(true); }else if(this.fireEvent('beforeselect', this, node, last) !== false){ - if(last){ + if(last && last.ui){ last.ui.onSelectedChange(false); } this.selNode = node; node.ui.onSelectedChange(true); - this.fireEvent("selectionchange", this, node, last); + this.fireEvent('selectionchange', this, node, last); } return node; }, @@ -1142,22 +1185,26 @@ Ext.extend(Ext.tree.DefaultSelectionModel, Ext.util.Observable, { /** * Deselect a node. * @param {TreeNode} node The node to unselect + * @param {Boolean} silent True to stop the selectionchange event from firing. */ - unselect : function(node){ + unselect : function(node, silent){ if(this.selNode == node){ - this.clearSelections(); + this.clearSelections(silent); } }, /** * Clear all selections + * @param {Boolean} silent True to stop the selectionchange event from firing. */ - clearSelections : function(){ + clearSelections : function(silent){ var n = this.selNode; if(n){ n.ui.onSelectedChange(false); this.selNode = null; - this.fireEvent("selectionchange", this, null); + if(silent !== true){ + this.fireEvent('selectionchange', this, null); + } } return n; }, @@ -1183,24 +1230,24 @@ Ext.extend(Ext.tree.DefaultSelectionModel, Ext.util.Observable, { * Selects the node above the selected node in the tree, intelligently walking the nodes * @return TreeNode The new selection */ - selectPrevious : function(){ - var s = this.selNode || this.lastSelNode; - if(!s){ + selectPrevious : function(/* private */ s){ + if(!(s = s || this.selNode || this.lastSelNode)){ return null; } + // Here we pass in the current function to select to indicate the direction we're moving var ps = s.previousSibling; if(ps){ if(!ps.isExpanded() || ps.childNodes.length < 1){ - return this.select(ps); + return this.select(ps, this.selectPrevious); } else{ var lc = ps.lastChild; - while(lc && lc.isExpanded() && lc.childNodes.length > 0){ + while(lc && lc.isExpanded() && Ext.fly(lc.ui.wrap).isVisible() && lc.childNodes.length > 0){ lc = lc.lastChild; } - return this.select(lc); + return this.select(lc, this.selectPrevious); } } else if(s.parentNode && (this.tree.rootVisible || !s.parentNode.isRoot)){ - return this.select(s.parentNode); + return this.select(s.parentNode, this.selectPrevious); } return null; }, @@ -1209,20 +1256,20 @@ Ext.extend(Ext.tree.DefaultSelectionModel, Ext.util.Observable, { * Selects the node above the selected node in the tree, intelligently walking the nodes * @return TreeNode The new selection */ - selectNext : function(){ - var s = this.selNode || this.lastSelNode; - if(!s){ + selectNext : function(/* private */ s){ + if(!(s = s || this.selNode || this.lastSelNode)){ return null; } - if(s.firstChild && s.isExpanded()){ - return this.select(s.firstChild); + // Here we pass in the current function to select to indicate the direction we're moving + if(s.firstChild && s.isExpanded() && Ext.fly(s.ui.wrap).isVisible()){ + return this.select(s.firstChild, this.selectNext); }else if(s.nextSibling){ - return this.select(s.nextSibling); + return this.select(s.nextSibling, this.selectNext); }else if(s.parentNode){ var newS = null; s.parentNode.bubble(function(){ if(this.nextSibling){ - newS = this.getOwnerTree().selModel.select(this.nextSibling); + newS = this.getOwnerTree().selModel.select(this.nextSibling, this.selectNext); return false; } }); @@ -1285,7 +1332,7 @@ Ext.tree.MultiSelectionModel = function(config){ * @param {MultiSelectionModel} this * @param {Array} nodes Array of the selected nodes */ - "selectionchange" + 'selectionchange' ); Ext.apply(this, config); Ext.tree.MultiSelectionModel.superclass.constructor.call(this); @@ -1294,8 +1341,8 @@ Ext.tree.MultiSelectionModel = function(config){ Ext.extend(Ext.tree.MultiSelectionModel, Ext.util.Observable, { init : function(tree){ this.tree = tree; - tree.getTreeEl().on("keydown", this.onKeyDown, this); - tree.on("click", this.onNodeClick, this); + tree.mon(tree.getTreeEl(), 'keydown', this.onKeyDown, this); + tree.on('click', this.onNodeClick, this); }, onNodeClick : function(node, e){ @@ -1325,7 +1372,7 @@ Ext.extend(Ext.tree.MultiSelectionModel, Ext.util.Observable, { this.selMap[node.id] = node; this.lastSelNode = node; node.ui.onSelectedChange(true); - this.fireEvent("selectionchange", this, this.selNodes); + this.fireEvent('selectionchange', this, this.selNodes); return node; }, @@ -1342,7 +1389,7 @@ Ext.extend(Ext.tree.MultiSelectionModel, Ext.util.Observable, { this.selNodes.splice(index, 1); } delete this.selMap[node.id]; - this.fireEvent("selectionchange", this, this.selNodes); + this.fireEvent('selectionchange', this, this.selNodes); } }, @@ -1358,7 +1405,7 @@ Ext.extend(Ext.tree.MultiSelectionModel, Ext.util.Observable, { this.selNodes = []; this.selMap = {}; if(suppressEvent !== true){ - this.fireEvent("selectionchange", this, this.selNodes); + this.fireEvent('selectionchange', this, this.selNodes); } } }, @@ -1798,9 +1845,10 @@ Ext.extend(Ext.data.Node, Ext.util.Observable, { /** * Removes a child node from this node. * @param {Node} node The node to remove + * @param {Boolean} destroy true to destroy the node upon removal. Defaults to false. * @return {Node} The removed node */ - removeChild : function(node){ + removeChild : function(node, destroy){ var index = this.childNodes.indexOf(node); if(index == -1){ return false; @@ -1828,14 +1876,35 @@ Ext.extend(Ext.data.Node, Ext.util.Observable, { this.setLastChild(node.previousSibling); } - node.setOwnerTree(null); - // clear any references from the node - node.parentNode = null; - node.previousSibling = null; - node.nextSibling = null; + node.clear(); this.fireEvent("remove", this.ownerTree, this, node); + if(destroy){ + node.destroy(); + } return node; }, + + // private + clear : function(destroy){ + // clear any references from the node + this.setOwnerTree(null, destroy); + this.parentNode = this.previousSibling = this.nextSibling = null + if(destroy){ + this.firstChild = this.lastChild = null; + } + }, + + /** + * Destroys the node. + */ + destroy : function(){ + this.purgeListeners(); + this.clear(true); + Ext.each(this.childNodes, function(n){ + n.destroy(); + }); + this.childNodes = null; + }, /** * Inserts the first node before the second node in this nodes childNodes collection. @@ -1895,10 +1964,11 @@ Ext.extend(Ext.data.Node, Ext.util.Observable, { /** * Removes this node from its parent + * @param {Boolean} destroy true to destroy the node upon removal. Defaults to false. * @return {Node} this */ - remove : function(){ - this.parentNode.removeChild(this); + remove : function(destroy){ + this.parentNode.removeChild(this, destroy); return this; }, @@ -1967,16 +2037,18 @@ Ext.extend(Ext.data.Node, Ext.util.Observable, { }, // private - setOwnerTree : function(tree){ + setOwnerTree : function(tree, destroy){ // if it is a move, we need to update everyone if(tree != this.ownerTree){ if(this.ownerTree){ this.ownerTree.unregisterNode(this); } this.ownerTree = tree; - var cs = this.childNodes; - for(var i = 0, len = cs.length; i < len; i++) { - cs[i].setOwnerTree(tree); + // If we're destroying, we don't need to recurse since it will be called on each child node + if(destroy !== true){ + Ext.each(this.childNodes, function(n){ + n.setOwnerTree(tree); + }); } if(tree){ tree.registerNode(this); @@ -1994,7 +2066,7 @@ Ext.extend(Ext.data.Node, Ext.util.Observable, { if(t){ t.unregisterNode(this); } - this.id = id; + this.id = this.attributes.id = id; if(t){ t.registerNode(this); } @@ -2023,13 +2095,12 @@ Ext.extend(Ext.data.Node, Ext.util.Observable, { }, /** - * Bubbles up the tree from this node, calling the specified function with each node. The scope (this) of - * function call will be the scope provided or the current node. The arguments to the function + * Bubbles up the tree from this node, calling the specified function with each node. The arguments to the function * will be the args provided or the current node. If the function returns false at any point, * the bubble is stopped. * @param {Function} fn The function to call - * @param {Object} scope (optional) The scope of the function (defaults to current node) - * @param {Array} args (optional) The args to call the function with (default to passing the current node) + * @param {Object} scope (optional) The scope (this reference) in which the function is executed. Defaults to the current Node. + * @param {Array} args (optional) The args to call the function with (default to passing the current Node) */ bubble : function(fn, scope, args){ var p = this; @@ -2042,13 +2113,12 @@ Ext.extend(Ext.data.Node, Ext.util.Observable, { }, /** - * Cascades down the tree from this node, calling the specified function with each node. The scope (this) of - * function call will be the scope provided or the current node. The arguments to the function + * Cascades down the tree from this node, calling the specified function with each node. The arguments to the function * will be the args provided or the current node. If the function returns false at any point, * the cascade is stopped on that branch. * @param {Function} fn The function to call - * @param {Object} scope (optional) The scope of the function (defaults to current node) - * @param {Array} args (optional) The args to call the function with (default to passing the current node) + * @param {Object} scope (optional) The scope (this reference) in which the function is executed. Defaults to the current Node. + * @param {Array} args (optional) The args to call the function with (default to passing the current Node) */ cascade : function(fn, scope, args){ if(fn.apply(scope || this, args || [this]) !== false){ @@ -2060,13 +2130,12 @@ Ext.extend(Ext.data.Node, Ext.util.Observable, { }, /** - * Interates the child nodes of this node, calling the specified function with each node. The scope (this) of - * function call will be the scope provided or the current node. The arguments to the function + * Interates the child nodes of this node, calling the specified function with each node. The arguments to the function * will be the args provided or the current node. If the function returns false at any point, * the iteration stops. * @param {Function} fn The function to call - * @param {Object} scope (optional) The scope of the function (defaults to current node) - * @param {Array} args (optional) The args to call the function with (default to passing the current node) + * @param {Object} scope (optional) The scope (this reference) in which the function is executed. Defaults to the current Node in the iteration. + * @param {Array} args (optional) The args to call the function with (default to passing the current Node) */ eachChild : function(fn, scope, args){ var cs = this.childNodes; @@ -2094,10 +2163,9 @@ Ext.extend(Ext.data.Node, Ext.util.Observable, { }, /** - * Finds the first child by a custom function. The child matches if the function passed - * returns true. - * @param {Function} fn - * @param {Object} scope (optional) + * Finds the first child by a custom function. The child matches if the function passed returns true. + * @param {Function} fn A function which must return true if the passed Node is the required Node. + * @param {Object} scope (optional) The scope (this reference) in which the function is executed. Defaults to the Node being tested. * @return {Node} The found child or null if none was found */ findChildBy : function(fn, scope){ @@ -2111,9 +2179,9 @@ Ext.extend(Ext.data.Node, Ext.util.Observable, { }, /** - * Sorts this nodes children using the supplied sort function - * @param {Function} fn - * @param {Object} scope (optional) + * Sorts this nodes children using the supplied sort function. + * @param {Function} fn A function which, when passed two Nodes, returns -1, 0 or 1 depending upon required sort order. + * @param {Object} scope (optional)The scope (this reference) in which the function is executed. Defaults to the browser window. */ sort : function(fn, scope){ var cs = this.childNodes; @@ -2188,13 +2256,13 @@ Ext.extend(Ext.data.Node, Ext.util.Observable, { * @cfg {Boolean} draggable True to make this node draggable (defaults to false) * @cfg {Boolean} isTarget False to not allow this node to act as a drop target (defaults to true) * @cfg {Boolean} allowChildren False to not allow this node to have child nodes (defaults to true) - * @cfg {Boolean} editable False to not allow this node to be edited by an (@link Ext.tree.TreeEditor} (defaults to true) + * @cfg {Boolean} editable False to not allow this node to be edited by an {@link Ext.tree.TreeEditor} (defaults to true) * @constructor * @param {Object/String} attributes The attributes/config for the node or just a string with the text for the node */ Ext.tree.TreeNode = function(attributes){ attributes = attributes || {}; - if(typeof attributes == "string"){ + if(Ext.isString(attributes)){ attributes = {text: attributes}; } this.childrenRendered = false; @@ -2206,7 +2274,7 @@ Ext.tree.TreeNode = function(attributes){ this.allowChildren = attributes.allowChildren !== false && attributes.allowDrop !== false; /** - * Read-only. The text for this node. To change it use setText(). + * Read-only. The text for this node. To change it use {@link #setText}. * @type String */ this.text = attributes.text; @@ -2229,7 +2297,7 @@ Ext.tree.TreeNode = function(attributes){ * @param {String} text The new text * @param {String} oldText The old text */ - "textchange", + 'textchange', /** * @event beforeexpand * Fires before this node is expanded, return false to cancel. @@ -2237,7 +2305,7 @@ Ext.tree.TreeNode = function(attributes){ * @param {Boolean} deep * @param {Boolean} anim */ - "beforeexpand", + 'beforeexpand', /** * @event beforecollapse * Fires before this node is collapsed, return false to cancel. @@ -2245,67 +2313,74 @@ Ext.tree.TreeNode = function(attributes){ * @param {Boolean} deep * @param {Boolean} anim */ - "beforecollapse", + 'beforecollapse', /** * @event expand * Fires when this node is expanded * @param {Node} this This node */ - "expand", + 'expand', /** * @event disabledchange * Fires when the disabled status of this node changes * @param {Node} this This node * @param {Boolean} disabled */ - "disabledchange", + 'disabledchange', /** * @event collapse * Fires when this node is collapsed * @param {Node} this This node */ - "collapse", + 'collapse', /** * @event beforeclick * Fires before click processing. Return false to cancel the default action. * @param {Node} this This node * @param {Ext.EventObject} e The event object */ - "beforeclick", + 'beforeclick', /** * @event click * Fires when this node is clicked * @param {Node} this This node * @param {Ext.EventObject} e The event object */ - "click", + 'click', /** * @event checkchange * Fires when a node with a checkbox's checked property changes * @param {Node} this This node * @param {Boolean} checked */ - "checkchange", + 'checkchange', + /** + * @event beforedblclick + * Fires before double click processing. Return false to cancel the default action. + * @param {Node} this This node + * @param {Ext.EventObject} e The event object + */ + 'beforedblclick', /** * @event dblclick * Fires when this node is double clicked * @param {Node} this This node * @param {Ext.EventObject} e The event object */ - "dblclick", + 'dblclick', /** * @event contextmenu * Fires when this node is right clicked * @param {Node} this This node * @param {Ext.EventObject} e The event object */ - "contextmenu", + 'contextmenu', /** * @event beforechildrenrendered * Fires right before the child nodes for this node are rendered * @param {Node} this This node */ - "beforechildrenrendered" + 'beforechildrenrendered' ); var uiClass = this.attributes.uiProvider || this.defaultUI || Ext.tree.TreeNodeUI; @@ -2317,7 +2392,7 @@ Ext.tree.TreeNode = function(attributes){ this.ui = new uiClass(this); }; Ext.extend(Ext.tree.TreeNode, Ext.data.Node, { - preventHScroll: true, + preventHScroll : true, /** * Returns true if this node is expanded * @return {Boolean} @@ -2338,7 +2413,7 @@ Ext.extend(Ext.tree.TreeNode, Ext.data.Node, { getLoader : function(){ var owner; - return this.loader || ((owner = this.getOwnerTree()) && owner.loader ? owner.loader : new Ext.tree.TreeLoader()); + return this.loader || ((owner = this.getOwnerTree()) && owner.loader ? owner.loader : (this.loader = new Ext.tree.TreeLoader())); }, // private override @@ -2380,11 +2455,11 @@ Ext.extend(Ext.tree.TreeNode, Ext.data.Node, { }, // private override - removeChild : function(node){ + removeChild : function(node, destroy){ this.ownerTree.getSelectionModel().unselect(node); Ext.tree.TreeNode.superclass.removeChild.apply(this, arguments); // if it's been rendered remove dom node - if(this.childrenRendered){ + if(node.ui.rendered){ node.ui.remove(); } if(this.childNodes.length < 1){ @@ -2400,7 +2475,7 @@ Ext.extend(Ext.tree.TreeNode, Ext.data.Node, { // private override insertBefore : function(node, refNode){ - if(!node.render){ + if(!node.render){ node = this.getLoader().createNode(node); } var newNode = Ext.tree.TreeNode.superclass.insertBefore.call(this, node, refNode); @@ -2417,26 +2492,32 @@ Ext.extend(Ext.tree.TreeNode, Ext.data.Node, { */ setText : function(text){ var oldText = this.text; - this.text = text; - this.attributes.text = text; + this.text = this.attributes.text = text; if(this.rendered){ // event without subscribing this.ui.onTextChange(this, text, oldText); } - this.fireEvent("textchange", this, text, oldText); + this.fireEvent('textchange', this, text, oldText); }, /** * Triggers selection of this node */ select : function(){ - this.getOwnerTree().getSelectionModel().select(this); + var t = this.getOwnerTree(); + if(t){ + t.getSelectionModel().select(this); + } }, /** * Triggers deselection of this node + * @param {Boolean} silent (optional) True to stop selection change events from firing. */ - unselect : function(){ - this.getOwnerTree().getSelectionModel().unselect(this); + unselect : function(silent){ + var t = this.getOwnerTree(); + if(t){ + t.getSelectionModel().unselect(this, silent); + } }, /** @@ -2444,7 +2525,8 @@ Ext.extend(Ext.tree.TreeNode, Ext.data.Node, { * @return {Boolean} */ isSelected : function(){ - return this.getOwnerTree().getSelectionModel().isSelected(this); + var t = this.getOwnerTree(); + return t ? t.getSelectionModel().isSelected(this) : false; }, /** @@ -2454,11 +2536,11 @@ Ext.extend(Ext.tree.TreeNode, Ext.data.Node, { * @param {Function} callback (optional) A callback to be called when * expanding this node completes (does not wait for deep expand to complete). * Called with 1 parameter, this node. - * @param {Object} scope (optional) The scope in which to execute the callback. + * @param {Object} scope (optional) The scope (this reference) in which the callback is executed. Defaults to this TreeNode. */ expand : function(deep, anim, callback, scope){ if(!this.expanded){ - if(this.fireEvent("beforeexpand", this, deep, anim) === false){ + if(this.fireEvent('beforeexpand', this, deep, anim) === false){ return; } if(!this.childrenRendered){ @@ -2467,7 +2549,7 @@ Ext.extend(Ext.tree.TreeNode, Ext.data.Node, { this.expanded = true; if(!this.isHiddenRoot() && (this.getOwnerTree().animate && anim !== false) || anim){ this.ui.animExpand(function(){ - this.fireEvent("expand", this); + this.fireEvent('expand', this); this.runCallback(callback, scope || this, [this]); if(deep === true){ this.expandChildNodes(true); @@ -2476,7 +2558,7 @@ Ext.extend(Ext.tree.TreeNode, Ext.data.Node, { return; }else{ this.ui.expand(); - this.fireEvent("expand", this); + this.fireEvent('expand', this); this.runCallback(callback, scope || this, [this]); } }else{ @@ -2486,8 +2568,8 @@ Ext.extend(Ext.tree.TreeNode, Ext.data.Node, { this.expandChildNodes(true); } }, - - runCallback: function(cb, scope, args){ + + runCallback : function(cb, scope, args){ if(Ext.isFunction(cb)){ cb.apply(scope, args); } @@ -2504,17 +2586,17 @@ Ext.extend(Ext.tree.TreeNode, Ext.data.Node, { * @param {Function} callback (optional) A callback to be called when * expanding this node completes (does not wait for deep expand to complete). * Called with 1 parameter, this node. - * @param {Object} scope (optional) The scope in which to execute the callback. + * @param {Object} scope (optional) The scope (this reference) in which the callback is executed. Defaults to this TreeNode. */ collapse : function(deep, anim, callback, scope){ if(this.expanded && !this.isHiddenRoot()){ - if(this.fireEvent("beforecollapse", this, deep, anim) === false){ + if(this.fireEvent('beforecollapse', this, deep, anim) === false){ return; } this.expanded = false; if((this.getOwnerTree().animate && anim !== false) || anim){ this.ui.animCollapse(function(){ - this.fireEvent("collapse", this); + this.fireEvent('collapse', this); this.runCallback(callback, scope || this, [this]); if(deep === true){ this.collapseChildNodes(true); @@ -2523,7 +2605,7 @@ Ext.extend(Ext.tree.TreeNode, Ext.data.Node, { return; }else{ this.ui.collapse(); - this.fireEvent("collapse", this); + this.fireEvent('collapse', this); this.runCallback(callback, scope || this, [this]); } }else if(!this.expanded){ @@ -2567,7 +2649,7 @@ Ext.extend(Ext.tree.TreeNode, Ext.data.Node, { * Ensures all parent nodes are expanded, and if necessary, scrolls * the node into view. * @param {Function} callback (optional) A function to call when the node has been made visible. - * @param {Object} scope (optional) The scope in which to execute the callback. + * @param {Object} scope (optional) The scope (this reference) in which the callback is executed. Defaults to this TreeNode. */ ensureVisible : function(callback, scope){ var tree = this.getOwnerTree(); @@ -2609,7 +2691,7 @@ Ext.extend(Ext.tree.TreeNode, Ext.data.Node, { if(this.rendered && this.ui.onDisableChange){ // event without subscribing this.ui.onDisableChange(this, true); } - this.fireEvent("disabledchange", this, true); + this.fireEvent('disabledchange', this, true); }, /** @@ -2620,13 +2702,13 @@ Ext.extend(Ext.tree.TreeNode, Ext.data.Node, { if(this.rendered && this.ui.onDisableChange){ // event without subscribing this.ui.onDisableChange(this, false); } - this.fireEvent("disabledchange", this, false); + this.fireEvent('disabledchange', this, false); }, // private renderChildren : function(suppressEvent){ if(suppressEvent !== false){ - this.fireEvent("beforechildrenrendered", this); + this.fireEvent('beforechildrenrendered', this); } var cs = this.childNodes; for(var i = 0, len = cs.length; i < len; i++){ @@ -2685,19 +2767,14 @@ Ext.extend(Ext.tree.TreeNode, Ext.data.Node, { }, destroy : function(){ - if(this.childNodes){ - for(var i = 0,l = this.childNodes.length; i < l; i++){ - this.childNodes[i].destroy(); - } - this.childNodes = null; - } - if(this.ui.destroy){ - this.ui.destroy(); - } + this.unselect(true); + Ext.tree.TreeNode.superclass.destroy.call(this); + Ext.destroy(this.ui, this.loader); + this.ui = this.loader = null; }, - + // private - onIdChange: function(id){ + onIdChange : function(id){ this.ui.onIdChange(id); } }); @@ -2793,7 +2870,7 @@ Ext.extend(Ext.tree.AsyncTreeNode, Ext.tree.TreeNode, { /** * Trigger a reload for this node * @param {Function} callback - * @param {Object} scope (optional) The scope in which to execute the callback. + * @param {Object} scope (optional) The scope (this reference) in which the callback is executed. Defaults to this Node. */ reload : function(callback, scope){ this.collapse(false, false); @@ -2859,9 +2936,9 @@ Ext.tree.TreeNodeUI.prototype = { // private onDisableChange : function(node, state){ this.disabled = state; - if (this.checkbox) { - this.checkbox.disabled = state; - } + if (this.checkbox) { + this.checkbox.disabled = state; + } if(state){ this.addClass("x-tree-node-disabled"); }else{ @@ -2939,10 +3016,7 @@ Ext.tree.TreeNodeUI.prototype = { this.node.on("move", this.onMove, this); if(this.node.disabled){ - this.addClass("x-tree-node-disabled"); - if (this.checkbox) { - this.checkbox.disabled = true; - } + this.onDisableChange(this.node, true); } if(this.node.hidden){ this.hide(); @@ -3027,13 +3101,15 @@ Ext.tree.TreeNodeUI.prototype = { if(this.disabled){ return; } - if(this.checkbox){ - this.toggleCheck(); - } - if(!this.animating && this.node.isExpandable()){ - this.node.toggle(); + if(this.fireEvent("beforedblclick", this.node, e) !== false){ + if(this.checkbox){ + this.toggleCheck(); + } + if(!this.animating && this.node.isExpandable()){ + this.node.toggle(); + } + this.fireEvent("dblclick", this.node, e); } - this.fireEvent("dblclick", this.node, e); }, onOver : function(e){ @@ -3047,8 +3123,8 @@ Ext.tree.TreeNodeUI.prototype = { // private onCheckChange : function(){ var checked = this.checkbox.checked; - // fix for IE6 - this.checkbox.defaultChecked = checked; + // fix for IE6 + this.checkbox.defaultChecked = checked; this.node.attributes.checked = checked; this.fireEvent('checkchange', this.node, checked); }, @@ -3175,7 +3251,10 @@ Ext.tree.TreeNodeUI.prototype = { return this.ctNode; }, - // private +/** + * Returns the element which encapsulates this node. + * @return {HtmlElement} The DOM element. The default implementation uses a <li>. + */ getEl : function(){ return this.wrap; }, @@ -3238,10 +3317,10 @@ Ext.tree.TreeNodeUI.prototype = { // add some indent caching, this helps performance when rendering a large tree this.indentMarkup = n.parentNode ? n.parentNode.ui.getChildIndent() : ''; - var cb = typeof a.checked == 'boolean'; - - var href = a.href ? a.href : Ext.isGecko ? "" : "#"; - var buf = ['
  • ', + var cb = Ext.isBoolean(a.checked), + nel, + href = a.href ? a.href : Ext.isGecko ? "" : "#", + buf = ['
  • ', '',this.indentMarkup,"", '', '', @@ -3251,7 +3330,6 @@ Ext.tree.TreeNodeUI.prototype = { '', "
  • "].join(''); - var nel; if(bulkRender !== true && n.nextSibling && (nel = n.nextSibling.ui.getEl())){ this.wrap = Ext.DomHelper.insertHtml("beforeBegin", nel, buf); }else{ @@ -3267,8 +3345,8 @@ Ext.tree.TreeNodeUI.prototype = { var index = 3; if(cb){ this.checkbox = cs[3]; - // fix for IE6 - this.checkbox.defaultChecked = this.checkbox.checked; + // fix for IE6 + this.checkbox.defaultChecked = this.checkbox.checked; index++; } this.anchor = cs[index]; @@ -3311,9 +3389,11 @@ Ext.tree.TreeNodeUI.prototype = { // private updateExpandIcon : function(){ if(this.rendered){ - var n = this.node, c1, c2; - var cls = n.isLast() ? "x-tree-elbow-end" : "x-tree-elbow"; - var hasChild = n.hasChildNodes(); + var n = this.node, + c1, + c2, + cls = n.isLast() ? "x-tree-elbow-end" : "x-tree-elbow", + hasChild = n.hasChildNodes(); if(hasChild || n.attributes.expandable){ if(n.expanded){ cls += "-minus"; @@ -3358,8 +3438,8 @@ Ext.tree.TreeNodeUI.prototype = { // private getChildIndent : function(){ if(!this.childIndent){ - var buf = []; - var p = this.node; + var buf = [], + p = this.node; while(p){ if(!p.isRoot || (p.isRoot && p.ownerTree.rootVisible)){ if(!p.isLast()) { @@ -3378,8 +3458,8 @@ Ext.tree.TreeNodeUI.prototype = { // private renderIndent : function(){ if(this.rendered){ - var indent = ""; - var p = this.node.parentNode; + var indent = "", + p = this.node.parentNode; if(p){ indent = p.ui.getChildIndent(); } @@ -3395,23 +3475,14 @@ Ext.tree.TreeNodeUI.prototype = { if(this.elNode){ Ext.dd.Registry.unregister(this.elNode.id); } - delete this.elNode; - delete this.ctNode; - delete this.indentNode; - delete this.ecNode; - delete this.iconNode; - delete this.checkbox; - delete this.anchor; - delete this.textNode; - if (this.holder){ - delete this.wrap; - Ext.removeNode(this.holder); - delete this.holder; - }else{ - Ext.removeNode(this.wrap); - delete this.wrap; - } + Ext.each(['textnode', 'anchor', 'checkbox', 'indentNode', 'ecNode', 'iconNode', 'elNode', 'ctNode', 'wrap', 'holder'], function(el){ + if(this[el]){ + Ext.fly(this[el]).remove(); + delete this[el]; + } + }, this); + delete this.node; } }; @@ -3505,7 +3576,7 @@ Ext.tree.TreeLoader = function(config){ "loadexception" ); Ext.tree.TreeLoader.superclass.constructor.call(this); - if(typeof this.paramOrder == 'string'){ + if(Ext.isString(this.paramOrder)){ this.paramOrder = this.paramOrder.split(/[\s,|]/); } }; @@ -3570,6 +3641,12 @@ paramOrder: 'param1|param2|param' * {@link #paramOrder} nullifies this configuration. */ paramsAsHash: false, + + /** + * @cfg {String} nodeParameter The name of the parameter sent to the server which contains + * the identifier of the node. Defaults to 'node'. + */ + nodeParameter: 'node', /** * @cfg {Function} directFn @@ -3582,8 +3659,10 @@ paramOrder: 'param1|param2|param' * This is called automatically when a node is expanded, but may be used to reload * a node (or append new children if the {@link #clearOnLoad} option is false.) * @param {Ext.tree.TreeNode} node - * @param {Function} callback - * @param (Object) scope + * @param {Function} callback Function to call after the node has been loaded. The + * function is passed the TreeNode which was requested to be loaded. + * @param (Object) scope The cope (this reference) in which the callback is executed. + * defaults to the loaded TreeNode. */ load : function(node, callback, scope){ if(this.clearOnLoad){ @@ -3592,7 +3671,7 @@ paramOrder: 'param1|param2|param' } } if(this.doPreload(node)){ // preloaded json children - this.runCallback(callback, scope || node, []); + this.runCallback(callback, scope || node, [node]); }else if(this.directFn || this.dataUrl || this.url){ this.requestData(node, callback, scope || node); } @@ -3631,13 +3710,9 @@ paramOrder: 'param1|param2|param' } return buf; }else{ - for(var key in bp){ - if(!Ext.isFunction(bp[key])){ - buf.push(encodeURIComponent(key), "=", encodeURIComponent(bp[key]), "&"); - } - } - buf.push("node=", encodeURIComponent(node.id)); - return buf.join(""); + var o = Ext.apply({}, bp); + o[this.nodeParameter] = node.id; + return o; } }, @@ -3702,7 +3777,7 @@ paramOrder: 'param1|param2|param' * Example:
    
     new Ext.tree.TreePanel({
         ...
    -    new Ext.tree.TreeLoader({
    +    loader: new Ext.tree.TreeLoader({
             url: 'dataUrl',
             createNode: function(attr) {
     //          Allow consolidation consignments to have
    @@ -3711,7 +3786,7 @@ new Ext.tree.TreePanel({
                     attr.iconCls = 'x-consol',
                     attr.allowDrop = true;
                 }
    -            return Ext.tree.TreeLoader.prototype.call(this, attr);
    +            return Ext.tree.TreeLoader.prototype.createNode.call(this, attr);
             }
         }),
         ...
    @@ -3724,10 +3799,10 @@ new Ext.tree.TreePanel({
             if(this.baseAttrs){
                 Ext.applyIf(attr, this.baseAttrs);
             }
    -        if(this.applyLoader !== false){
    +        if(this.applyLoader !== false && !attr.loader){
                 attr.loader = this;
             }
    -        if(typeof attr.uiProvider == 'string'){
    +        if(Ext.isString(attr.uiProvider)){
                attr.uiProvider = this.uiProviders[attr.uiProvider] || eval(attr.uiProvider);
             }
             if(attr.nodeType){
    @@ -3769,6 +3844,10 @@ new Ext.tree.TreePanel({
             var a = response.argument;
             this.fireEvent("loadexception", this, a.node, response);
             this.runCallback(a.callback, a.scope || a.node, [a.node]);
    +    },
    +    
    +    destroy : function(){
    +        this.purgeListeners();
         }
     });/**
      * @class Ext.tree.TreeFilter
    @@ -3824,7 +3903,7 @@ Ext.tree.TreeFilter.prototype = {
          * node in the tree (or from the startNode). If the function returns true, the node is kept
          * otherwise it is filtered. If a node is filtered, its children are also filtered.
          * @param {Function} fn The filter function
    -     * @param {Object} scope (optional) The scope of the function (defaults to the current node)
    +     * @param {Object} scope (optional) The scope (this reference) in which the function is executed. Defaults to the current Node.
          */
         filterBy : function(fn, scope, startNode){
             startNode = startNode || this.tree.root;
    @@ -3944,8 +4023,8 @@ Ext.tree.TreeSorter = function(tree, config){
                     return -1;
                 }
             }
    -    	var v1 = sortType ? sortType(n1) : (cs ? n1.attributes[p] : n1.attributes[p].toUpperCase());
    -    	var v2 = sortType ? sortType(n2) : (cs ? n2.attributes[p] : n2.attributes[p].toUpperCase());
    +    	var v1 = sortType ? sortType(n1.attributes[p]) : (cs ? n1.attributes[p] : n1.attributes[p].toUpperCase());
    +    	var v2 = sortType ? sortType(n2.attributes[p]) : (cs ? n2.attributes[p] : n2.attributes[p].toUpperCase());
         	if(v1 < v2){
     			return dsc ? +1 : -1;
     		}else if(v1 > v2){
    @@ -4431,12 +4510,18 @@ Ext.extend(Ext.tree.TreeEditor, Ext.Editor, {
         editDelay : 350,
     
         initEditor : function(tree){
    -        tree.on('beforeclick', this.beforeNodeClick, this);
    -        tree.on('dblclick', this.onNodeDblClick, this);
    -        this.on('complete', this.updateNode, this);
    -        this.on('beforestartedit', this.fitToTree, this);
    +        tree.on({
    +            scope: this,
    +            beforeclick: this.beforeNodeClick,
    +            dblclick: this.onNodeDblClick
    +        });
    +        this.on({
    +            scope: this,
    +            complete: this.updateNode,
    +            beforestartedit: this.fitToTree,
    +            specialkey: this.onSpecialKey
    +        });
             this.on('startedit', this.bindScroll, this, {delay:10});
    -        this.on('specialkey', this.onSpecialKey, this);
         },
     
         // private
    @@ -4518,5 +4603,13 @@ Ext.extend(Ext.tree.TreeEditor, Ext.Editor, {
                 e.stopEvent();
                 this.completeEdit();
             }
    +    },
    +    
    +    onDestroy : function(){
    +        clearTimeout(this.autoEditTimer);
    +        Ext.tree.TreeEditor.superclass.onDestroy.call(this);
    +        var tree = this.tree;
    +        tree.un('beforeclick', this.beforeNodeClick, this);
    +        tree.un('dblclick', this.onNodeDblClick, this);
         }
     });
    \ No newline at end of file