Upgrade to ExtJS 4.0.0 - Released 04/26/2011
[extjs.git] / examples / ux / grid / filter / StringFilter.js
similarity index 81%
rename from examples/ux/gridfilters/filter/StringFilter.js
rename to examples/ux/grid/filter/StringFilter.js
index e02928c..71b5a30 100644 (file)
@@ -1,32 +1,28 @@
-/*!
- * Ext JS Library 3.3.1
- * Copyright(c) 2006-2010 Sencha Inc.
- * licensing@sencha.com
- * http://www.sencha.com/license
- */
-/** 
+/**
  * @class Ext.ux.grid.filter.StringFilter
  * @extends Ext.ux.grid.filter.Filter
- * Filter by a configurable Ext.form.TextField
+ * Filter by a configurable Ext.form.field.Text
  * <p><b><u>Example Usage:</u></b></p>
- * <pre><code>    
-var filters = new Ext.ux.grid.GridFilters({
+ * <pre><code>
+var filters = Ext.create('Ext.ux.grid.GridFilters', {
     ...
     filters: [{
         // required configs
         type: 'string',
         dataIndex: 'name',
-        
+
         // optional configs
         value: 'foo',
         active: true, // default is false
         iconCls: 'ux-gridfilter-text-icon' // default
-        // any Ext.form.TextField configs accepted
+        // any Ext.form.field.Text configs accepted
     }]
 });
  * </code></pre>
  */
-Ext.ux.grid.filter.StringFilter = Ext.extend(Ext.ux.grid.filter.Filter, {
+Ext.define('Ext.ux.grid.filter.StringFilter', {
+    extend: 'Ext.ux.grid.filter.Filter',
+    alias: 'gridfilter.string',
 
     /**
      * @cfg {String} iconCls
@@ -38,8 +34,8 @@ Ext.ux.grid.filter.StringFilter = Ext.extend(Ext.ux.grid.filter.Filter, {
     emptyText: 'Enter Filter Text...',
     selectOnFocus: true,
     width: 125,
-    
-    /**  
+
+    /**
      * @private
      * Template method that is to initialize the filter and install required menu items.
      */
@@ -47,17 +43,23 @@ Ext.ux.grid.filter.StringFilter = Ext.extend(Ext.ux.grid.filter.Filter, {
         Ext.applyIf(config, {
             enableKeyEvents: true,
             iconCls: this.iconCls,
+            hideLabel: true,
             listeners: {
                 scope: this,
-                keyup: this.onInputKeyUp
+                keyup: this.onInputKeyUp,
+                el: {
+                    click: function(e) {
+                        e.stopPropagation();
+                    }
+                }
             }
         });
 
-        this.inputItem = new Ext.form.TextField(config); 
+        this.inputItem = Ext.create('Ext.form.field.Text', config);
         this.menu.add(this.inputItem);
-        this.updateTask = new Ext.util.DelayedTask(this.fireUpdate, this);
+        this.updateTask = Ext.create('Ext.util.DelayedTask', this.fireUpdate, this);
     },
-    
+
     /**
      * @private
      * Template method that is to get and return the value of the filter.
@@ -66,12 +68,12 @@ Ext.ux.grid.filter.StringFilter = Ext.extend(Ext.ux.grid.filter.Filter, {
     getValue : function () {
         return this.inputItem.getValue();
     },
-    
+
     /**
      * @private
      * Template method that is to set the value of the filter.
      * @param {Object} value The value to set the filter
-     */        
+     */
     setValue : function (value) {
         this.inputItem.setValue(value);
         this.fireEvent('update', this);
@@ -114,8 +116,8 @@ Ext.ux.grid.filter.StringFilter = Ext.extend(Ext.ux.grid.filter.Filter, {
 
         return val.toLowerCase().indexOf(this.getValue().toLowerCase()) > -1;
     },
-    
-    /**  
+
+    /**
      * @private
      * Handler method called when there is a keyup event on this.inputItem
      */
@@ -123,7 +125,7 @@ Ext.ux.grid.filter.StringFilter = Ext.extend(Ext.ux.grid.filter.Filter, {
         var k = e.getKey();
         if (k == e.RETURN && field.isValid()) {
             e.stopEvent();
-            this.menu.hide(true);
+            this.menu.hide();
             return;
         }
         // restart the timer