Upgrade to ExtJS 4.0.0 - Released 04/26/2011
[extjs.git] / examples / ux / grid / filter / Filter.js
similarity index 91%
rename from examples/ux/gridfilters/filter/Filter.js
rename to examples/ux/grid/filter/Filter.js
index ecde37a..23b185d 100644 (file)
@@ -1,17 +1,11 @@
-/*!
- * Ext JS Library 3.3.1
- * Copyright(c) 2006-2010 Sencha Inc.
- * licensing@sencha.com
- * http://www.sencha.com/license
- */
-Ext.namespace('Ext.ux.grid.filter');
-
-/** 
+/**
  * @class Ext.ux.grid.filter.Filter
  * @extends Ext.util.Observable
  * Abstract base class for filter implementations.
  */
-Ext.ux.grid.filter.Filter = Ext.extend(Ext.util.Observable, {
+Ext.define('Ext.ux.grid.filter.Filter', {
+    extend: 'Ext.util.Observable',
+
     /**
      * @cfg {Boolean} active
      * Indicates the initial status of the filter (defaults to false).
@@ -23,7 +17,7 @@ Ext.ux.grid.filter.Filter = Ext.extend(Ext.util.Observable, {
      * @property active
      */
     /**
-     * @cfg {String} dataIndex 
+     * @cfg {String} dataIndex
      * The {@link Ext.data.Store} dataIndex of the field this filter represents.
      * The dataIndex does not actually have to exist in the store.
      */
@@ -36,14 +30,14 @@ Ext.ux.grid.filter.Filter = Ext.extend(Ext.util.Observable, {
     menu : null,
     /**
      * @cfg {Number} updateBuffer
-     * Number of milliseconds to wait after user interaction to fire an update. Only supported 
+     * Number of milliseconds to wait after user interaction to fire an update. Only supported
      * by filters: 'list', 'numeric', and 'string'. Defaults to 500.
      */
     updateBuffer : 500,
 
     constructor : function (config) {
         Ext.apply(this, config);
-            
+
         this.addEvents(
             /**
              * @event activate
@@ -74,7 +68,7 @@ Ext.ux.grid.filter.Filter = Ext.extend(Ext.util.Observable, {
         );
         Ext.ux.grid.filter.Filter.superclass.constructor.call(this);
 
-        this.menu = new Ext.menu.Menu();
+        this.menu = this.createMenu(config);
         this.init(config);
         if(config && config.value){
             this.setValue(config.value);
@@ -90,7 +84,7 @@ Ext.ux.grid.filter.Filter = Ext.extend(Ext.util.Observable, {
         if (this.menu){
             this.menu.destroy();
         }
-        this.purgeListeners();
+        this.clearListeners();
     },
 
     /**
@@ -99,7 +93,17 @@ Ext.ux.grid.filter.Filter = Ext.extend(Ext.util.Observable, {
      * Defaults to Ext.emptyFn.
      */
     init : Ext.emptyFn,
-    
+
+    /**
+     * @private @override
+     * Creates the Menu for this filter.
+     * @param {Object} config Filter configuration
+     * @return {Ext.menu.Menu}
+     */
+    createMenu: function(config) {
+        return Ext.create('Ext.menu.Menu', config);
+    },
+
     /**
      * Template method to be implemented by all subclasses that is to
      * get and return the value of the filter.
@@ -108,16 +112,16 @@ Ext.ux.grid.filter.Filter = Ext.extend(Ext.util.Observable, {
      * @methodOf Ext.ux.grid.filter.Filter
      */
     getValue : Ext.emptyFn,
-    
+
     /**
      * Template method to be implemented by all subclasses that is to
      * set the value of the filter and fire the 'update' event.
      * Defaults to Ext.emptyFn.
      * @param {Object} data The value to set the filter
      * @methodOf Ext.ux.grid.filter.Filter
-     */        
+     */
     setValue : Ext.emptyFn,
-    
+
     /**
      * Template method to be implemented by all subclasses that is to
      * return <tt>true</tt> if the filter has enough configuration information to be activated.
@@ -127,7 +131,7 @@ Ext.ux.grid.filter.Filter = Ext.extend(Ext.util.Observable, {
     isActivatable : function(){
         return true;
     },
-    
+
     /**
      * Template method to be implemented by all subclasses that is to
      * get and return serialized filter data for transmission to the server.
@@ -167,7 +171,7 @@ Ext.ux.grid.filter.Filter = Ext.extend(Ext.util.Observable, {
         }
         this.setActive(this.isActivatable());
     },
-    
+
     /**
      * Sets the status of the filter and fires the appropriate events.
      * @param {Boolean} active        The new filter state.
@@ -181,5 +185,5 @@ Ext.ux.grid.filter.Filter = Ext.extend(Ext.util.Observable, {
                 this.fireEvent(active ? 'activate' : 'deactivate', this);
             }
         }
-    }    
-});
\ No newline at end of file
+    }
+});