Upgrade to ExtJS 3.2.0 - Released 03/30/2010
[extjs.git] / examples / ux / gridfilters / menu / RangeMenu.js
index e2f0288..06da660 100644 (file)
 /*!
- * Ext JS Library 3.1.1
- * Copyright(c) 2006-2010 Ext JS, LLC
+ * Ext JS Library 3.2.0
+ * Copyright(c) 2006-2010 Ext JS, Inc.
  * licensing@extjs.com
  * http://www.extjs.com/license
  */
-Ext.ns('Ext.ux.menu');\r
-\r
-/** \r
- * @class Ext.ux.menu.RangeMenu\r
- * @extends Ext.menu.Menu\r
- * Custom implementation of Ext.menu.Menu that has preconfigured\r
- * items for gt, lt, eq.\r
- * <p><b><u>Example Usage:</u></b></p>\r
- * <pre><code>    \r
-\r
- * </code></pre> \r
- */\r
-Ext.ux.menu.RangeMenu = Ext.extend(Ext.menu.Menu, {\r
-\r
-    constructor : function (config) {\r
-\r
-        Ext.ux.menu.RangeMenu.superclass.constructor.call(this, config);\r
-\r
-        this.addEvents(\r
-            /**\r
-             * @event update\r
-             * Fires when a filter configuration has changed\r
-             * @param {Ext.ux.grid.filter.Filter} this The filter object.\r
-             */\r
-            'update'\r
-        );\r
-      \r
-        this.updateTask = new Ext.util.DelayedTask(this.fireUpdate, this);\r
-    \r
-        var i, len, item, cfg, Cls;\r
-\r
-        for (i = 0, len = this.menuItems.length; i < len; i++) {\r
-            item = this.menuItems[i];\r
-            if (item !== '-') {\r
-                // defaults\r
-                cfg = {\r
-                    itemId: 'range-' + item,\r
-                    enableKeyEvents: true,\r
-                    iconCls: this.iconCls[item] || 'no-icon',\r
-                    listeners: {\r
-                        scope: this,\r
-                        keyup: this.onInputKeyUp\r
-                    }\r
-                };\r
-                Ext.apply(\r
-                    cfg,\r
-                    // custom configs\r
-                    Ext.applyIf(this.fields[item] || {}, this.fieldCfg[item]),\r
-                    // configurable defaults\r
-                    this.menuItemCfgs\r
-                );\r
-                Cls = cfg.fieldCls || this.fieldCls;\r
-                item = this.fields[item] = new Cls(cfg);\r
-            }\r
-            this.add(item);\r
-        }\r
-    },\r
-\r
-    /**\r
-     * @private\r
-     * called by this.updateTask\r
-     */\r
-    fireUpdate : function () {\r
-        this.fireEvent('update', this);\r
-    },\r
-    \r
-    /**\r
-     * Get and return the value of the filter.\r
-     * @return {String} The value of this filter\r
-     */\r
-    getValue : function () {\r
-        var result = {}, key, field;\r
-        for (key in this.fields) {\r
-            field = this.fields[key];\r
-            if (field.isValid() && String(field.getValue()).length > 0) {\r
-                result[key] = field.getValue();\r
-            }\r
-        }\r
-        return result;\r
-    },\r
-  \r
-    /**\r
-     * Set the value of this menu and fires the 'update' event.\r
-     * @param {Object} data The data to assign to this menu\r
-     */        \r
-    setValue : function (data) {\r
-        var key;\r
-        for (key in this.fields) {\r
-            this.fields[key].setValue(data[key] !== undefined ? data[key] : '');\r
-        }\r
-        this.fireEvent('update', this);\r
-    },\r
-\r
-    /**  \r
-     * @private\r
-     * Handler method called when there is a keyup event on an input\r
-     * item of this menu.\r
-     */\r
-    onInputKeyUp : function (field, e) {\r
-        var k = e.getKey();\r
-        if (k == e.RETURN && field.isValid()) {\r
-            e.stopEvent();\r
-            this.hide(true);\r
-            return;\r
-        }\r
-        \r
-        if (field == this.fields.eq) {\r
-            if (this.fields.gt) {\r
-                this.fields.gt.setValue(null);\r
-            }\r
-            if (this.fields.lt) {\r
-                this.fields.lt.setValue(null);\r
-            }\r
-        }\r
-        else {\r
-            this.fields.eq.setValue(null);\r
-        }\r
-        \r
-        // restart the timer\r
-        this.updateTask.delay(this.updateBuffer);\r
-    }\r
-});\r
+Ext.ns('Ext.ux.menu');
+
+/** 
+ * @class Ext.ux.menu.RangeMenu
+ * @extends Ext.menu.Menu
+ * Custom implementation of Ext.menu.Menu that has preconfigured
+ * items for gt, lt, eq.
+ * <p><b><u>Example Usage:</u></b></p>
+ * <pre><code>    
+
+ * </code></pre> 
+ */
+Ext.ux.menu.RangeMenu = Ext.extend(Ext.menu.Menu, {
+
+    constructor : function (config) {
+
+        Ext.ux.menu.RangeMenu.superclass.constructor.call(this, config);
+
+        this.addEvents(
+            /**
+             * @event update
+             * Fires when a filter configuration has changed
+             * @param {Ext.ux.grid.filter.Filter} this The filter object.
+             */
+            'update'
+        );
+      
+        this.updateTask = new Ext.util.DelayedTask(this.fireUpdate, this);
+    
+        var i, len, item, cfg, Cls;
+
+        for (i = 0, len = this.menuItems.length; i < len; i++) {
+            item = this.menuItems[i];
+            if (item !== '-') {
+                // defaults
+                cfg = {
+                    itemId: 'range-' + item,
+                    enableKeyEvents: true,
+                    iconCls: this.iconCls[item] || 'no-icon',
+                    listeners: {
+                        scope: this,
+                        keyup: this.onInputKeyUp
+                    }
+                };
+                Ext.apply(
+                    cfg,
+                    // custom configs
+                    Ext.applyIf(this.fields[item] || {}, this.fieldCfg[item]),
+                    // configurable defaults
+                    this.menuItemCfgs
+                );
+                Cls = cfg.fieldCls || this.fieldCls;
+                item = this.fields[item] = new Cls(cfg);
+            }
+            this.add(item);
+        }
+    },
+
+    /**
+     * @private
+     * called by this.updateTask
+     */
+    fireUpdate : function () {
+        this.fireEvent('update', this);
+    },
+    
+    /**
+     * Get and return the value of the filter.
+     * @return {String} The value of this filter
+     */
+    getValue : function () {
+        var result = {}, key, field;
+        for (key in this.fields) {
+            field = this.fields[key];
+            if (field.isValid() && String(field.getValue()).length > 0) {
+                result[key] = field.getValue();
+            }
+        }
+        return result;
+    },
+  
+    /**
+     * Set the value of this menu and fires the 'update' event.
+     * @param {Object} data The data to assign to this menu
+     */        
+    setValue : function (data) {
+        var key;
+        for (key in this.fields) {
+            this.fields[key].setValue(data[key] !== undefined ? data[key] : '');
+        }
+        this.fireEvent('update', this);
+    },
+
+    /**  
+     * @private
+     * Handler method called when there is a keyup event on an input
+     * item of this menu.
+     */
+    onInputKeyUp : function (field, e) {
+        var k = e.getKey();
+        if (k == e.RETURN && field.isValid()) {
+            e.stopEvent();
+            this.hide(true);
+            return;
+        }
+        
+        if (field == this.fields.eq) {
+            if (this.fields.gt) {
+                this.fields.gt.setValue(null);
+            }
+            if (this.fields.lt) {
+                this.fields.lt.setValue(null);
+            }
+        }
+        else {
+            this.fields.eq.setValue(null);
+        }
+        
+        // restart the timer
+        this.updateTask.delay(this.updateBuffer);
+    }
+});