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

📄 component.js

📁 ajax框架extjs是一套完整的富客户端解决方案
💻 JS
📖 第 1 页 / 共 3 页
字号:
     * <p>Components attempt to save state when one of the events listed in the {@link #stateEvents}     * configuration fires.</p>     * <p>You can perform extra processing on state save and restore by attaching handlers to the     * {@link #beforestaterestore}, {@link staterestore}, {@link beforestatesave} and {@link statesave} events</p>     */    /**     * @cfg {String} stateId     * The unique id for this component to use for state management purposes (defaults to the component id).     * <p>See {@link #stateful} for an explanation of saving and restoring Component state.</p>     */    /* //internal - to be set by subclasses     * @cfg {Array} stateEvents     * An array of events that, when fired, should trigger this component to save its state (defaults to none).     * These can be any types of events supported by this component, including browser or custom events (e.g.,     * ['click', 'customerchange']).     * <p>See {@link #stateful} for an explanation of saving and restoring Component state.</p>     */    /**     * @cfg {String} disabledClass     * CSS class added to the component when it is disabled (defaults to "x-item-disabled").     */    disabledClass : "x-item-disabled",	/**	 * @cfg {Boolean} allowDomMove	 * Whether the component can move the Dom node when rendering (defaults to true).	 */    allowDomMove : true,	/**	 * @cfg {Boolean} autoShow	 * True if the component should check for hidden classes (e.g. 'x-hidden' or 'x-hide-display') and remove	 * them on render (defaults to false).	 */    autoShow : false,    /**     * @cfg {String} hideMode     * How this component should hidden. Supported values are "visibility" (css visibility), "offsets" (negative     * offset position) and "display" (css display) - defaults to "display".     */    hideMode: 'display',    /**     * @cfg {Boolean} hideParent     * True to hide and show the component's container when hide/show is called on the component, false to hide     * and show the component itself (defaults to false).  For example, this can be used as a shortcut for a hide     * button on a window by setting hide:true on the button when adding it to its parent container.     */    hideParent: false,    /**     * The component's owner {@link Ext.Container} (defaults to undefined, and is set automatically when     * the component is added to a container).  Read-only.     * @type Ext.Container     * @property ownerCt     */    /**     * True if this component is hidden. Read-only.     * @type Boolean     * @property     */    hidden : false,    /**     * True if this component is disabled. Read-only.     * @type Boolean     * @property     */    disabled : false,    /**     * True if this component has been rendered. Read-only.     * @type Boolean     * @property     */    rendered : false,    // private    ctype : "Ext.Component",    // private    actionMode : "el",    // private    getActionEl : function(){        return this[this.actionMode];    },    initPlugin : function(p){        p.init(this);        return p;    },    /* // protected     * Function to be implemented by Component subclasses to be part of standard component initialization flow (it is empty by default).     * <pre><code>// Traditional constructor:Ext.Foo = function(config){	// call superclass constructor:    Ext.Foo.superclass.constructor.call(this, config);    this.addEvents({		// add events    });};Ext.extend(Ext.Foo, Ext.Bar, {   // class body}// initComponent replaces the constructor:Ext.Foo = Ext.extend(Ext.Bar, {    initComponent : function(){		// call superclass initComponent        Ext.Container.superclass.initComponent.call(this);        this.addEvents({            // add events        });    }}</code></pre>     */    initComponent : Ext.emptyFn,    /**     * <p>Render this Components into the passed HTML element.</p>     * <p><b>If you are using a {@link Ext.Container Container} object to house this Component, then     * do not use the render method.</b></p>     * <p>A Container's child Components are rendered by that Container's     * {@link Ext.Container#layout layout} manager when the Container is first rendered.</p>     * <p>Certain layout managers allow dynamic addition of child components. Those that do     * include {@link Ext.layout.CardLayout}, {@link Ext.layout.AnchorLayout},     * {@link Ext.layout.FormLayout}, {@link Ext.layout.TableLayout}.</p>     * <p>If the Container is already rendered when a new child Component is added, you may need to call     * the Container's {@link Ext.Container#doLayout doLayout} to refresh the view which causes any     * unrendered child Components to be rendered. This is required so that you can add multiple     * child components if needed while only refreshing the layout once.</p>     * <p>When creating complex UIs, it is important to remember that sizing and positioning     * of child items is the responsibility of the Container's {@link Ext.Container#layout layout} manager.     * If you expect child items to be sized in response to user interactions, you must     * configure the Container with a layout manager which creates and manages the type of layout you     * have in mind.</p>     * <p><b>Omitting the Container's {@link Ext.Container#layout layout} config means that a basic     * layout manager is used which does nothnig but render child components sequentially into the     * Container. No sizing or positioning will be performed in this situation.</b></p>     * @param {Element/HTMLElement/String} container (optional) The element this Component should be     * rendered into. If it is being created from existing markup, this should be omitted.     * @param {String/Number} position (optional) The element ID or DOM node index within the container <b>before</b>     * which this component will be inserted (defaults to appending to the end of the container)     */    render : function(container, position){        if(!this.rendered && this.fireEvent("beforerender", this) !== false){            if(!container && this.el){                this.el = Ext.get(this.el);                container = this.el.dom.parentNode;                this.allowDomMove = false;            }            this.container = Ext.get(container);            if(this.ctCls){                this.container.addClass(this.ctCls);            }            this.rendered = true;            if(position !== undefined){                if(typeof position == 'number'){                    position = this.container.dom.childNodes[position];                }else{                    position = Ext.getDom(position);                }            }            this.onRender(this.container, position || null);            if(this.autoShow){                this.el.removeClass(['x-hidden','x-hide-' + this.hideMode]);            }            if(this.cls){                this.el.addClass(this.cls);                delete this.cls;            }            if(this.style){                this.el.applyStyles(this.style);                delete this.style;            }            this.fireEvent("render", this);            this.afterRender(this.container);            if(this.hidden){                this.hide();            }            if(this.disabled){                this.disable();            }            if(this.stateful !== false){                this.initStateEvents();            }        }        return this;    },    // private    initState : function(config){        if(Ext.state.Manager){            var state = Ext.state.Manager.get(this.stateId || this.id);            if(state){                if(this.fireEvent('beforestaterestore', this, state) !== false){                    this.applyState(state);                    this.fireEvent('staterestore', this, state);                }            }        }    },    // private    initStateEvents : function(){        if(this.stateEvents){            for(var i = 0, e; e = this.stateEvents[i]; i++){                this.on(e, this.saveState, this, {delay:100});            }        }    },    // private    applyState : function(state, config){        if(state){            Ext.apply(this, state);        }    },    // private    getState : function(){        return null;    },    // private    saveState : function(){        if(Ext.state.Manager){            var state = this.getState();            if(this.fireEvent('beforestatesave', this, state) !== false){                Ext.state.Manager.set(this.stateId || this.id, state);                this.fireEvent('statesave', this, state);            }        }    },    /**     * Apply this component to existing markup that is valid. With this function, no call to render() is required.     * @param {String/HTMLElement} el      */    applyToMarkup : function(el){        this.allowDomMove = false;        this.el = Ext.get(el);        this.render(this.el.dom.parentNode);    },    /**     * Adds a CSS class to the component's underlying element.     * @param {string} cls The CSS class name to add     */    addClass : function(cls){        if(this.el){            this.el.addClass(cls);        }else{            this.cls = this.cls ? this.cls + ' ' + cls : cls;        }    },    /**     * Removes a CSS class from the component's underlying element.     * @param {string} cls The CSS class name to remove     */    removeClass : function(cls){        if(this.el){            this.el.removeClass(cls);        }else if(this.cls){            this.cls = this.cls.split(' ').remove(cls).join(' ');        }    },    // private    // default function is not really useful    onRender : function(ct, position){        if(this.autoEl){            if(typeof this.autoEl == 'string'){                this.el = document.createElement(this.autoEl);            }else{                var div = document.createElement('div');                Ext.DomHelper.overwrite(div, this.autoEl);                this.el = div.firstChild;            }            if (!this.el.id) {            	this.el.id = this.getId();            }        }        if(this.el){            this.el = Ext.get(this.el);            if(this.allowDomMove !== false){                ct.dom.insertBefore(this.el.dom, position);            }            if(this.overCls) {                this.el.addClassOnOver(this.overCls);            }           }    },    // private    getAutoCreate : function(){        var cfg = typeof this.autoCreate == "object" ?                      this.autoCreate : Ext.apply({}, this.defaultAutoCreate);        if(this.id && !cfg.id){            cfg.id = this.id;        }        return cfg;    },    // private    afterRender : Ext.emptyFn,    /**     * Destroys this component by purging any event listeners, removing the component's element from the DOM,     * removing the component from its {@link Ext.Container} (if applicable) and unregistering it from     * {@link Ext.ComponentMgr}.  Destruction is generally handled automatically by the framework and this method     * should usually not need to be called directly.     */

⌨️ 快捷键说明

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