Upgrade to ExtJS 3.0.0 - Released 07/06/2009
[extjs.git] / source / widgets / form / TriggerField.js
diff --git a/source/widgets/form/TriggerField.js b/source/widgets/form/TriggerField.js
deleted file mode 100644 (file)
index 6a981bf..0000000
+++ /dev/null
@@ -1,280 +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.form.TriggerField\r
- * @extends Ext.form.TextField\r
- * Provides a convenient wrapper for TextFields that adds a clickable trigger button (looks like a combobox by default).\r
- * The trigger has no default action, so you must assign a function to implement the trigger click handler by\r
- * overriding {@link #onTriggerClick}. You can create a TriggerField directly, as it renders exactly like a combobox\r
- * for which you can provide a custom implementation.  For example:\r
- * <pre><code>\r
-var trigger = new Ext.form.TriggerField();\r
-trigger.onTriggerClick = myTriggerFn;\r
-trigger.applyToMarkup('my-field');\r
-</code></pre>\r
- *\r
- * However, in general you will most likely want to use TriggerField as the base class for a reusable component.\r
- * {@link Ext.form.DateField} and {@link Ext.form.ComboBox} are perfect examples of this.\r
- * @cfg {String} triggerClass An additional CSS class used to style the trigger button.  The trigger will always get the\r
- * class 'x-form-trigger' by default and triggerClass will be <b>appended</b> if specified.\r
- * @constructor\r
- * Create a new TriggerField.\r
- * @param {Object} config Configuration options (valid {@Ext.form.TextField} config options will also be applied\r
- * to the base TextField)\r
- */\r
-Ext.form.TriggerField = Ext.extend(Ext.form.TextField,  {\r
-    /**\r
-     * @cfg {String} triggerClass A CSS class to apply to the trigger\r
-     */\r
-    /**\r
-     * @cfg {String/Object} autoCreate A DomHelper element spec, or true for a default element spec (defaults to\r
-     * {tag: "input", type: "text", size: "16", autocomplete: "off"})\r
-     */\r
-    defaultAutoCreate : {tag: "input", type: "text", size: "16", autocomplete: "off"},\r
-    /**\r
-     * @cfg {Boolean} hideTrigger True to hide the trigger element and display only the base text field (defaults to false)\r
-     */\r
-    hideTrigger:false,\r
-\r
-    /**\r
-     * @hide \r
-     * @method autoSize\r
-     */\r
-    autoSize: Ext.emptyFn,\r
-    // private\r
-    monitorTab : true,\r
-    // private\r
-    deferHeight : true,\r
-    // private\r
-    mimicing : false,\r
-\r
-    // private\r
-    onResize : function(w, h){\r
-        Ext.form.TriggerField.superclass.onResize.call(this, w, h);\r
-        if(typeof w == 'number'){\r
-            this.el.setWidth(this.adjustWidth('input', w - this.trigger.getWidth()));\r
-        }\r
-        this.wrap.setWidth(this.el.getWidth()+this.trigger.getWidth());\r
-    },\r
-\r
-    // private\r
-    adjustSize : Ext.BoxComponent.prototype.adjustSize,\r
-\r
-    // private\r
-    getResizeEl : function(){\r
-        return this.wrap;\r
-    },\r
-\r
-    // private\r
-    getPositionEl : function(){\r
-        return this.wrap;\r
-    },\r
-\r
-    // private\r
-    alignErrorIcon : function(){\r
-        if(this.wrap){\r
-            this.errorIcon.alignTo(this.wrap, 'tl-tr', [2, 0]);\r
-        }\r
-    },\r
-\r
-    // private\r
-    onRender : function(ct, position){\r
-        Ext.form.TriggerField.superclass.onRender.call(this, ct, position);\r
-        this.wrap = this.el.wrap({cls: "x-form-field-wrap"});\r
-        this.trigger = this.wrap.createChild(this.triggerConfig ||\r
-                {tag: "img", src: Ext.BLANK_IMAGE_URL, cls: "x-form-trigger " + this.triggerClass});\r
-        if(this.hideTrigger){\r
-            this.trigger.setDisplayed(false);\r
-        }\r
-        this.initTrigger();\r
-        if(!this.width){\r
-            this.wrap.setWidth(this.el.getWidth()+this.trigger.getWidth());\r
-        }\r
-    },\r
-\r
-    afterRender : function(){\r
-        Ext.form.TriggerField.superclass.afterRender.call(this);\r
-        var y;\r
-        if(Ext.isIE && !this.hideTrigger && this.el.getY() != (y = this.trigger.getY())){\r
-            this.el.position();\r
-            this.el.setY(y);\r
-        }\r
-    },\r
-\r
-    // private\r
-    initTrigger : function(){\r
-        this.trigger.on("click", this.onTriggerClick, this, {preventDefault:true});\r
-        this.trigger.addClassOnOver('x-form-trigger-over');\r
-        this.trigger.addClassOnClick('x-form-trigger-click');\r
-    },\r
-\r
-    // private\r
-    onDestroy : function(){\r
-        if(this.trigger){\r
-            this.trigger.removeAllListeners();\r
-            this.trigger.remove();\r
-        }\r
-        if(this.wrap){\r
-            this.wrap.remove();\r
-        }\r
-        Ext.form.TriggerField.superclass.onDestroy.call(this);\r
-    },\r
-\r
-    // private\r
-    onFocus : function(){\r
-        Ext.form.TriggerField.superclass.onFocus.call(this);\r
-        if(!this.mimicing){\r
-            this.wrap.addClass('x-trigger-wrap-focus');\r
-            this.mimicing = true;\r
-            Ext.get(Ext.isIE ? document.body : document).on("mousedown", this.mimicBlur, this, {delay: 10});\r
-            if(this.monitorTab){\r
-                this.el.on("keydown", this.checkTab, this);\r
-            }\r
-        }\r
-    },\r
-\r
-    // private\r
-    checkTab : function(e){\r
-        if(e.getKey() == e.TAB){\r
-            this.triggerBlur();\r
-        }\r
-    },\r
-\r
-    // private\r
-    onBlur : function(){\r
-        // do nothing\r
-    },\r
-\r
-    // private\r
-    mimicBlur : function(e){\r
-        if(!this.wrap.contains(e.target) && this.validateBlur(e)){\r
-            this.triggerBlur();\r
-        }\r
-    },\r
-\r
-    // private\r
-    triggerBlur : function(){\r
-        this.mimicing = false;\r
-        Ext.get(Ext.isIE ? document.body : document).un("mousedown", this.mimicBlur, this);\r
-        if(this.monitorTab && this.el){\r
-            this.el.un("keydown", this.checkTab, this);\r
-        }\r
-        this.beforeBlur();\r
-        if(this.wrap){\r
-            this.wrap.removeClass('x-trigger-wrap-focus');\r
-        }\r
-        Ext.form.TriggerField.superclass.onBlur.call(this);\r
-    },\r
-\r
-    beforeBlur : Ext.emptyFn, \r
-\r
-    // private\r
-    // This should be overriden by any subclass that needs to check whether or not the field can be blurred.\r
-    validateBlur : function(e){\r
-        return true;\r
-    },\r
-\r
-    // private\r
-    onDisable : function(){\r
-        Ext.form.TriggerField.superclass.onDisable.call(this);\r
-        if(this.wrap){\r
-            this.wrap.addClass(this.disabledClass);\r
-            this.el.removeClass(this.disabledClass);\r
-        }\r
-    },\r
-\r
-    // private\r
-    onEnable : function(){\r
-        Ext.form.TriggerField.superclass.onEnable.call(this);\r
-        if(this.wrap){\r
-            this.wrap.removeClass(this.disabledClass);\r
-        }\r
-    },\r
-\r
-    // private\r
-    onShow : function(){\r
-        if(this.wrap){\r
-            this.wrap.dom.style.display = '';\r
-            this.wrap.dom.style.visibility = 'visible';\r
-        }\r
-    },\r
-\r
-    // private\r
-    onHide : function(){\r
-        this.wrap.dom.style.display = 'none';\r
-    },\r
-\r
-    /**\r
-     * The function that should handle the trigger's click event.  This method does nothing by default until overridden\r
-     * by an implementing function.\r
-     * @method\r
-     * @param {EventObject} e\r
-     */\r
-    onTriggerClick : Ext.emptyFn\r
-\r
-    /**\r
-     * @cfg {Boolean} grow @hide\r
-     */\r
-    /**\r
-     * @cfg {Number} growMin @hide\r
-     */\r
-    /**\r
-     * @cfg {Number} growMax @hide\r
-     */\r
-});\r
-\r
-// TwinTriggerField is not a public class to be used directly.  It is meant as an abstract base class\r
-// to be extended by an implementing class.  For an example of implementing this class, see the custom\r
-// SearchField implementation here: http://extjs.com/deploy/ext/examples/form/custom.html\r
-Ext.form.TwinTriggerField = Ext.extend(Ext.form.TriggerField, {\r
-    initComponent : function(){\r
-        Ext.form.TwinTriggerField.superclass.initComponent.call(this);\r
-\r
-        this.triggerConfig = {\r
-            tag:'span', cls:'x-form-twin-triggers', cn:[\r
-            {tag: "img", src: Ext.BLANK_IMAGE_URL, cls: "x-form-trigger " + this.trigger1Class},\r
-            {tag: "img", src: Ext.BLANK_IMAGE_URL, cls: "x-form-trigger " + this.trigger2Class}\r
-        ]};\r
-    },\r
-\r
-    getTrigger : function(index){\r
-        return this.triggers[index];\r
-    },\r
-\r
-    initTrigger : function(){\r
-        var ts = this.trigger.select('.x-form-trigger', true);\r
-        this.wrap.setStyle('overflow', 'hidden');\r
-        var triggerField = this;\r
-        ts.each(function(t, all, index){\r
-            t.hide = function(){\r
-                var w = triggerField.wrap.getWidth();\r
-                this.dom.style.display = 'none';\r
-                triggerField.el.setWidth(w-triggerField.trigger.getWidth());\r
-            };\r
-            t.show = function(){\r
-                var w = triggerField.wrap.getWidth();\r
-                this.dom.style.display = '';\r
-                triggerField.el.setWidth(w-triggerField.trigger.getWidth());\r
-            };\r
-            var triggerIndex = 'Trigger'+(index+1);\r
-\r
-            if(this['hide'+triggerIndex]){\r
-                t.dom.style.display = 'none';\r
-            }\r
-            t.on("click", this['on'+triggerIndex+'Click'], this, {preventDefault:true});\r
-            t.addClassOnOver('x-form-trigger-over');\r
-            t.addClassOnClick('x-form-trigger-click');\r
-        }, this);\r
-        this.triggers = ts.elements;\r
-    },\r
-\r
-    onTrigger1Click : Ext.emptyFn,\r
-    onTrigger2Click : Ext.emptyFn\r
-});\r
-Ext.reg('trigger', Ext.form.TriggerField);
\ No newline at end of file