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

📄 borderlayout.js

📁 Ext JS是一个创建丰富互联网应用程序的跨浏览器的JavaScrip库。它包含:高效率
💻 JS
📖 第 1 页 / 共 3 页
字号:
/*
 * Ext JS Library 3.0 Pre-alpha
 * Copyright(c) 2006-2008, Ext JS, LLC.
 * licensing@extjs.com
 * 
 * http://extjs.com/license
 */

/** * @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 {@link Ext.layout.BorderLayout.Region#split split} bars between * {@link Ext.layout.BorderLayout.Region#BorderLayout.Region regions} and built-in * {@link Ext.layout.BorderLayout.Region#collapsible expanding and collapsing} of regions.</p> * <p>This class is intended to be extended or created via the <tt>layout:'border'</tt> * {@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 configuration options available for customizing the BorderLayout are at the * {@link Ext.layout.BorderLayout.Region} and {@link Ext.layout.BorderLayout.SplitRegion} * levels.</p> * <p>Example usage:</p> * <pre><code>var myBorderPanel = new Ext.Panel({    {@link Ext.Component#renderTo renderTo}: document.body,    {@link Ext.BoxComponent#width width}: 700,    {@link Ext.BoxComponent#height height}: 500,    {@link Ext.Panel#title title}: 'Border Layout',    {@link Ext.Container#layout layout}: 'border',    {@link Ext.Container#items items}: [{        {@link Ext.Panel#title title}: 'South Region is resizable',        {@link Ext.layout.BorderLayout.Region#BorderLayout.Region region}: 'south',     // position for region        {@link Ext.BoxComponent#height height}: 100,        {@link Ext.layout.BorderLayout.Region#split split}: true,         // enable resizing        {@link Ext.SplitBar#minSize minSize}: 75,         // defaults to {@link Ext.layout.BorderLayout.Region#minHeight 50}         {@link Ext.SplitBar#maxSize maxSize}: 150,        {@link Ext.layout.BorderLayout.Region#margins margins}: '0 5 5 5'    },{        // xtype: 'panel' implied by default        {@link Ext.Panel#title title}: 'West Region is collapsible',        {@link Ext.layout.BorderLayout.Region#BorderLayout.Region region}:'west',        {@link Ext.layout.BorderLayout.Region#margins margins}: '5 0 0 5',        {@link Ext.BoxComponent#width width}: 200,        {@link Ext.layout.BorderLayout.Region#collapsible collapsible}: true,   // make collapsible        {@link Ext.layout.BorderLayout.Region#cmargins cmargins}: '5 5 0 5', // adjust top margin when collapsed        {@link Ext.Component#id id}: 'west-region-container',        {@link Ext.Container#layout layout}: 'fit',        {@link Ext.Panel#unstyled unstyled}: true    },{        {@link Ext.Panel#title title}: 'Center Region',        {@link Ext.layout.BorderLayout.Region#BorderLayout.Region region}: 'center',     // center region is required, no width/height specified        {@link Ext.Component#xtype xtype}: 'container',        {@link Ext.Container#layout layout}: 'fit',        {@link Ext.layout.BorderLayout.Region#margins margins}: '5 5 0 0'    }]});</code></pre> * <p><b><u>Notes</u></b>:</p><div class="mdetail-params"><ul> * <li>Any container using the BorderLayout <b>must</b> have a child item with <tt>region:'center'</tt>. * The child item in the center region will always be resized to fill the remaining space not used by * the other regions in the layout.</li> * <li>Any child items with a region of <tt>west</tt> or <tt>east</tt> must have <tt>width</tt> defined * (an integer representing the number of pixels that the region should take up).</li> * <li>Any child items with a region of <tt>north</tt> or <tt>south</tt> must have <tt>height</tt> defined.</li> * <li>The regions of a BorderLayout are <b>fixed at render time</b> and thereafter, its child Components may not be removed or added</b>.  To add/remove * Components within a BorderLayout, have them wrapped by an additional Container which is directly * managed by the BorderLayout.  If the region is to be collapsible, the Container used directly * by the BorderLayout manager should be a Panel.  In the following example a Container (an Ext.Panel) * is added to the west region: * <div style="margin-left:16px"><pre><code>wrc = {@link Ext#getCmp Ext.getCmp}('west-region-container');wrc.{@link Ext.Panel#removeAll removeAll}();wrc.{@link Ext.Container#add add}({    title: 'Added Panel',    html: 'Some content'});wrc.{@link Ext.Container#doLayout doLayout}(); * </code></pre></div> * </li> * <li> To reference a {@link Ext.layout.BorderLayout.Region Region}: * <div style="margin-left:16px"><pre><code>wr = myBorderPanel.layout.west; * </code></pre></div> * </li> * </ul></div> */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.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?            if(collapsed){                this.restoreCollapsed = collapsed;            }            return;        }else if(this.restoreCollapsed){            collapsed = this.restoreCollapsed;            delete this.restoreCollapsed;        }        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 && Ext.layout.BorderLayout.WARN !== false){            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);        }        if(c){            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();        }    },    destroy: function() {        var r = ['north', 'south', 'east', 'west'];        for (var i = 0; i < r.length; i++) {            var region = this[r[i]];            if(region){                if(region.destroy){                    region.destroy();                }else if (region.split){                    region.split.destroy(true);                }            }        }        Ext.layout.BorderLayout.superclass.destroy.call(this);    }    /**     * @property activeItem     * @hide     */});/** * @class Ext.layout.BorderLayout.Region * <p>This is a region of a {@link Ext.layout.BorderLayout BorderLayout} that acts as a subcontainer * within the layout.  Each region has its own {@link Ext.layout.ContainerLayout layout} that is * independent of other regions and the containing BorderLayout, and can be any of the * {@link Ext.layout.ContainerLayout valid Ext layout types}.</p> * <p>Region size is managed automatically and cannot be changed by the user -- for * {@link #split resizable regions}, see {@link Ext.layout.BorderLayout.SplitRegion}.</p> * @constructor * Create a new Region. * @param {Layout} layout The {@link Ext.layout.BorderLayout BorderLayout} instance that is managing this Region. * @param {Object} config The configuration options * @param {String} position The region position.  Valid values are: <tt>north</tt>, <tt>south</tt>, * <tt>east</tt>, <tt>west</tt> and <tt>center</tt>.  Every {@link Ext.layout.BorderLayout BorderLayout} * <b>must have a center region</b> 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     * <tt>{@link #autoHide} = false</tt>).  Setting <tt>{@link #animFloat} = false</tt> will     * prevent the open and close of these floated panels from being animated (defaults to <tt>true</tt>).     */    /**     * @cfg {Boolean} autoHide     * When a collapsed region's bar is clicked, the region's panel will be displayed as a floated     * panel.  If <tt>autoHide = true</tt>, the panel will automatically hide after the user mouses     * out of the panel.  If <tt>autoHide = false</tt>, the panel will continue to display until the     * user clicks outside of the panel (defaults to <tt>true</tt>).     */    /**     * @cfg {String} collapseMode     * <tt>collapseMode</tt> supports two configuration values:<div class="mdetail-params"><ul>     * <li><b><tt>undefined</tt></b> (default)<div class="sub-desc">By default, {@link #collapsible}     * regions are collapsed by clicking the expand/collapse tool button that renders into the region's     * title bar.</div></li>     * <li><b><tt>'mini'</tt></b><div class="sub-desc">Optionally, when <tt>collapseMode</tt> is set to     * <tt>'mini'</tt> the region's split bar will also display a small collapse button in the center of     * the bar. In <tt>'mini'</tt> mode the region will collapse to a thinner bar than in normal mode.     * </div></li>     * </ul></div></p>     * <p><b>Note</b>: if a collapsible region does not have a title bar, then set <tt>collapseMode =     * 'mini'</tt> and <tt>{@link #split} = true</tt> in order for the region to be {@link #collapsible}     * by the user as the expand/collapse tool button (that would go in the title bar) will not be rendered.</p>     * <p>See also <tt>{@link #cmargins}</tt>.</p>     */    /**     * @cfg {Object} margins     * An object containing margins to apply to the region when in the expanded state in the     * format:<pre><code>{    top: (top margin),    right: (right margin),    bottom: (bottom margin),    left: (left margin)}</code></pre>     * <p>May also be a string containing space-separated, numeric margin values. The order of the     * sides associated with each value matches the way CSS processes margin values:</p>     * <p><ul>     * <li>If there is only one value, it applies to all sides.</li>     * <li>If there are two values, the top and bottom borders are set to the first value and the     * right and left are set to the second.</li>     * <li>If there are three values, the top is set to the first value, the left and right are set     * to the second, and the bottom is set to the third.</li>     * <li>If there are four values, they apply to the top, right, bottom, and left, respectively.</li>     * </ul></p>     * <p>Defaults to:</p><pre><code>     * {top:0, right:0, bottom:0, left:0}     * </code></pre>     */    /**     * @cfg {Object} cmargins     * An object containing margins to apply to the region when in the collapsed state in the     * format:<pre><code>{    top: (top margin),    right: (right margin),    bottom: (bottom margin),    left: (left margin)}</code></pre>     * <p>May also be a string containing space-separated, numeric margin values. The order of the     * sides associated with each value matches the way CSS processes margin values.</p>     * <p><ul>     * <li>If there is only one value, it applies to all sides.</li>     * <li>If there are two values, the top and bottom borders are set to the first value and the     * right and left are set to the second.</li>     * <li>If there are three values, the top is set to the first value, the left and right are set     * to the second, and the bottom is set to the third.</li>     * <li>If there are four values, they apply to the top, right, bottom, and left, respectively.</li>     * </ul></p>     */    /**     * @cfg {Boolean} collapsible     * <p><tt>true</tt> to allow the user to collapse this region (defaults to <tt>false</tt>).  If     * <tt>true</tt>, an expand/collapse tool button will automatically be rendered into the title     * bar of the region, otherwise the button will not be shown.</p>     * <p><b>Note</b>: that a title bar is required to display the collapse/expand toggle button -- if     * no <tt>title</tt> is specified for the region's panel, the region will only be collapsible if     * <tt>{@link #collapseMode} = 'mini'</tt> and <tt>{@link #split} = true</tt>.     */    collapsible : false,    /**     * @cfg {Boolean} split     * <p><tt>true</tt> to create a {@link Ext.layout.BorderLayout.SplitRegion SplitRegion} and      * display a 5px wide {@link Ext.SplitBar} between this region and its neighbor, allowing the user to     * resize the regions dynamically.  Defaults to <tt>false</tt> creating a     * {@link Ext.layout.BorderLayout.Region Region}.</p><br>     * <p><b>Notes</b>:</p><div class="mdetail-params"><ul>     * <li>this configuration option is ignored if <tt>region='center'</tt></li>      * <li>when <tt>split == true</tt>, it is common to specify a     * <tt>{@link Ext.SplitBar#minSize minSize}</tt> and <tt>{@link Ext.SplitBar#maxSize maxSize}</tt>     * for the {@link Ext.BoxComponent BoxComponent} representing the region. These are not native     * configs of {@link Ext.BoxComponent BoxComponent}, and are used only by this class.</li>     * <li>if <tt>{@link #collapseMode} = 'mini'</tt> requires <tt>split = true</tt> to reserve space     * for the collapse tool</tt></li>      * </ul></div>      */    split:false,    /**     * @cfg {Boolean} floatable     * <tt>true</tt> to allow clicking a collapsed region's bar to display the region's panel floated     * above the layout, <tt>false</tt> to force the user to fully expand a collapsed region by     * clicking the expand button to see it again (defaults to <tt>true</tt>).     */    floatable: true,

⌨️ 快捷键说明

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