/*!
- * Ext JS Library 3.0.3
+ * Ext JS Library 3.1.0
* Copyright(c) 2006-2009 Ext JS, LLC
* licensing@extjs.com
* http://www.extjs.com/license
* @cfg {Boolean} draggable True to make this node draggable (defaults to false)\r
* @cfg {Boolean} isTarget False to not allow this node to act as a drop target (defaults to true)\r
* @cfg {Boolean} allowChildren False to not allow this node to have child nodes (defaults to true)\r
- * @cfg {Boolean} editable False to not allow this node to be edited by an (@link Ext.tree.TreeEditor} (defaults to true)\r
+ * @cfg {Boolean} editable False to not allow this node to be edited by an {@link Ext.tree.TreeEditor} (defaults to true)\r
* @constructor\r
* @param {Object/String} attributes The attributes/config for the node or just a string with the text for the node\r
*/\r
Ext.tree.TreeNode = function(attributes){\r
attributes = attributes || {};\r
- if(typeof attributes == 'string'){\r
+ if(Ext.isString(attributes)){\r
attributes = {text: attributes};\r
}\r
this.childrenRendered = false;\r
\r
getLoader : function(){\r
var owner;\r
- return this.loader || ((owner = this.getOwnerTree()) && owner.loader ? owner.loader : new Ext.tree.TreeLoader());\r
+ return this.loader || ((owner = this.getOwnerTree()) && owner.loader ? owner.loader : (this.loader = new Ext.tree.TreeLoader()));\r
},\r
\r
// private override\r
},\r
\r
// private override\r
- removeChild : function(node){\r
+ removeChild : function(node, destroy){\r
this.ownerTree.getSelectionModel().unselect(node);\r
Ext.tree.TreeNode.superclass.removeChild.apply(this, arguments);\r
// if it's been rendered remove dom node\r
- if(this.childrenRendered){\r
+ if(node.ui.rendered){\r
node.ui.remove();\r
}\r
if(this.childNodes.length < 1){\r
*/\r
setText : function(text){\r
var oldText = this.text;\r
- this.text = text;\r
- this.attributes.text = text;\r
+ this.text = this.attributes.text = text;\r
if(this.rendered){ // event without subscribing\r
this.ui.onTextChange(this, text, oldText);\r
}\r
* Triggers selection of this node\r
*/\r
select : function(){\r
- this.getOwnerTree().getSelectionModel().select(this);\r
+ var t = this.getOwnerTree();\r
+ if(t){\r
+ t.getSelectionModel().select(this);\r
+ }\r
},\r
\r
/**\r
* Triggers deselection of this node\r
+ * @param {Boolean} silent (optional) True to stop selection change events from firing.\r
*/\r
- unselect : function(){\r
- this.getOwnerTree().getSelectionModel().unselect(this);\r
+ unselect : function(silent){\r
+ var t = this.getOwnerTree();\r
+ if(t){\r
+ t.getSelectionModel().unselect(this, silent);\r
+ }\r
},\r
\r
/**\r
* @return {Boolean}\r
*/\r
isSelected : function(){\r
- return this.getOwnerTree().getSelectionModel().isSelected(this);\r
+ var t = this.getOwnerTree();\r
+ return t ? t.getSelectionModel().isSelected(this) : false;\r
},\r
\r
/**\r
* @param {Function} callback (optional) A callback to be called when\r
* expanding this node completes (does not wait for deep expand to complete).\r
* Called with 1 parameter, this node.\r
- * @param {Object} scope (optional) The scope in which to execute the callback.\r
+ * @param {Object} scope (optional) The scope (<code>this</code> reference) in which the callback is executed. Defaults to this TreeNode.\r
*/\r
expand : function(deep, anim, callback, scope){\r
if(!this.expanded){\r
* @param {Function} callback (optional) A callback to be called when\r
* expanding this node completes (does not wait for deep expand to complete).\r
* Called with 1 parameter, this node.\r
- * @param {Object} scope (optional) The scope in which to execute the callback.\r
+ * @param {Object} scope (optional) The scope (<code>this</code> reference) in which the callback is executed. Defaults to this TreeNode.\r
*/\r
collapse : function(deep, anim, callback, scope){\r
if(this.expanded && !this.isHiddenRoot()){\r
* Ensures all parent nodes are expanded, and if necessary, scrolls\r
* the node into view.\r
* @param {Function} callback (optional) A function to call when the node has been made visible.\r
- * @param {Object} scope (optional) The scope in which to execute the callback.\r
+ * @param {Object} scope (optional) The scope (<code>this</code> reference) in which the callback is executed. Defaults to this TreeNode.\r
*/\r
ensureVisible : function(callback, scope){\r
var tree = this.getOwnerTree();\r
},\r
\r
destroy : function(){\r
- if(this.childNodes){\r
- for(var i = 0,l = this.childNodes.length; i < l; i++){\r
- this.childNodes[i].destroy();\r
- }\r
- this.childNodes = null;\r
- }\r
- if(this.ui.destroy){\r
- this.ui.destroy();\r
- }\r
+ this.unselect(true);\r
+ Ext.tree.TreeNode.superclass.destroy.call(this);\r
+ Ext.destroy(this.ui, this.loader);\r
+ this.ui = this.loader = null;\r
},\r
\r
// private\r