⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 field.js

📁 最强的js界面,超前卫的显示方式 把AJAX运用得淋漓尽致。
💻 JS
📖 第 1 页 / 共 2 页
字号:
/*
 * Ext JS Library 2.0.2
 * Copyright(c) 2006-2008, Ext JS, LLC.
 * licensing@extjs.com
 * 
 * http://extjs.com/license
 */

/** * @class Ext.form.Field * @extends Ext.BoxComponent * Base class for form fields that provides default event handling, sizing, value handling and other functionality. * @constructor * Creates a new Field * @param {Object} config Configuration options */Ext.form.Field = Ext.extend(Ext.BoxComponent,  {    /**     * @cfg {String} fieldLabel The label text to display next to this field (defaults to '')     */    /**     * @cfg {String} labelStyle A CSS style specification to apply directly to this field's label (defaults to the     * container's labelStyle value if set, or ''). For example, <code>labelStyle: 'font-weight:bold;'</code>.     */    /**     * @cfg {String} labelSeparator The standard separator to display after the text of each form label (defaults     * to the value of {@link Ext.layout.FormLayout#labelSeparator}, which is a colon ':' by default).  To display     * no separator for this field's label specify empty string ''.     */    /**     * @cfg {Boolean} hideLabel True to completely hide the label element (defaults to false)     */    /**     * @cfg {String} clearCls The CSS class used to provide field clearing (defaults to 'x-form-clear-left')     */    /**     * @cfg {String} itemCls An additional CSS class to apply to the wrapper element of this field (defaults to the container's itemCls     * value if set, or '').  Since it is applied to the wrapper, it allows you to write standard CSS rules that can apply to     * the field, the label (if specified) or any other element within the markup for the field.  Example use:     * <pre><code>// Apply a style to the field's label:&lt;style>    .required .x-form-item-label {font-weight:bold;color:red;}&lt;/style>new Ext.FormPanel({	height: 100,	renderTo: document.body,	items: [{		xtype: 'textfield',		fieldLabel: 'Name',		itemCls: 'required' //this label will be styled	},{		xtype: 'textfield',		fieldLabel: 'Favorite Color'	}]});</code></pre>     */    /**     * @cfg {String} invalidClass The CSS class to use when marking a field invalid (defaults to "x-form-invalid")     */    invalidClass : "x-form-invalid",    /**     * @cfg {String} invalidText The error text to use when marking a field invalid and no message is provided     * (defaults to "The value in this field is invalid")     */    invalidText : "The value in this field is invalid",    /**     * @cfg {String} focusClass The CSS class to use when the field receives focus (defaults to "x-form-focus")     */    focusClass : "x-form-focus",    /**     * @cfg {String/Boolean} validationEvent The event that should initiate field validation. Set to false to disable      automatic validation (defaults to "keyup").     */    validationEvent : "keyup",    /**     * @cfg {Boolean} validateOnBlur Whether the field should validate when it loses focus (defaults to true).     */    validateOnBlur : true,    /**     * @cfg {Number} validationDelay The length of time in milliseconds after user input begins until validation     * is initiated (defaults to 250)     */    validationDelay : 250,    /**     * @cfg {String/Object} autoCreate A DomHelper element spec, or true for a default element spec (defaults to     * {tag: "input", type: "text", size: "20", autocomplete: "off"})     */    defaultAutoCreate : {tag: "input", type: "text", size: "20", autocomplete: "off"},    /**     * @cfg {String} fieldClass The default CSS class for the field (defaults to "x-form-field")     */    fieldClass : "x-form-field",    /**     * @cfg {String} msgTarget The location where error text should display.  Should be one of the following values     * (defaults to 'qtip'):     *<pre>Value         Description-----------   ----------------------------------------------------------------------qtip          Display a quick tip when the user hovers over the fieldtitle         Display a default browser title attribute popupunder         Add a block div beneath the field containing the error textside          Add an error icon to the right of the field with a popup on hover[element id]  Add the error text directly to the innerHTML of the specified element</pre>     */    msgTarget : 'qtip',    /**     * @cfg {String} msgFx <b>Experimental</b> The effect used when displaying a validation message under the field     * (defaults to 'normal').     */    msgFx : 'normal',        /**     * @cfg {Boolean} readOnly True to mark the field as readOnly in HTML (defaults to false) -- Note: this only     * sets the element's readOnly DOM attribute.     */    readOnly : false,    /**     * @cfg {Boolean} disabled True to disable the field (defaults to false).     */    disabled : false,    /**     * @cfg {String} inputType The type attribute for input fields -- e.g. radio, text, password (defaults to "text").     */    /**     * @cfg {Number} tabIndex The tabIndex for this field. Note this only applies to fields that are rendered,     * not those which are built via applyTo (defaults to undefined).	 */    // private    isFormField : true,    // private    hasFocus : false,    /**     * @cfg {Mixed} value A value to initialize this field with.     */        /**     * @cfg {String} name The field's HTML name attribute.     */    /**     * @cfg {String} cls A CSS class to apply to the field's underlying element.     */	// private ??	initComponent : function(){        Ext.form.Field.superclass.initComponent.call(this);        this.addEvents(            /**             * @event focus             * Fires when this field receives input focus.             * @param {Ext.form.Field} this             */            'focus',            /**             * @event blur             * Fires when this field loses input focus.             * @param {Ext.form.Field} this             */            'blur',            /**             * @event specialkey             * Fires when any key related to navigation (arrows, tab, enter, esc, etc.) is pressed.  You can check             * {@link Ext.EventObject#getKey} to determine which key was pressed.             * @param {Ext.form.Field} this             * @param {Ext.EventObject} e The event object             */            'specialkey',            /**             * @event change             * Fires just before the field blurs if the field value has changed.             * @param {Ext.form.Field} this             * @param {Mixed} newValue The new value             * @param {Mixed} oldValue The original value             */            'change',            /**             * @event invalid             * Fires after the field has been marked as invalid.             * @param {Ext.form.Field} this             * @param {String} msg The validation message             */            'invalid',            /**             * @event valid             * Fires after the field has been validated with no errors.             * @param {Ext.form.Field} this             */            'valid'        );    },    /**     * Returns the name attribute of the field if available     * @return {String} name The field name     */    getName: function(){         return this.rendered && this.el.dom.name ? this.el.dom.name : (this.hiddenName || '');    },    // private    onRender : function(ct, position){        Ext.form.Field.superclass.onRender.call(this, ct, position);        if(!this.el){            var cfg = this.getAutoCreate();            if(!cfg.name){                cfg.name = this.name || this.id;            }            if(this.inputType){                cfg.type = this.inputType;            }            this.el = ct.createChild(cfg, position);        }        var type = this.el.dom.type;        if(type){            if(type == 'password'){                type = 'text';            }            this.el.addClass('x-form-'+type);        }        if(this.readOnly){            this.el.dom.readOnly = true;        }        if(this.tabIndex !== undefined){            this.el.dom.setAttribute('tabIndex', this.tabIndex);        }        this.el.addClass([this.fieldClass, this.cls]);        this.initValue();    },    // private    initValue : function(){        if(this.value !== undefined){            this.setValue(this.value);        }else if(this.el.dom.value.length > 0){            this.setValue(this.el.dom.value);        }    },    /**     * Returns true if this field has been changed since it was originally loaded and is not disabled.     */    isDirty : function() {        if(this.disabled) {            return false;        }        return String(this.getValue()) !== String(this.originalValue);    },    // private    afterRender : function(){        Ext.form.Field.superclass.afterRender.call(this);        this.initEvents();    },    // private    fireKey : function(e){        if(e.isSpecialKey()){            this.fireEvent("specialkey", this, e);        }    },    /**     * Resets the current field value to the originally loaded value and clears any validation messages     */    reset : function(){        this.setValue(this.originalValue);        this.clearInvalid();    },    // private    initEvents : function(){        this.el.on(Ext.isIE ? "keydown" : "keypress", this.fireKey,  this);        this.el.on("focus", this.onFocus,  this);        this.el.on("blur", this.onBlur,  this);        // reference to original value for reset        this.originalValue = this.getValue();    },

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -