<html>
<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>The source code</title>
<link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
<script type="text/javascript" src="../resources/prettify/prettify.js"></script>
</head>
<body onload="prettyPrint();">
<pre class="prettyprint lang-js">/*!
- * Ext JS Library 3.0.3
- * Copyright(c) 2006-2009 Ext JS, LLC
- * licensing@extjs.com
- * http://www.extjs.com/license
+ * Ext JS Library 3.3.1
+ * Copyright(c) 2006-2010 Sencha Inc.
+ * licensing@sencha.com
+ * http://www.sencha.com/license
*/
-<div id="cls-Ext.form.TriggerField"></div>/**\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
- * \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
- * @xtype trigger\r
- */\r
-Ext.form.TriggerField = Ext.extend(Ext.form.TextField, {\r
- <div id="cfg-Ext.form.TriggerField-triggerClass"></div>/**\r
- * @cfg {String} triggerClass\r
- * An additional CSS class used to style the trigger button. The trigger will always get the\r
- * class <tt>'x-form-trigger'</tt> by default and <tt>triggerClass</tt> will be <b>appended</b> if specified.\r
- */\r
- <div id="cfg-Ext.form.TriggerField-triggerConfig"></div>/**\r
- * @cfg {Mixed} triggerConfig\r
- * <p>A {@link Ext.DomHelper DomHelper} config object specifying the structure of the\r
- * trigger element for this Field. (Optional).</p>\r
- * <p>Specify this when you need a customized element to act as the trigger button for a TriggerField.</p>\r
- * <p>Note that when using this option, it is the developer's responsibility to ensure correct sizing, positioning\r
- * and appearance of the trigger. Defaults to:</p>\r
- * <pre><code>{tag: "img", src: Ext.BLANK_IMAGE_URL, cls: "x-form-trigger " + this.triggerClass}</code></pre>\r
- */\r
- <div id="cfg-Ext.form.TriggerField-autoCreate"></div>/**\r
- * @cfg {String/Object} autoCreate <p>A {@link Ext.DomHelper DomHelper} element spec, or true for a default\r
- * element spec. Used to create the {@link Ext.Component#getEl Element} which will encapsulate this Component.\r
- * See <tt>{@link Ext.Component#autoEl autoEl}</tt> for details. Defaults to:</p>\r
- * <pre><code>{tag: "input", type: "text", size: "16", autocomplete: "off"}</code></pre>\r
- */\r
- defaultAutoCreate : {tag: "input", type: "text", size: "16", autocomplete: "off"},\r
- <div id="cfg-Ext.form.TriggerField-hideTrigger"></div>/**\r
- * @cfg {Boolean} hideTrigger <tt>true</tt> to hide the trigger element and display only the base\r
- * text field (defaults to <tt>false</tt>)\r
- */\r
- hideTrigger:false,\r
- <div id="cfg-Ext.form.TriggerField-editable"></div>/**\r
- * @cfg {Boolean} editable <tt>false</tt> to prevent the user from typing text directly into the field,\r
- * the field will only respond to a click on the trigger to set the value. (defaults to <tt>true</tt>)\r
- */\r
- editable: true,\r
- <div id="cfg-Ext.form.TriggerField-wrapFocusClass"></div>/**\r
- * @cfg {String} wrapFocusClass The class added to the to the wrap of the trigger element. Defaults to\r
- * <tt>x-trigger-wrap-focus</tt>.\r
- */\r
- wrapFocusClass: 'x-trigger-wrap-focus',\r
- <div id="method-Ext.form.TriggerField-autoSize"></div>/**\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
- actionMode: 'wrap',\r
- \r
- defaultTriggerWidth: 17,\r
-\r
- // private\r
- onResize : function(w, h){\r
- Ext.form.TriggerField.superclass.onResize.call(this, w, h);\r
- var tw = this.getTriggerWidth();\r
- if(Ext.isNumber(w)){\r
- this.el.setWidth(w - tw);\r
- }\r
- this.wrap.setWidth(this.el.getWidth() + tw);\r
- },\r
- \r
- getTriggerWidth: function(){\r
- var tw = this.trigger.getWidth();\r
- if(!this.hideTrigger && tw === 0){\r
- tw = this.defaultTriggerWidth;\r
- }\r
- return tw;\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
- this.doc = Ext.isIE ? Ext.getBody() : Ext.getDoc();\r
- Ext.form.TriggerField.superclass.onRender.call(this, ct, position);\r
-\r
- this.wrap = this.el.wrap({cls: 'x-form-field-wrap x-form-field-trigger-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
- if(!this.editable){\r
- this.editable = true;\r
- this.setEditable(false);\r
- }\r
- this.resizeEl = this.positionEl = this.wrap;\r
- },\r
-\r
- afterRender : function(){\r
- Ext.form.TriggerField.superclass.afterRender.call(this);\r
- },\r
-\r
- // private\r
- initTrigger : function(){\r
- this.mon(this.trigger, '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
- Ext.destroy(this.trigger, this.wrap);\r
- if (this.mimicing){\r
- this.doc.un('mousedown', this.mimicBlur, this);\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(this.wrapFocusClass);\r
- this.mimicing = true;\r
- this.doc.on('mousedown', this.mimicBlur, this, {delay: 10});\r
- if(this.monitorTab){\r
- this.on('specialkey', this.checkTab, this);\r
- }\r
- }\r
- },\r
-\r
- // private\r
- checkTab : function(me, e){\r
- if(e.getKey() == e.TAB){\r
- this.triggerBlur();\r
- }\r
- },\r
-\r
- // private\r
- onBlur : Ext.emptyFn,\r
-\r
- // private\r
- mimicBlur : function(e){\r
- if(!this.isDestroyed && !this.wrap.contains(e.target) && this.validateBlur(e)){\r
- this.triggerBlur();\r
- }\r
- },\r
-\r
- // private\r
- triggerBlur : function(){\r
- this.mimicing = false;\r
- this.doc.un('mousedown', this.mimicBlur, this);\r
- if(this.monitorTab && this.el){\r
- this.un('specialkey', this.checkTab, this);\r
- }\r
- Ext.form.TriggerField.superclass.onBlur.call(this);\r
- if(this.wrap){\r
- this.wrap.removeClass(this.wrapFocusClass);\r
- }\r
- },\r
-\r
- beforeBlur : Ext.emptyFn, \r
- \r
- <div id="method-Ext.form.TriggerField-setEditable"></div>/**\r
- * Allow or prevent the user from directly editing the field text. If false is passed,\r
- * the user will only be able to modify the field using the trigger. This method\r
- * is the runtime equivalent of setting the 'editable' config option at config time.\r
- * @param {Boolean} value True to allow the user to directly edit the field text\r
- */\r
- setEditable : function(value){\r
- if(value == this.editable){\r
- return;\r
- }\r
- this.editable = value;\r
- if(!value){\r
- this.el.addClass('x-trigger-noedit').on('click', this.onTriggerClick, this).dom.setAttribute('readOnly', true);\r
- }else{\r
- this.el.removeClass('x-trigger-noedit').un('click', this.onTriggerClick, this).dom.removeAttribute('readOnly');\r
- }\r
- },\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
- <div id="method-Ext.form.TriggerField-onTriggerClick"></div>/**\r
- * The function that should handle the trigger's click event. This method does nothing by default\r
- * until overridden by an implementing function. See Ext.form.ComboBox and Ext.form.DateField for\r
- * sample implementations.\r
- * @method\r
- * @param {EventObject} e\r
- */\r
- onTriggerClick : Ext.emptyFn\r
-\r
- <div id="cfg-Ext.form.TriggerField-grow"></div>/**\r
- * @cfg {Boolean} grow @hide\r
- */\r
- <div id="cfg-Ext.form.TriggerField-growMin"></div>/**\r
- * @cfg {Number} growMin @hide\r
- */\r
- <div id="cfg-Ext.form.TriggerField-growMax"></div>/**\r
- * @cfg {Number} growMax @hide\r
- */\r
-});\r
-\r
-<div id="cls-Ext.form.TwinTriggerField"></div>/**\r
- * @class Ext.form.TwinTriggerField\r
- * @extends Ext.form.TriggerField\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:\r
- * <a href="http://extjs.com/deploy/ext/examples/form/custom.html">http://extjs.com/deploy/ext/examples/form/custom.html</a>\r
- */\r
-Ext.form.TwinTriggerField = Ext.extend(Ext.form.TriggerField, {\r
- <div id="cfg-Ext.form.TwinTriggerField-triggerConfig"></div>/**\r
- * @cfg {Mixed} triggerConfig\r
- * <p>A {@link Ext.DomHelper DomHelper} config object specifying the structure of the trigger elements\r
- * for this Field. (Optional).</p>\r
- * <p>Specify this when you need a customized element to contain the two trigger elements for this Field.\r
- * Each trigger element must be marked by the CSS class <tt>x-form-trigger</tt> (also see\r
- * <tt>{@link #trigger1Class}</tt> and <tt>{@link #trigger2Class}</tt>).</p>\r
- * <p>Note that when using this option, it is the developer's responsibility to ensure correct sizing,\r
- * positioning and appearance of the triggers.</p>\r
- */\r
- <div id="cfg-Ext.form.TwinTriggerField-trigger1Class"></div>/**\r
- * @cfg {String} trigger1Class\r
- * An additional CSS class used to style the trigger button. The trigger will always get the\r
- * class <tt>'x-form-trigger'</tt> by default and <tt>triggerClass</tt> will be <b>appended</b> if specified.\r
- */\r
- <div id="cfg-Ext.form.TwinTriggerField-trigger2Class"></div>/**\r
- * @cfg {String} trigger2Class\r
- * An additional CSS class used to style the trigger button. The trigger will always get the\r
- * class <tt>'x-form-trigger'</tt> by default and <tt>triggerClass</tt> will be <b>appended</b> if specified.\r
- */\r
-\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
- var triggerField = this;\r
- ts.each(function(t, all, index){\r
- var triggerIndex = 'Trigger'+(index+1);\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
- this['hidden' + triggerIndex] = true;\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
- this['hidden' + triggerIndex] = false;\r
- };\r
- \r
- if(this['hide'+triggerIndex]){\r
- t.dom.style.display = 'none';\r
- this['hidden' + triggerIndex] = true;\r
- }\r
- this.mon(t, '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
- getTriggerWidth: function(){\r
- var tw = 0;\r
- Ext.each(this.triggers, function(t, index){\r
- var triggerIndex = 'Trigger' + (index + 1),\r
- w = t.getWidth();\r
- if(w === 0 && !this['hidden' + triggerIndex]){\r
- tw += this.defaultTriggerWidth;\r
- }else{\r
- tw += w;\r
- }\r
- }, this);\r
- return tw;\r
- },\r
- \r
- // private\r
- onDestroy : function() {\r
- Ext.destroy(this.triggers);\r
- Ext.form.TwinTriggerField.superclass.onDestroy.call(this);\r
- },\r
-\r
- <div id="method-Ext.form.TwinTriggerField-onTrigger1Click"></div>/**\r
- * The function that should handle the trigger's click event. This method does nothing by default\r
- * until overridden by an implementing function. See {@link Ext.form.TriggerField#onTriggerClick}\r
- * for additional information. \r
- * @method\r
- * @param {EventObject} e\r
- */\r
- onTrigger1Click : Ext.emptyFn,\r
- <div id="method-Ext.form.TwinTriggerField-onTrigger2Click"></div>/**\r
- * The function that should handle the trigger's click event. This method does nothing by default\r
- * until overridden by an implementing function. See {@link Ext.form.TriggerField#onTriggerClick}\r
- * for additional information. \r
- * @method\r
- * @param {EventObject} e\r
- */\r
- onTrigger2Click : Ext.emptyFn\r
-});\r
-Ext.reg('trigger', Ext.form.TriggerField);</pre>
+<div id="cls-Ext.form.TriggerField"></div>/**
+ * @class Ext.form.TriggerField
+ * @extends Ext.form.TextField
+ * Provides a convenient wrapper for TextFields that adds a clickable trigger button (looks like a combobox by default).
+ * The trigger has no default action, so you must assign a function to implement the trigger click handler by
+ * overriding {@link #onTriggerClick}. You can create a TriggerField directly, as it renders exactly like a combobox
+ * for which you can provide a custom implementation. For example:
+ * <pre><code>
+var trigger = new Ext.form.TriggerField();
+trigger.onTriggerClick = myTriggerFn;
+trigger.applyToMarkup('my-field');
+</code></pre>
+ *
+ * However, in general you will most likely want to use TriggerField as the base class for a reusable component.
+ * {@link Ext.form.DateField} and {@link Ext.form.ComboBox} are perfect examples of this.
+ *
+ * @constructor
+ * Create a new TriggerField.
+ * @param {Object} config Configuration options (valid {@Ext.form.TextField} config options will also be applied
+ * to the base TextField)
+ * @xtype trigger
+ */
+Ext.form.TriggerField = Ext.extend(Ext.form.TextField, {
+ <div id="cfg-Ext.form.TriggerField-triggerClass"></div>/**
+ * @cfg {String} triggerClass
+ * An additional CSS class used to style the trigger button. The trigger will always get the
+ * class <tt>'x-form-trigger'</tt> by default and <tt>triggerClass</tt> will be <b>appended</b> if specified.
+ */
+ <div id="cfg-Ext.form.TriggerField-triggerConfig"></div>/**
+ * @cfg {Mixed} triggerConfig
+ * <p>A {@link Ext.DomHelper DomHelper} config object specifying the structure of the
+ * trigger element for this Field. (Optional).</p>
+ * <p>Specify this when you need a customized element to act as the trigger button for a TriggerField.</p>
+ * <p>Note that when using this option, it is the developer's responsibility to ensure correct sizing, positioning
+ * and appearance of the trigger. Defaults to:</p>
+ * <pre><code>{tag: "img", src: Ext.BLANK_IMAGE_URL, cls: "x-form-trigger " + this.triggerClass}</code></pre>
+ */
+ <div id="cfg-Ext.form.TriggerField-autoCreate"></div>/**
+ * @cfg {String/Object} autoCreate <p>A {@link Ext.DomHelper DomHelper} element spec, or true for a default
+ * element spec. Used to create the {@link Ext.Component#getEl Element} which will encapsulate this Component.
+ * See <tt>{@link Ext.Component#autoEl autoEl}</tt> for details. Defaults to:</p>
+ * <pre><code>{tag: "input", type: "text", size: "16", autocomplete: "off"}</code></pre>
+ */
+ defaultAutoCreate : {tag: "input", type: "text", size: "16", autocomplete: "off"},
+ <div id="cfg-Ext.form.TriggerField-hideTrigger"></div>/**
+ * @cfg {Boolean} hideTrigger <tt>true</tt> to hide the trigger element and display only the base
+ * text field (defaults to <tt>false</tt>)
+ */
+ hideTrigger:false,
+ <div id="cfg-Ext.form.TriggerField-editable"></div>/**
+ * @cfg {Boolean} editable <tt>false</tt> to prevent the user from typing text directly into the field,
+ * the field will only respond to a click on the trigger to set the value. (defaults to <tt>true</tt>).
+ */
+ editable: true,
+ <div id="cfg-Ext.form.TriggerField-readOnly"></div>/**
+ * @cfg {Boolean} readOnly <tt>true</tt> to prevent the user from changing the field, and
+ * hides the trigger. Superceeds the editable and hideTrigger options if the value is true.
+ * (defaults to <tt>false</tt>)
+ */
+ readOnly: false,
+ <div id="cfg-Ext.form.TriggerField-wrapFocusClass"></div>/**
+ * @cfg {String} wrapFocusClass The class added to the to the wrap of the trigger element. Defaults to
+ * <tt>x-trigger-wrap-focus</tt>.
+ */
+ wrapFocusClass: 'x-trigger-wrap-focus',
+ <div id="method-Ext.form.TriggerField-autoSize"></div>/**
+ * @hide
+ * @method autoSize
+ */
+ autoSize: Ext.emptyFn,
+ // private
+ monitorTab : true,
+ // private
+ deferHeight : true,
+ // private
+ mimicing : false,
+
+ actionMode: 'wrap',
+
+ defaultTriggerWidth: 17,
+
+ // private
+ onResize : function(w, h){
+ Ext.form.TriggerField.superclass.onResize.call(this, w, h);
+ var tw = this.getTriggerWidth();
+ if(Ext.isNumber(w)){
+ this.el.setWidth(w - tw);
+ }
+ this.wrap.setWidth(this.el.getWidth() + tw);
+ },
+
+ getTriggerWidth: function(){
+ var tw = this.trigger.getWidth();
+ if(!this.hideTrigger && !this.readOnly && tw === 0){
+ tw = this.defaultTriggerWidth;
+ }
+ return tw;
+ },
+
+ // private
+ alignErrorIcon : function(){
+ if(this.wrap){
+ this.errorIcon.alignTo(this.wrap, 'tl-tr', [2, 0]);
+ }
+ },
+
+ // private
+ onRender : function(ct, position){
+ this.doc = Ext.isIE ? Ext.getBody() : Ext.getDoc();
+ Ext.form.TriggerField.superclass.onRender.call(this, ct, position);
+
+ this.wrap = this.el.wrap({cls: 'x-form-field-wrap x-form-field-trigger-wrap'});
+ this.trigger = this.wrap.createChild(this.triggerConfig ||
+ {tag: "img", src: Ext.BLANK_IMAGE_URL, alt: "", cls: "x-form-trigger " + this.triggerClass});
+ this.initTrigger();
+ if(!this.width){
+ this.wrap.setWidth(this.el.getWidth()+this.trigger.getWidth());
+ }
+ this.resizeEl = this.positionEl = this.wrap;
+ },
+
+ getWidth: function() {
+ return(this.el.getWidth() + this.trigger.getWidth());
+ },
+
+ updateEditState: function(){
+ if(this.rendered){
+ if (this.readOnly) {
+ this.el.dom.readOnly = true;
+ this.el.addClass('x-trigger-noedit');
+ this.mun(this.el, 'click', this.onTriggerClick, this);
+ this.trigger.setDisplayed(false);
+ } else {
+ if (!this.editable) {
+ this.el.dom.readOnly = true;
+ this.el.addClass('x-trigger-noedit');
+ this.mon(this.el, 'click', this.onTriggerClick, this);
+ } else {
+ this.el.dom.readOnly = false;
+ this.el.removeClass('x-trigger-noedit');
+ this.mun(this.el, 'click', this.onTriggerClick, this);
+ }
+ this.trigger.setDisplayed(!this.hideTrigger);
+ }
+ this.onResize(this.width || this.wrap.getWidth());
+ }
+ },
+
+ <div id="method-Ext.form.TriggerField-setHideTrigger"></div>/**
+ * Changes the hidden status of the trigger.
+ * @param {Boolean} hideTrigger True to hide the trigger, false to show it.
+ */
+ setHideTrigger: function(hideTrigger){
+ if(hideTrigger != this.hideTrigger){
+ this.hideTrigger = hideTrigger;
+ this.updateEditState();
+ }
+ },
+
+ <div id="method-Ext.form.TriggerField-setEditable"></div>/**
+ * Allow or prevent the user from directly editing the field text. If false is passed,
+ * the user will only be able to modify the field using the trigger. Will also add
+ * a click event to the text field which will call the trigger. This method
+ * is the runtime equivalent of setting the {@link #editable} config option at config time.
+ * @param {Boolean} value True to allow the user to directly edit the field text.
+ */
+ setEditable: function(editable){
+ if(editable != this.editable){
+ this.editable = editable;
+ this.updateEditState();
+ }
+ },
+
+ <div id="method-Ext.form.TriggerField-setReadOnly"></div>/**
+ * Setting this to true will supersede settings {@link #editable} and {@link #hideTrigger}.
+ * Setting this to false will defer back to {@link #editable} and {@link #hideTrigger}. This method
+ * is the runtime equivalent of setting the {@link #readOnly} config option at config time.
+ * @param {Boolean} value True to prevent the user changing the field and explicitly
+ * hide the trigger.
+ */
+ setReadOnly: function(readOnly){
+ if(readOnly != this.readOnly){
+ this.readOnly = readOnly;
+ this.updateEditState();
+ }
+ },
+
+ afterRender : function(){
+ Ext.form.TriggerField.superclass.afterRender.call(this);
+ this.updateEditState();
+ },
+
+ // private
+ initTrigger : function(){
+ this.mon(this.trigger, 'click', this.onTriggerClick, this, {preventDefault:true});
+ this.trigger.addClassOnOver('x-form-trigger-over');
+ this.trigger.addClassOnClick('x-form-trigger-click');
+ },
+
+ // private
+ onDestroy : function(){
+ Ext.destroy(this.trigger, this.wrap);
+ if (this.mimicing){
+ this.doc.un('mousedown', this.mimicBlur, this);
+ }
+ delete this.doc;
+ Ext.form.TriggerField.superclass.onDestroy.call(this);
+ },
+
+ // private
+ onFocus : function(){
+ Ext.form.TriggerField.superclass.onFocus.call(this);
+ if(!this.mimicing){
+ this.wrap.addClass(this.wrapFocusClass);
+ this.mimicing = true;
+ this.doc.on('mousedown', this.mimicBlur, this, {delay: 10});
+ if(this.monitorTab){
+ this.on('specialkey', this.checkTab, this);
+ }
+ }
+ },
+
+ // private
+ checkTab : function(me, e){
+ if(e.getKey() == e.TAB){
+ this.triggerBlur();
+ }
+ },
+
+ // private
+ onBlur : Ext.emptyFn,
+
+ // private
+ mimicBlur : function(e){
+ if(!this.isDestroyed && !this.wrap.contains(e.target) && this.validateBlur(e)){
+ this.triggerBlur();
+ }
+ },
+
+ // private
+ triggerBlur : function(){
+ this.mimicing = false;
+ this.doc.un('mousedown', this.mimicBlur, this);
+ if(this.monitorTab && this.el){
+ this.un('specialkey', this.checkTab, this);
+ }
+ Ext.form.TriggerField.superclass.onBlur.call(this);
+ if(this.wrap){
+ this.wrap.removeClass(this.wrapFocusClass);
+ }
+ },
+
+ beforeBlur : Ext.emptyFn,
+
+ // private
+ // This should be overriden by any subclass that needs to check whether or not the field can be blurred.
+ validateBlur : function(e){
+ return true;
+ },
+
+ <div id="method-Ext.form.TriggerField-onTriggerClick"></div>/**
+ * The function that should handle the trigger's click event. This method does nothing by default
+ * until overridden by an implementing function. See Ext.form.ComboBox and Ext.form.DateField for
+ * sample implementations.
+ * @method
+ * @param {EventObject} e
+ */
+ onTriggerClick : Ext.emptyFn
+
+ <div id="cfg-Ext.form.TriggerField-grow"></div>/**
+ * @cfg {Boolean} grow @hide
+ */
+ <div id="cfg-Ext.form.TriggerField-growMin"></div>/**
+ * @cfg {Number} growMin @hide
+ */
+ <div id="cfg-Ext.form.TriggerField-growMax"></div>/**
+ * @cfg {Number} growMax @hide
+ */
+});
+
+<div id="cls-Ext.form.TwinTriggerField"></div>/**
+ * @class Ext.form.TwinTriggerField
+ * @extends Ext.form.TriggerField
+ * TwinTriggerField is not a public class to be used directly. It is meant as an abstract base class
+ * to be extended by an implementing class. For an example of implementing this class, see the custom
+ * SearchField implementation here:
+ * <a href="http://extjs.com/deploy/ext/examples/form/custom.html">http://extjs.com/deploy/ext/examples/form/custom.html</a>
+ */
+Ext.form.TwinTriggerField = Ext.extend(Ext.form.TriggerField, {
+ <div id="cfg-Ext.form.TwinTriggerField-triggerConfig"></div>/**
+ * @cfg {Mixed} triggerConfig
+ * <p>A {@link Ext.DomHelper DomHelper} config object specifying the structure of the trigger elements
+ * for this Field. (Optional).</p>
+ * <p>Specify this when you need a customized element to contain the two trigger elements for this Field.
+ * Each trigger element must be marked by the CSS class <tt>x-form-trigger</tt> (also see
+ * <tt>{@link #trigger1Class}</tt> and <tt>{@link #trigger2Class}</tt>).</p>
+ * <p>Note that when using this option, it is the developer's responsibility to ensure correct sizing,
+ * positioning and appearance of the triggers.</p>
+ */
+ <div id="cfg-Ext.form.TwinTriggerField-trigger1Class"></div>/**
+ * @cfg {String} trigger1Class
+ * An additional CSS class used to style the trigger button. The trigger will always get the
+ * class <tt>'x-form-trigger'</tt> by default and <tt>triggerClass</tt> will be <b>appended</b> if specified.
+ */
+ <div id="cfg-Ext.form.TwinTriggerField-trigger2Class"></div>/**
+ * @cfg {String} trigger2Class
+ * An additional CSS class used to style the trigger button. The trigger will always get the
+ * class <tt>'x-form-trigger'</tt> by default and <tt>triggerClass</tt> will be <b>appended</b> if specified.
+ */
+
+ initComponent : function(){
+ Ext.form.TwinTriggerField.superclass.initComponent.call(this);
+
+ this.triggerConfig = {
+ tag:'span', cls:'x-form-twin-triggers', cn:[
+ {tag: "img", src: Ext.BLANK_IMAGE_URL, alt: "", cls: "x-form-trigger " + this.trigger1Class},
+ {tag: "img", src: Ext.BLANK_IMAGE_URL, alt: "", cls: "x-form-trigger " + this.trigger2Class}
+ ]};
+ },
+
+ getTrigger : function(index){
+ return this.triggers[index];
+ },
+
+ afterRender: function(){
+ Ext.form.TwinTriggerField.superclass.afterRender.call(this);
+ var triggers = this.triggers,
+ i = 0,
+ len = triggers.length;
+
+ for(; i < len; ++i){
+ if(this['hideTrigger' + (i + 1)]){
+ triggers[i].hide();
+ }
+
+ }
+ },
+
+ initTrigger : function(){
+ var ts = this.trigger.select('.x-form-trigger', true),
+ triggerField = this;
+
+ ts.each(function(t, all, index){
+ var triggerIndex = 'Trigger'+(index+1);
+ t.hide = function(){
+ var w = triggerField.wrap.getWidth();
+ this.dom.style.display = 'none';
+ triggerField.el.setWidth(w-triggerField.trigger.getWidth());
+ triggerField['hidden' + triggerIndex] = true;
+ };
+ t.show = function(){
+ var w = triggerField.wrap.getWidth();
+ this.dom.style.display = '';
+ triggerField.el.setWidth(w-triggerField.trigger.getWidth());
+ triggerField['hidden' + triggerIndex] = false;
+ };
+ this.mon(t, 'click', this['on'+triggerIndex+'Click'], this, {preventDefault:true});
+ t.addClassOnOver('x-form-trigger-over');
+ t.addClassOnClick('x-form-trigger-click');
+ }, this);
+ this.triggers = ts.elements;
+ },
+
+ getTriggerWidth: function(){
+ var tw = 0;
+ Ext.each(this.triggers, function(t, index){
+ var triggerIndex = 'Trigger' + (index + 1),
+ w = t.getWidth();
+ if(w === 0 && !this['hidden' + triggerIndex]){
+ tw += this.defaultTriggerWidth;
+ }else{
+ tw += w;
+ }
+ }, this);
+ return tw;
+ },
+
+ // private
+ onDestroy : function() {
+ Ext.destroy(this.triggers);
+ Ext.form.TwinTriggerField.superclass.onDestroy.call(this);
+ },
+
+ <div id="method-Ext.form.TwinTriggerField-onTrigger1Click"></div>/**
+ * The function that should handle the trigger's click event. This method does nothing by default
+ * until overridden by an implementing function. See {@link Ext.form.TriggerField#onTriggerClick}
+ * for additional information.
+ * @method
+ * @param {EventObject} e
+ */
+ onTrigger1Click : Ext.emptyFn,
+ <div id="method-Ext.form.TwinTriggerField-onTrigger2Click"></div>/**
+ * The function that should handle the trigger's click event. This method does nothing by default
+ * until overridden by an implementing function. See {@link Ext.form.TriggerField#onTriggerClick}
+ * for additional information.
+ * @method
+ * @param {EventObject} e
+ */
+ onTrigger2Click : Ext.emptyFn
+});
+Ext.reg('trigger', Ext.form.TriggerField);
+</pre>
</body>
</html>
\ No newline at end of file