Upgrade to ExtJS 3.0.0 - Released 07/06/2009
[extjs.git] / source / widgets / tree / TreeFilter.js
diff --git a/source/widgets/tree/TreeFilter.js b/source/widgets/tree/TreeFilter.js
deleted file mode 100644 (file)
index 826038a..0000000
+++ /dev/null
@@ -1,116 +0,0 @@
-/*\r
- * Ext JS Library 2.2.1\r
- * Copyright(c) 2006-2009, Ext JS, LLC.\r
- * licensing@extjs.com\r
- * \r
- * http://extjs.com/license\r
- */\r
-\r
-/**\r
-* @class Ext.tree.TreeFilter\r
-* Note this class is experimental and doesn't update the indent (lines) or expand collapse icons of the nodes\r
-* @param {TreePanel} tree\r
-* @param {Object} config (optional)\r
- */\r
-Ext.tree.TreeFilter = function(tree, config){\r
-    this.tree = tree;\r
-    this.filtered = {};\r
-    Ext.apply(this, config);\r
-};\r
-\r
-Ext.tree.TreeFilter.prototype = {\r
-    clearBlank:false,\r
-    reverse:false,\r
-    autoClear:false,\r
-    remove:false,\r
-\r
-     /**\r
-     * Filter the data by a specific attribute.\r
-     * @param {String/RegExp} value Either string that the attribute value \r
-     * should start with or a RegExp to test against the attribute\r
-     * @param {String} attr (optional) The attribute passed in your node's attributes collection. Defaults to "text".\r
-     * @param {TreeNode} startNode (optional) The node to start the filter at.\r
-     */\r
-    filter : function(value, attr, startNode){\r
-        attr = attr || "text";\r
-        var f;\r
-        if(typeof value == "string"){\r
-            var vlen = value.length;\r
-            // auto clear empty filter\r
-            if(vlen == 0 && this.clearBlank){\r
-                this.clear();\r
-                return;\r
-            }\r
-            value = value.toLowerCase();\r
-            f = function(n){\r
-                return n.attributes[attr].substr(0, vlen).toLowerCase() == value;\r
-            };\r
-        }else if(value.exec){ // regex?\r
-            f = function(n){\r
-                return value.test(n.attributes[attr]);\r
-            };\r
-        }else{\r
-            throw 'Illegal filter type, must be string or regex';\r
-        }\r
-        this.filterBy(f, null, startNode);\r
-       },\r
-    \r
-    /**\r
-     * Filter by a function. The passed function will be called with each \r
-     * node in the tree (or from the startNode). If the function returns true, the node is kept \r
-     * otherwise it is filtered. If a node is filtered, its children are also filtered.\r
-     * @param {Function} fn The filter function\r
-     * @param {Object} scope (optional) The scope of the function (defaults to the current node) \r
-     */\r
-    filterBy : function(fn, scope, startNode){\r
-        startNode = startNode || this.tree.root;\r
-        if(this.autoClear){\r
-            this.clear();\r
-        }\r
-        var af = this.filtered, rv = this.reverse;\r
-        var f = function(n){\r
-            if(n == startNode){\r
-                return true;\r
-            }\r
-            if(af[n.id]){\r
-                return false;\r
-            }\r
-            var m = fn.call(scope || n, n);\r
-            if(!m || rv){\r
-                af[n.id] = n;\r
-                n.ui.hide();\r
-                return false;\r
-            }\r
-            return true;\r
-        };\r
-        startNode.cascade(f);\r
-        if(this.remove){\r
-           for(var id in af){\r
-               if(typeof id != "function"){\r
-                   var n = af[id];\r
-                   if(n && n.parentNode){\r
-                       n.parentNode.removeChild(n);\r
-                   }\r
-               }\r
-           } \r
-        }\r
-    },\r
-    \r
-    /**\r
-     * Clears the current filter. Note: with the "remove" option\r
-     * set a filter cannot be cleared.\r
-     */\r
-    clear : function(){\r
-        var t = this.tree;\r
-        var af = this.filtered;\r
-        for(var id in af){\r
-            if(typeof id != "function"){\r
-                var n = af[id];\r
-                if(n){\r
-                    n.ui.show();\r
-                }\r
-            }\r
-        }\r
-        this.filtered = {}; \r
-    }\r
-};\r