Upgrade to ExtJS 3.1.1 - Released 02/08/2010
[extjs.git] / src / widgets / tree / TreeSelectionModel.js
index d0f0c08..d100cc7 100644 (file)
@@ -1,6 +1,6 @@
 /*!
- * Ext JS Library 3.0.3
- * Copyright(c) 2006-2009 Ext JS, LLC
+ * Ext JS Library 3.1.1
+ * Copyright(c) 2006-2010 Ext JS, LLC
  * licensing@extjs.com
  * http://www.extjs.com/license
  */
@@ -19,7 +19,7 @@ Ext.tree.DefaultSelectionModel = function(config){
         * @param {DefaultSelectionModel} this\r
         * @param {TreeNode} node the new selection\r
         */\r
-       "selectionchange",\r
+       'selectionchange',\r
 \r
        /**\r
         * @event beforeselect\r
@@ -28,7 +28,7 @@ Ext.tree.DefaultSelectionModel = function(config){
         * @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
@@ -39,7 +39,7 @@ Ext.extend(Ext.tree.DefaultSelectionModel, Ext.util.Observable, {
     init : function(tree){\r
         this.tree = tree;\r
         tree.mon(tree.getTreeEl(), 'keydown', this.onKeyDown, this);\r
-        tree.on("click", this.onNodeClick, this);\r
+        tree.on('click', this.onNodeClick, this);\r
     },\r
     \r
     onNodeClick : function(node, e){\r
@@ -60,12 +60,12 @@ Ext.extend(Ext.tree.DefaultSelectionModel, Ext.util.Observable, {
         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
@@ -73,22 +73,26 @@ Ext.extend(Ext.tree.DefaultSelectionModel, Ext.util.Observable, {
     /**\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
     /**\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
@@ -216,7 +220,7 @@ Ext.tree.MultiSelectionModel = function(config){
         * @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
@@ -226,7 +230,7 @@ Ext.extend(Ext.tree.MultiSelectionModel, Ext.util.Observable, {
     init : function(tree){\r
         this.tree = tree;\r
         tree.mon(tree.getTreeEl(), 'keydown', this.onKeyDown, this);\r
-        tree.on("click", this.onNodeClick, this);\r
+        tree.on('click', this.onNodeClick, this);\r
     },\r
     \r
     onNodeClick : function(node, e){\r
@@ -256,7 +260,7 @@ Ext.extend(Ext.tree.MultiSelectionModel, Ext.util.Observable, {
         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
@@ -273,7 +277,7 @@ Ext.extend(Ext.tree.MultiSelectionModel, Ext.util.Observable, {
                 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
@@ -289,7 +293,7 @@ Ext.extend(Ext.tree.MultiSelectionModel, Ext.util.Observable, {
             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