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

📄 component.js

📁 ajax框架extjs是一套完整的富客户端解决方案
💻 JS
📖 第 1 页 / 共 3 页
字号:
/*
 * Ext JS Library 2.2
 * Copyright(c) 2006-2008, Ext JS, LLC.
 * licensing@extjs.com
 * 
 * http://extjs.com/license
 */

/** * @class Ext.Component * @extends Ext.util.Observable * <p>Base class for all Ext components.  All subclasses of Component can automatically participate in the standard * Ext component lifecycle of creation, rendering and destruction.  They also have automatic support for basic hide/show * and enable/disable behavior.  Component allows any subclass to be lazy-rendered into any {@link Ext.Container} and * to be automatically registered with the {@link Ext.ComponentMgr} so that it can be referenced at any time via * {@link Ext#getCmp}.  All visual widgets that require rendering into a layout should subclass Component (or * {@link Ext.BoxComponent} if managed box model handling is required).</p> * <p>Every component has a specific xtype, which is its Ext-specific type name, along with methods for checking the * xtype like {@link #getXType} and {@link #isXType}. This is the list of all valid xtypes:</p> * <pre>xtype            Class-------------    ------------------box              Ext.BoxComponentbutton           Ext.Buttoncolorpalette     Ext.ColorPalettecomponent        Ext.Componentcontainer        Ext.Containercycle            Ext.CycleButtondataview         Ext.DataViewdatepicker       Ext.DatePickereditor           Ext.Editoreditorgrid       Ext.grid.EditorGridPanelgrid             Ext.grid.GridPanelpaging           Ext.PagingToolbarpanel            Ext.Panelprogress         Ext.ProgressBarpropertygrid     Ext.grid.PropertyGridslider           Ext.Slidersplitbutton      Ext.SplitButtonstatusbar        Ext.StatusBartabpanel         Ext.TabPaneltreepanel        Ext.tree.TreePanelviewport         Ext.Viewportwindow           Ext.WindowToolbar components---------------------------------------toolbar          Ext.Toolbartbbutton         Ext.Toolbar.Buttontbfill           Ext.Toolbar.Filltbitem           Ext.Toolbar.Itemtbseparator      Ext.Toolbar.Separatortbspacer         Ext.Toolbar.Spacertbsplit          Ext.Toolbar.SplitButtontbtext           Ext.Toolbar.TextItemForm components---------------------------------------form             Ext.FormPanelcheckbox         Ext.form.Checkboxcombo            Ext.form.ComboBoxdatefield        Ext.form.DateFieldfield            Ext.form.Fieldfieldset         Ext.form.FieldSethidden           Ext.form.Hiddenhtmleditor       Ext.form.HtmlEditorlabel            Ext.form.Labelnumberfield      Ext.form.NumberFieldradio            Ext.form.Radiotextarea         Ext.form.TextAreatextfield        Ext.form.TextFieldtimefield        Ext.form.TimeFieldtrigger          Ext.form.TriggerField</pre> * @constructor * @param {Ext.Element/String/Object} config The configuration options.  If an element is passed, it is set as the internal * element and its id used as the component id.  If a string is passed, it is assumed to be the id of an existing element * and is used as the component id.  Otherwise, it is assumed to be a standard config object and is applied to the component. */Ext.Component = function(config){    config = config || {};    if(config.initialConfig){        if(config.isAction){           // actions            this.baseAction = config;        }        config = config.initialConfig; // component cloning / action set up    }else if(config.tagName || config.dom || typeof config == "string"){ // element object        config = {applyTo: config, id: config.id || config};    }    /**     * This Component's initial configuration specification. Read-only.     * @type Object     * @property initialConfig     */    this.initialConfig = config;    Ext.apply(this, config);    this.addEvents(        /**         * @event disable         * Fires after the component is disabled.	     * @param {Ext.Component} this	     */        'disable',        /**         * @event enable         * Fires after the component is enabled.	     * @param {Ext.Component} this	     */        'enable',        /**         * @event beforeshow         * Fires before the component is shown. Return false to stop the show.	     * @param {Ext.Component} this	     */        'beforeshow',        /**         * @event show         * Fires after the component is shown.	     * @param {Ext.Component} this	     */        'show',        /**         * @event beforehide         * Fires before the component is hidden. Return false to stop the hide.	     * @param {Ext.Component} this	     */        'beforehide',        /**         * @event hide         * Fires after the component is hidden.	     * @param {Ext.Component} this	     */        'hide',        /**         * @event beforerender         * Fires before the component is rendered. Return false to stop the render.	     * @param {Ext.Component} this	     */        'beforerender',        /**         * @event render         * Fires after the component is rendered.	     * @param {Ext.Component} this	     */        'render',        /**         * @event beforedestroy         * Fires before the component is destroyed. Return false to stop the destroy.	     * @param {Ext.Component} this	     */        'beforedestroy',        /**         * @event destroy         * Fires after the component is destroyed.	     * @param {Ext.Component} this	     */        'destroy',        /**         * @event beforestaterestore         * Fires before the state of the component is restored. Return false to stop the restore.	     * @param {Ext.Component} this	     * @param {Object} state The hash of state values	     */        'beforestaterestore',        /**         * @event staterestore         * Fires after the state of the component is restored.	     * @param {Ext.Component} this	     * @param {Object} state The hash of state values	     */        'staterestore',        /**         * @event beforestatesave         * Fires before the state of the component is saved to the configured state provider. Return false to stop the save.	     * @param {Ext.Component} this	     * @param {Object} state The hash of state values	     */        'beforestatesave',        /**         * @event statesave         * Fires after the state of the component is saved to the configured state provider.	     * @param {Ext.Component} this	     * @param {Object} state The hash of state values	     */        'statesave'    );    this.getId();    Ext.ComponentMgr.register(this);    Ext.Component.superclass.constructor.call(this);    if(this.baseAction){        this.baseAction.addComponent(this);    }    this.initComponent();    if(this.plugins){        if(Ext.isArray(this.plugins)){            for(var i = 0, len = this.plugins.length; i < len; i++){                this.plugins[i] = this.initPlugin(this.plugins[i]);            }        }else{            this.plugins = this.initPlugin(this.plugins);        }    }    if(this.stateful !== false){        this.initState(config);    }    if(this.applyTo){        this.applyToMarkup(this.applyTo);        delete this.applyTo;    }else if(this.renderTo){        this.render(this.renderTo);        delete this.renderTo;    }};// privateExt.Component.AUTO_ID = 1000;Ext.extend(Ext.Component, Ext.util.Observable, {    /**     * @cfg {String} id     * The unique id of this component (defaults to an auto-assigned id).     */    /**     * @cfg {String/Object} autoEl     * A tag name or DomHelper spec to create an element with. This is intended to create shorthand     * utility components inline via JSON. It should not be used for higher level components which already create     * their own elements. Example usage:     * <pre><code>{xtype:'box', autoEl: 'div', cls:'my-class'}{xtype:'box', autoEl: {tag:'blockquote', html:'autoEl is cool!'}} // with DomHelper</code></pre>     */    /**     * @cfg {String} xtype     * The registered xtype to create. This config option is not used when passing     * a config object into a constructor. This config option is used only when     * lazy instantiation is being used, and a child item of a Container is being     * specified not as a fully instantiated Component, but as a <i>Component config     * object</i>. The xtype will be looked up at render time up to determine what     * type of child Component to create.<br><br>     * The predefined xtypes are listed {@link Ext.Component here}.     * <br><br>     * If you subclass Components to create your own Components, you may register     * them using {@link Ext.ComponentMgr#registerType} in order to be able to     * take advantage of lazy instantiation and rendering.     */    /**     * @cfg {String} cls     * An optional extra CSS class that will be added to this component's Element (defaults to '').  This can be     * useful for adding customized styles to the component or any of its children using standard CSS rules.     */    /**     * @cfg {String} overCls     * An optional extra CSS class that will be added to this component's Element when the mouse moves     * over the Element, and removed when the mouse moves out. (defaults to '').  This can be     * useful for adding customized "active" or "hover" styles to the component or any of its children using standard CSS rules.     */    /**     * @cfg {String} style     * A custom style specification to be applied to this component's Element.  Should be a valid argument to     * {@link Ext.Element#applyStyles}.     */    /**     * @cfg {String} ctCls     * An optional extra CSS class that will be added to this component's container (defaults to '').  This can be     * useful for adding customized styles to the container or any of its children using standard CSS rules.     */    /**     * @cfg {Boolean} disabled     * Render this component disabled (default is false).     */    /**     * @cfg {Boolean} hidden     * Render this component hidden (default is false).     */    /**     * @cfg {Object/Array} plugins     * An object or array of objects that will provide custom functionality for this component.  The only     * requirement for a valid plugin is that it contain an init method that accepts a reference of type Ext.Component.     * When a component is created, if any plugins are available, the component will call the init method on each     * plugin, passing a reference to itself.  Each plugin can then call methods or respond to events on the     * component as needed to provide its functionality.     */    /**     * @cfg {Mixed} applyTo     * The id of the node, a DOM node or an existing Element corresponding to a DIV that is already present in     * the document that specifies some structural markup for this component.  When applyTo is used, constituent parts of     * the component can also be specified by id or CSS class name within the main element, and the component being created     * may attempt to create its subcomponents from that markup if applicable. Using this config, a call to render() is     * not required.  If applyTo is specified, any value passed for {@link #renderTo} will be ignored and the target     * element's parent node will automatically be used as the component's container.     */    /**     * @cfg {Mixed} renderTo     * The id of the node, a DOM node or an existing Element that will be the container to render this component into.     * Using this config, a call to render() is not required.     */    /**     * @cfg {Boolean} stateful     * A flag which causes the Component to attempt to restore the state of internal properties     * from a saved state on startup.<p>     * For state saving to work, the state manager's provider must have been set to an implementation     * of {@link Ext.state.Provider} which overrides the {@link Ext.state.Provider#set set}     * and {@link Ext.state.Provider#get get} methods to save and recall name/value pairs.     * A built-in implementation, {@link Ext.state.CookieProvider} is available.</p>     * <p>To set the state provider for the current page:</p>	     * <pre><code>Ext.state.Manager.setProvider(new Ext.state.CookieProvider());</code></pre>

⌨️ 快捷键说明

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