X-Git-Url: http://git.ithinksw.org/extjs.git/blobdiff_plain/25ef3491bd9ae007ff1fc2b0d7943e6eaaccf775..6e39d509471fe9b4e2660e0d1631b350d0c66f40:/pkgs/pkg-tree-debug.js diff --git a/pkgs/pkg-tree-debug.js b/pkgs/pkg-tree-debug.js index 39f9880e..2553a85a 100644 --- a/pkgs/pkg-tree-debug.js +++ b/pkgs/pkg-tree-debug.js @@ -1,5 +1,5 @@ /*! - * 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 @@ -118,18 +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. - * Defaults to ['add', 'remove']. + * See {@link Ext.util.Observable#enableBubble}. + * Defaults to []. */ - bubbleEvents: [], + bubbleEvents : [], initComponent : function(){ Ext.tree.TreePanel.superclass.initComponent.call(this); @@ -145,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; @@ -174,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. @@ -182,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 @@ -192,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. @@ -201,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. @@ -209,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. @@ -217,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. @@ -227,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. @@ -236,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 @@ -257,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. @@ -265,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. @@ -273,61 +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", + '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 @@ -375,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 @@ -389,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 @@ -397,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 @@ -406,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 @@ -422,11 +444,11 @@ new Ext.tree.TreePanel({ * to be inserted by setting them on this object. *
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;
@@ -2067,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){
@@ -2085,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;
@@ -2119,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){
@@ -2136,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;
@@ -2213,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;
@@ -2370,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
@@ -2412,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){
@@ -2449,8 +2492,7 @@ 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);
}
@@ -2461,14 +2503,21 @@ Ext.extend(Ext.tree.TreeNode, Ext.data.Node, {
* 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);
+ }
},
/**
@@ -2476,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;
},
/**
@@ -2486,7 +2536,7 @@ 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){
@@ -2536,7 +2586,7 @@ 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()){
@@ -2599,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();
@@ -2717,15 +2767,10 @@ 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
@@ -2825,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);
@@ -2891,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{
@@ -3078,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);
},
@@ -3206,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;
},
@@ -3269,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 = ['this
reference) in which the callback is executed.
+ * defaults to the loaded TreeNode.
*/
load : function(node, callback, scope){
if(this.clearOnLoad){
@@ -3662,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;
}
},
@@ -3758,7 +3802,7 @@ new Ext.tree.TreePanel({
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){
@@ -3800,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
@@ -3855,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;
@@ -3975,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){
@@ -4462,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
@@ -4549,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