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

📄 borderlayout.js

📁 EXT2.0的中文API源代码
💻 JS
📖 第 1 页 / 共 3 页
字号:
/** * @class Ext.layout.BorderLayout * @extends Ext.layout.ContainerLayout * <p>This is a multi-pane, application-oriented UI layout style that supports multiple nested panels, automatic * split bars between regions and built-in expanding and collapsing of regions. * This class is intended to be extended or created via the layout:'border' {@link Ext.Container#layout} config, * and should generally not need to be created directly via the new keyword.</p> * <p>BorderLayout does not have any direct config options (other than inherited ones).  All configs available * for customizing the BorderLayout are at the {@link Ext.layout.BorderLayout.Region} and * {@link Ext.layout.BorderLayout.SplitRegion} levels.  Example usage:</p> * <pre><code>var border = new Ext.Panel({    title: 'Border Layout',    layout:'border',    items: [{        title: 'South Panel',        region: 'south',        height: 100,        minSize: 75,        maxSize: 250,        margins: '0 5 5 5'    },{        title: 'West Panel',        region:'west',        margins: '5 0 0 5',        cmargins: '5 5 0 5',        width: 200,        minSize: 100,        maxSize: 300    },{        title: 'Main Content',        region:'center',        margins: '5 5 0 0'    }]});</code></pre> */Ext.layout.BorderLayout = Ext.extend(Ext.layout.ContainerLayout, {    // private    monitorResize:true,    // private    rendered : false,    // private    onLayout : function(ct, target){        var collapsed;        if(!this.rendered){            target.position();            target.addClass('x-border-layout-ct');            var items = ct.items.items;            collapsed = [];            for(var i = 0, len = items.length; i < len; i++) {                var c = items[i];                var pos = c.region;                if(c.collapsed){                    collapsed.push(c);                }                c.collapsed = false;                if(!c.rendered){                    c.cls = c.cls ? c.cls +' x-border-panel' : 'x-border-panel';                    c.render(target, i);                }                this[pos] = pos != 'center' && c.split ?                    new Ext.layout.BorderLayout.SplitRegion(this, c.initialConfig, pos) :                    new Ext.layout.BorderLayout.Region(this, c.initialConfig, pos);                this[pos].render(target, c);            }            this.rendered = true;        }        var size = target.getViewSize();        if(size.width < 20 || size.height < 20){ // display none?            return;        }        var w = size.width, h = size.height;        var centerW = w, centerH = h, centerY = 0, centerX = 0;        var n = this.north, s = this.south, west = this.west, e = this.east, c = this.center;        if(!c){            throw 'No center region defined in BorderLayout ' + ct.id;        }        if(n && n.isVisible()){            var b = n.getSize();            var m = n.getMargins();            b.width = w - (m.left+m.right);            b.x = m.left;            b.y = m.top;            centerY = b.height + b.y + m.bottom;            centerH -= centerY;            n.applyLayout(b);        }        if(s && s.isVisible()){            var b = s.getSize();            var m = s.getMargins();            b.width = w - (m.left+m.right);            b.x = m.left;            var totalHeight = (b.height + m.top + m.bottom);            b.y = h - totalHeight + m.top;            centerH -= totalHeight;            s.applyLayout(b);        }        if(west && west.isVisible()){            var b = west.getSize();            var m = west.getMargins();            b.height = centerH - (m.top+m.bottom);            b.x = m.left;            b.y = centerY + m.top;            var totalWidth = (b.width + m.left + m.right);            centerX += totalWidth;            centerW -= totalWidth;            west.applyLayout(b);        }        if(e && e.isVisible()){            var b = e.getSize();            var m = e.getMargins();            b.height = centerH - (m.top+m.bottom);            var totalWidth = (b.width + m.left + m.right);            b.x = w - totalWidth + m.left;            b.y = centerY + m.top;            centerW -= totalWidth;            e.applyLayout(b);        }        var m = c.getMargins();        var centerBox = {            x: centerX + m.left,            y: centerY + m.top,            width: centerW - (m.left+m.right),            height: centerH - (m.top+m.bottom)        };        c.applyLayout(centerBox);        if(collapsed){            for(var i = 0, len = collapsed.length; i < len; i++){                collapsed[i].collapse(false);            }        }        if(Ext.isIE && Ext.isStrict){ // workaround IE strict repainting issue            target.repaint();        }    }    /**     * @cfg {Mixed} activeItem @hide     */});/** * @class Ext.layout.BorderLayout.Region * This is a region of a BorderLayout that acts as a subcontainer within the layout.  Each region has its own * layout that is independent of other regions and the containing BorderLayout, and can be any of the valid * Ext layout types.  Region size is managed automatically and cannot be changed by the user -- for resizable * regions, see {@link Ext.layout.BorderLayout.SplitRegion}. * @constructor * Create a new Region. * @param {Layout} layout Any valid Ext layout class * @param {Object} config The configuration options * @param {String} position The region position.  Valid values are: north, south, east, west and center.  Every * BorderLayout must have a center region for the primary content -- all other regions are optional. */Ext.layout.BorderLayout.Region = function(layout, config, pos){    Ext.apply(this, config);    this.layout = layout;    this.position = pos;    this.state = {};    if(typeof this.margins == 'string'){        this.margins = this.layout.parseMargins(this.margins);    }    this.margins = Ext.applyIf(this.margins || {}, this.defaultMargins);    if(this.collapsible){        if(typeof this.cmargins == 'string'){            this.cmargins = this.layout.parseMargins(this.cmargins);        }        if(this.collapseMode == 'mini' && !this.cmargins){            this.cmargins = {left:0,top:0,right:0,bottom:0};        }else{            this.cmargins = Ext.applyIf(this.cmargins || {},                pos == 'north' || pos == 'south' ? this.defaultNSCMargins : this.defaultEWCMargins);        }    }};Ext.layout.BorderLayout.Region.prototype = {    /**     * @cfg {Boolean} animFloat     * When a collapsed region's bar is clicked, the region's panel will be displayed as a floated panel that will     * close again once the user mouses out of that panel (or clicks out if autoHide = false).  Setting animFloat     * to false will prevent the open and close of these floated panels from being animated (defaults to true).     */    /**     * @cfg {Boolean} autoHide     * When a collapsed region's bar is clicked, the region's panel will be displayed as a floated panel.  If     * autoHide is true, the panel will automatically hide after the user mouses out of the panel.  If autoHide     * is false, the panel will continue to display until the user clicks outside of the panel (defaults to true).     */    /**     * @cfg {String} collapseMode     * By default, collapsible regions are collapsed by clicking the expand/collapse tool button that renders into     * the region's title bar.  Optionally, when collapseMode is set to 'mini' the region's split bar will also     * display a small collapse button in the center of the bar.  In 'mini' mode the region will collapse to a     * thinner bar than in normal mode.  By default collapseMode is undefined, and the only two supported values     * are undefined and 'mini'.  Note that if a collapsible region does not have a title bar, then collapseMode     * must be set to 'mini' in order for the region to be collapsible by the user as the tool button will not     * be rendered.     */    /**     * @cfg {Object} margins     * An object containing margins to apply to the region in the format {left: (left margin), top: (top margin),     * right: (right margin), bottom: (bottom margin)}     */    /**     * @cfg {Object} cmargins     * An object containing margins to apply to the region's collapsed element in the format {left: (left margin),     * top: (top margin), right: (right margin), bottom: (bottom margin)}     */    /**     * @cfg {Boolean} collapsible     * True to allow the user to collapse this region (defaults to false).  If true, an expand/collapse tool button     * will automatically be rendered into the title bar of the region, otherwise the button will not be shown.     * Note that a title bar is required to display the toggle button -- if no region title is specified, the     * region will only be collapsible if {@link #collapseMode} is set to 'mini'.     */    collapsible : false,    /**     * @cfg {Boolean} split     * True to display a {@link Ext.SplitBar} between this region and its neighbor, allowing the user to resize     * the regions dynamically (defaults to false).  When split = true, it is common to specify a {@link #minSize}     * and {@link #maxSize} for the region.     */    split:false,    /**     * @cfg {Boolean} floatable     * True to allow clicking a collapsed region's bar to display the region's panel floated above the layout,     * false to force the user to fully expand a collapsed region by clicking the expand button to see it again     * (defaults to true).     */    floatable: true,    /**     * @cfg {Number} minWidth     * The minimum allowable width in pixels for this region (defaults to 50)     */    minWidth:50,    /**     * @cfg {Number} minHeight     * The minimum allowable height in pixels for this region (defaults to 50)     */    minHeight:50,    // private    defaultMargins : {left:0,top:0,right:0,bottom:0},    // private    defaultNSCMargins : {left:5,top:5,right:5,bottom:5},    // private    defaultEWCMargins : {left:5,top:0,right:5,bottom:0},    /**     * True if this region is collapsed. Read-only.     * @type Boolean     * @property     */    isCollapsed : false,    /**     * This region's panel.  Read-only.     * @type Ext.Panel     * @propery panel     */    /**     * This region's layout.  Read-only.     * @type Layout     * @propery layout     */    /**     * This region's layout position (north, south, east, west or center).  Read-only.     * @type String     * @property position     */    // private    render : function(ct, p){        this.panel = p;        p.el.enableDisplayMode('block');        this.targetEl = ct;        this.el = p.el;        var gs = p.getState, ps = this.position;        p.getState = function(){            return Ext.apply(gs.call(p) || {}, this.state);        }.createDelegate(this);        if(ps != 'center'){            p.allowQueuedExpand = false;            p.on({                beforecollapse: this.beforeCollapse,                collapse: this.onCollapse,                beforeexpand: this.beforeExpand,                expand: this.onExpand,                hide: this.onHide,                show: this.onShow,                scope: this            });            if(this.collapsible){                p.collapseEl = 'el';                p.slideAnchor = this.getSlideAnchor();            }            if(p.tools && p.tools.toggle){                p.tools.toggle.addClass('x-tool-collapse-'+ps);                p.tools.toggle.addClassOnOver('x-tool-collapse-'+ps+'-over');            }        }

⌨️ 快捷键说明

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