Upgrade to ExtJS 3.1.1 - Released 02/08/2010
[extjs.git] / src / widgets / tree / TreeSorter.js
index 142a745..39d743a 100644 (file)
@@ -1,12 +1,12 @@
 /*!
- * Ext JS Library 3.1.0
- * 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
  */
 /**\r
  * @class Ext.tree.TreeSorter\r
- * Provides sorting of nodes in a {@link Ext.tree.TreePanel}.  The TreeSorter automatically monitors events on the \r
+ * Provides sorting of nodes in a {@link Ext.tree.TreePanel}.  The TreeSorter automatically monitors events on the\r
  * associated TreePanel that might affect the tree's sort order (beforechildrenrendered, append, insert and textchange).\r
  * Example usage:<br />\r
  * <pre><code>\r
@@ -27,33 +27,33 @@ Ext.tree.TreeSorter = function(tree, config){
     /**\r
      * @cfg {Boolean} folderSort True to sort leaf nodes under non-leaf nodes (defaults to false)\r
      */\r
-    /** \r
-     * @cfg {String} property The named attribute on the node to sort by (defaults to "text").  Note that this \r
+    /**\r
+     * @cfg {String} property The named attribute on the node to sort by (defaults to "text").  Note that this\r
      * property is only used if no {@link #sortType} function is specified, otherwise it is ignored.\r
      */\r
-    /** \r
+    /**\r
      * @cfg {String} dir The direction to sort ("asc" or "desc," case-insensitive, defaults to "asc")\r
      */\r
-    /** \r
+    /**\r
      * @cfg {String} leafAttr The attribute used to determine leaf nodes when {@link #folderSort} = true (defaults to "leaf")\r
      */\r
-    /** \r
+    /**\r
      * @cfg {Boolean} caseSensitive true for case-sensitive sort (defaults to false)\r
      */\r
-    /** \r
+    /**\r
      * @cfg {Function} sortType A custom "casting" function used to convert node values before sorting.  The function\r
      * will be called with a single parameter (the {@link Ext.tree.TreeNode} being evaluated) and is expected to return\r
      * the node's sort value cast to the specific data type required for sorting.  This could be used, for example, when\r
-     * a node's text (or other attribute) should be sorted as a date or numeric value.  See the class description for \r
+     * a node's text (or other attribute) should be sorted as a date or numeric value.  See the class description for\r
      * example usage.  Note that if a sortType is specified, any {@link #property} config will be ignored.\r
      */\r
-    \r
+\r
     Ext.apply(this, config);\r
     tree.on("beforechildrenrendered", this.doSort, this);\r
     tree.on("append", this.updateSort, this);\r
     tree.on("insert", this.updateSort, this);\r
     tree.on("textchange", this.updateSortParent, this);\r
-    \r
+\r
     var dsc = this.dir && this.dir.toLowerCase() == "desc";\r
     var p = this.property || "text";\r
     var sortType = this.sortType;\r
@@ -70,14 +70,14 @@ Ext.tree.TreeSorter = function(tree, config){
                 return -1;\r
             }\r
         }\r
-       var v1 = sortType ? sortType(n1.attributes[p]) : (cs ? n1.attributes[p] : n1.attributes[p].toUpperCase());\r
-       var v2 = sortType ? sortType(n2.attributes[p]) : (cs ? n2.attributes[p] : n2.attributes[p].toUpperCase());\r
-       if(v1 < v2){\r
-                       return dsc ? +1 : -1;\r
-               }else if(v1 > v2){\r
-                       return dsc ? -1 : +1;\r
+        var v1 = sortType ? sortType(n1) : (cs ? n1.attributes[p] : n1.attributes[p].toUpperCase());\r
+        var v2 = sortType ? sortType(n2) : (cs ? n2.attributes[p] : n2.attributes[p].toUpperCase());\r
+        if(v1 < v2){\r
+            return dsc ? +1 : -1;\r
+        }else if(v1 > v2){\r
+            return dsc ? -1 : +1;\r
         }else{\r
-               return 0;\r
+            return 0;\r
         }\r
     };\r
 };\r
@@ -86,20 +86,20 @@ Ext.tree.TreeSorter.prototype = {
     doSort : function(node){\r
         node.sort(this.sortFn);\r
     },\r
-    \r
+\r
     compareNodes : function(n1, n2){\r
         return (n1.text.toUpperCase() > n2.text.toUpperCase() ? 1 : -1);\r
     },\r
-    \r
+\r
     updateSort : function(tree, node){\r
         if(node.childrenRendered){\r
             this.doSort.defer(1, this, [node]);\r
         }\r
     },\r
-    \r
+\r
     updateSortParent : function(node){\r
-               var p = node.parentNode;\r
-               if(p && p.childrenRendered){\r
+        var p = node.parentNode;\r
+        if(p && p.childrenRendered){\r
             this.doSort.defer(1, this, [p]);\r
         }\r
     }\r