<html>\r
<head>\r
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> \r
<title>The source code</title>\r
<link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />\r
<script type="text/javascript" src="../resources/prettify/prettify.js"></script>\r
* @param {DefaultSelectionModel} this\r
* @param {TreeNode} node the new selection\r
*/\r
- "selectionchange",\r
+ 'selectionchange',\r
\r
<div id="event-Ext.tree.DefaultSelectionModel-beforeselect"></div>/**\r
* @event beforeselect\r
* @param {TreeNode} node the new selection\r
* @param {TreeNode} node the old selection\r
*/\r
- "beforeselect"\r
+ 'beforeselect'\r
);\r
\r
Ext.apply(this, config);\r
Ext.extend(Ext.tree.DefaultSelectionModel, Ext.util.Observable, {\r
init : function(tree){\r
this.tree = tree;\r
- tree.getTreeEl().on("keydown", this.onKeyDown, this);\r
- tree.on("click", this.onNodeClick, this);\r
+ tree.mon(tree.getTreeEl(), 'keydown', this.onKeyDown, this);\r
+ tree.on('click', this.onNodeClick, this);\r
},\r
\r
onNodeClick : function(node, e){\r
* @param {TreeNode} node The node to select\r
* @return {TreeNode} The selected node\r
*/\r
- select : function(node){\r
+ select : function(node, /* private*/ selectNextNode){\r
+ // If node is hidden, select the next node in whatever direction was being moved in.\r
+ if (!Ext.fly(node.ui.wrap).isVisible() && selectNextNode) {\r
+ return selectNextNode.call(this, node);\r
+ }\r
var last = this.selNode;\r
if(node == last){\r
node.ui.onSelectedChange(true);\r
}else if(this.fireEvent('beforeselect', this, node, last) !== false){\r
- if(last){\r
+ if(last && last.ui){\r
last.ui.onSelectedChange(false);\r
}\r
this.selNode = node;\r
node.ui.onSelectedChange(true);\r
- this.fireEvent("selectionchange", this, node, last);\r
+ this.fireEvent('selectionchange', this, node, last);\r
}\r
return node;\r
},\r
<div id="method-Ext.tree.DefaultSelectionModel-unselect"></div>/**\r
* Deselect a node.\r
* @param {TreeNode} node The node to unselect\r
+ * @param {Boolean} silent True to stop the selectionchange event from firing.\r
*/\r
- unselect : function(node){\r
+ unselect : function(node, silent){\r
if(this.selNode == node){\r
- this.clearSelections();\r
+ this.clearSelections(silent);\r
} \r
},\r
\r
<div id="method-Ext.tree.DefaultSelectionModel-clearSelections"></div>/**\r
* Clear all selections\r
+ * @param {Boolean} silent True to stop the selectionchange event from firing.\r
*/\r
- clearSelections : function(){\r
+ clearSelections : function(silent){\r
var n = this.selNode;\r
if(n){\r
n.ui.onSelectedChange(false);\r
this.selNode = null;\r
- this.fireEvent("selectionchange", this, null);\r
+ if(silent !== true){\r
+ this.fireEvent('selectionchange', this, null);\r
+ }\r
}\r
return n;\r
},\r
* Selects the node above the selected node in the tree, intelligently walking the nodes\r
* @return TreeNode The new selection\r
*/\r
- selectPrevious : function(){\r
- var s = this.selNode || this.lastSelNode;\r
- if(!s){\r
+ selectPrevious : function(/* private */ s){\r
+ if(!(s = s || this.selNode || this.lastSelNode)){\r
return null;\r
}\r
+ // Here we pass in the current function to select to indicate the direction we're moving\r
var ps = s.previousSibling;\r
if(ps){\r
if(!ps.isExpanded() || ps.childNodes.length < 1){\r
- return this.select(ps);\r
+ return this.select(ps, this.selectPrevious);\r
} else{\r
var lc = ps.lastChild;\r
- while(lc && lc.isExpanded() && lc.childNodes.length > 0){\r
+ while(lc && lc.isExpanded() && Ext.fly(lc.ui.wrap).isVisible() && lc.childNodes.length > 0){\r
lc = lc.lastChild;\r
}\r
- return this.select(lc);\r
+ return this.select(lc, this.selectPrevious);\r
}\r
} else if(s.parentNode && (this.tree.rootVisible || !s.parentNode.isRoot)){\r
- return this.select(s.parentNode);\r
+ return this.select(s.parentNode, this.selectPrevious);\r
}\r
return null;\r
},\r
* Selects the node above the selected node in the tree, intelligently walking the nodes\r
* @return TreeNode The new selection\r
*/\r
- selectNext : function(){\r
- var s = this.selNode || this.lastSelNode;\r
- if(!s){\r
+ selectNext : function(/* private */ s){\r
+ if(!(s = s || this.selNode || this.lastSelNode)){\r
return null;\r
}\r
- if(s.firstChild && s.isExpanded()){\r
- return this.select(s.firstChild);\r
+ // Here we pass in the current function to select to indicate the direction we're moving\r
+ if(s.firstChild && s.isExpanded() && Ext.fly(s.ui.wrap).isVisible()){\r
+ return this.select(s.firstChild, this.selectNext);\r
}else if(s.nextSibling){\r
- return this.select(s.nextSibling);\r
+ return this.select(s.nextSibling, this.selectNext);\r
}else if(s.parentNode){\r
var newS = null;\r
s.parentNode.bubble(function(){\r
if(this.nextSibling){\r
- newS = this.getOwnerTree().selModel.select(this.nextSibling);\r
+ newS = this.getOwnerTree().selModel.select(this.nextSibling, this.selectNext);\r
return false;\r
}\r
});\r
* @param {MultiSelectionModel} this\r
* @param {Array} nodes Array of the selected nodes\r
*/\r
- "selectionchange"\r
+ 'selectionchange'\r
);\r
Ext.apply(this, config);\r
Ext.tree.MultiSelectionModel.superclass.constructor.call(this);\r
Ext.extend(Ext.tree.MultiSelectionModel, Ext.util.Observable, {\r
init : function(tree){\r
this.tree = tree;\r
- tree.getTreeEl().on("keydown", this.onKeyDown, this);\r
- tree.on("click", this.onNodeClick, this);\r
+ tree.mon(tree.getTreeEl(), 'keydown', this.onKeyDown, this);\r
+ tree.on('click', this.onNodeClick, this);\r
},\r
\r
onNodeClick : function(node, e){\r
this.selMap[node.id] = node;\r
this.lastSelNode = node;\r
node.ui.onSelectedChange(true);\r
- this.fireEvent("selectionchange", this, this.selNodes);\r
+ this.fireEvent('selectionchange', this, this.selNodes);\r
return node;\r
},\r
\r
this.selNodes.splice(index, 1);\r
}\r
delete this.selMap[node.id];\r
- this.fireEvent("selectionchange", this, this.selNodes);\r
+ this.fireEvent('selectionchange', this, this.selNodes);\r
}\r
},\r
\r
this.selNodes = [];\r
this.selMap = {};\r
if(suppressEvent !== true){\r
- this.fireEvent("selectionchange", this, this.selNodes);\r
+ this.fireEvent('selectionchange', this, this.selNodes);\r
}\r
}\r
},\r