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

📄 container.js

📁 1.. 需要jdom.jar和bsf.jar,否则无法跟spring整合. 2.. dwr生成的javascript函数会自动加一个回调函数的参数,如原来的函数是checkExist(String
💻 JS
📖 第 1 页 / 共 2 页
字号:
     * For a list of all available xtypes, see {@link Ext.Component}.     * @return {Ext.Component} component The Component (or config object) that was     * inserted with the Container's default config values applied.     */    insert : function(index, comp){        if(!this.items){            this.initItems();        }        var a = arguments, len = a.length;        if(len > 2){            for(var i = len-1; i >= 1; --i) {                this.insert(index, a[i]);            }            return;        }        var c = this.lookupComponent(this.applyDefaults(comp));        if(c.ownerCt == this && this.items.indexOf(c) < index){            --index;        }        if(this.fireEvent('beforeadd', this, c, index) !== false && this.onBeforeAdd(c) !== false){            this.items.insert(index, c);            c.ownerCt = this;            this.fireEvent('add', this, c, index);        }        return c;    },    // private    applyDefaults : function(c){        if(this.defaults){            if(typeof c == 'string'){                c = Ext.ComponentMgr.get(c);                Ext.apply(c, this.defaults);            }else if(!c.events){                Ext.applyIf(c, this.defaults);            }else{                Ext.apply(c, this.defaults);            }        }        return c;    },    // private    onBeforeAdd : function(item){        if(item.ownerCt){            item.ownerCt.remove(item, false);        }        if(this.hideBorders === true){            item.border = (item.border === true);        }    },    /**     * Removes a component from this container.  Fires the beforeremove event before removing, then fires     * the remove event after the component has been removed.     * @param {Component/String} component The component reference or id to remove     * @param {Boolean} autoDestroy (optional) True to automatically invoke the component's {@link Ext.Component#destroy} function     */    remove : function(comp, autoDestroy){        var c = this.getComponent(comp);        if(c && this.fireEvent('beforeremove', this, c) !== false){            this.items.remove(c);            delete c.ownerCt;            if(autoDestroy === true || (autoDestroy !== false && this.autoDestroy)){                c.destroy();            }            if(this.layout && this.layout.activeItem == c){                delete this.layout.activeItem;            }            this.fireEvent('remove', this, c);        }        return c;    },    /**     * Gets a direct child Component by id, or by index.     * @param {String/Number} id or index of child Component to return.     * @return Ext.Component     */    getComponent : function(comp){        if(typeof comp == 'object'){            return comp;        }        return this.items.get(comp);    },    // private    lookupComponent : function(comp){        if(typeof comp == 'string'){            return Ext.ComponentMgr.get(comp);        }else if(!comp.events){            return this.createComponent(comp);        }        return comp;    },    // private    createComponent : function(config){        return Ext.ComponentMgr.create(config, this.defaultType);    },    /**     * Force this container's layout to be recalculated. A call to this function is required after adding a new component     * to an already rendered container. If you are not dynamically adding and removing components after render, this     * function will generally not need to be called.     */    doLayout : function(){        if(this.rendered && this.layout){            this.layout.layout();        }        if(this.items){            var cs = this.items.items;            for(var i = 0, len = cs.length; i < len; i++) {                var c  = cs[i];                if(c.doLayout){                    c.doLayout();                }            }        }    },    /**     * Returns the layout currently in use by the container.  If the container does not currently have a layout     * set, a default {@link Ext.layout.ContainerLayout} will be created and set as the container's layout.     * @return {ContainerLayout} layout The container's layout     */    getLayout : function(){        if(!this.layout){            var layout = new Ext.layout.ContainerLayout(this.layoutConfig);            this.setLayout(layout);        }        return this.layout;    },    // private    onDestroy : function(){        if(this.items){            var cs = this.items.items;            for(var i = 0, len = cs.length; i < len; i++) {                Ext.destroy(cs[i]);            }        }        if(this.monitorResize){            Ext.EventManager.removeResizeListener(this.doLayout, this);        }        Ext.Container.superclass.onDestroy.call(this);    },    /**     * Bubbles up the component/container heirarchy, calling the specified function with each component. The scope (<i>this</i>) of     * function call will be the scope provided or the current component. The arguments to the function     * will be the args provided or the current component. If the function returns false at any point,     * the bubble is stopped.     * @param {Function} fn The function to call     * @param {Object} scope (optional) The scope of the function (defaults to current node)     * @param {Array} args (optional) The args to call the function with (default to passing the current component)     */    bubble : function(fn, scope, args){        var p = this;        while(p){            if(fn.apply(scope || p, args || [p]) === false){                break;            }            p = p.ownerCt;        }    },    /**     * Cascades down the component/container heirarchy from this component (called first), calling the specified function with     * each component. The scope (<i>this</i>) of     * function call will be the scope provided or the current component. The arguments to the function     * will be the args provided or the current component. If the function returns false at any point,     * the cascade is stopped on that branch.     * @param {Function} fn The function to call     * @param {Object} scope (optional) The scope of the function (defaults to current component)     * @param {Array} args (optional) The args to call the function with (defaults to passing the current component)     */    cascade : function(fn, scope, args){        if(fn.apply(scope || this, args || [this]) !== false){            if(this.items){                var cs = this.items.items;                for(var i = 0, len = cs.length; i < len; i++){                    if(cs[i].cascade){                        cs[i].cascade(fn, scope, args);                    }else{                        fn.apply(scope || this, args || [cs[i]]);                    }                }            }        }    },    /**     * Find a component under this container at any level by id     * @param {String} id     * @return Ext.Component     */    findById : function(id){        var m, ct = this;        this.cascade(function(c){            if(ct != c && c.id === id){                m = c;                return false;            }        });        return m || null;    },    /**     * Find a component under this container at any level by xtype or class     * @param {String/Class} xtype The xtype string for a component, or the class of the component directly     * @return {Array} Array of Ext.Components     */    findByType : function(xtype){        return typeof xtype == 'function' ?            this.findBy(function(c){                return c.constructor === xtype;            }) :            this.findBy(function(c){                return c.constructor.xtype === xtype;            });    },    /**     * Find a component under this container at any level by property     * @param {String} prop     * @param {String} value     * @return {Array} Array of Ext.Components     */    find : function(prop, value){        return this.findBy(function(c){            return c[prop] === value;        });    },    /**     * Find a component under this container at any level by a custom function. If the passed function returns     * true, the component will be included in the results. The passed function is called with the arguments (component, this container).     * @param {Function} fcn     * @param {Object} scope (optional)     * @return {Array} Array of Ext.Components     */    findBy : function(fn, scope){        var m = [], ct = this;        this.cascade(function(c){            if(ct != c && fn.call(scope || c, c, ct) === true){                m.push(c);            }        });        return m;    }});Ext.Container.LAYOUTS = {};Ext.reg('container', Ext.Container);

⌨️ 快捷键说明

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