1
<html><head><title>ContainerLayout.js</title><link rel="stylesheet" type="text/css" href="../resources/style.css" media="screen"/></head><body><h1>ContainerLayout.js</h1><pre class="highlighted"><code><i>/**
2
* @class Ext.layout.ContainerLayout
3
* <p>Every {@link Ext.Container Container} delegates the rendering of its child {@link Ext.Component Component}s
4
* to a layout manager class which must be {@link Ext.Container#layout configured} into the Container.</p>
5
* <p>Some layouts also provide sizing and positioning of child Components.</p>
6
* <p>The ContainerLayout class is the <b>default</b> layout manager used when no layout is configured into a Container.
7
* It provides the basic foundation <b>for</b> all other layout classes <b>in</b> Ext. It simply renders all child Components
8
* into the Container, performing no sizing or positioning services.</p>
9
* <p>This class is intended to be extended and should generally not need to be created directly via the <b>new</b> keyword.</p>
11
Ext.layout.ContainerLayout = <b>function</b>(config){
12
Ext.apply(<b>this</b>, config);
15
Ext.layout.ContainerLayout.prototype = {
17
* @cfg {String} extraCls
18
* An optional extra CSS class that will be added to the container (defaults to <em>''</em>). This can be useful <b>for</b>
19
* adding customized styles to the container or any of its children using standard CSS rules.
23
* @cfg {Boolean} renderHidden
24
* True to hide each contained item on render (defaults to false).
28
* A reference to the {@link Ext.Component} that is active. For example,
29
* <b>if</b>(myPanel.layout.activeItem.id == <em>'item-1'</em>) { ... }. activeItem only applies to layout styles that can
30
* display items one at a time (like {@link Ext.layout.Accordion}, {@link Ext.layout.CardLayout}
31
* and {@link Ext.layout.FitLayout}). Read-only. Related to {@link Ext.Container#activeItem}.
32
* @type {Ext.Component}
33
* @property activeItem
42
layout : <b>function</b>(){
43
<b>var</b> target = <b>this</b>.container.getLayoutTarget();
44
<b>this</b>.onLayout(<b>this</b>.container, target);
45
<b>this</b>.container.fireEvent(<em>'afterlayout'</em>, <b>this</b>.container, <b>this</b>);
49
onLayout : <b>function</b>(ct, target){
50
<b>this</b>.renderAll(ct, target);
54
isValidParent : <b>function</b>(c, target){
55
<b>var</b> el = c.getPositionEl ? c.getPositionEl() : c.getEl();
56
<b>return</b> el.dom.parentNode == target.dom;
60
renderAll : <b>function</b>(ct, target){
61
<b>var</b> items = ct.items.items;
62
<b>for</b>(var i = 0, len = items.length; i < len; i++) {
63
<b>var</b> c = items[i];
64
<b>if</b>(c && (!c.rendered || !<b>this</b>.isValidParent(c, target))){
65
<b>this</b>.renderItem(c, i, target);
71
renderItem : <b>function</b>(c, position, target){
72
<b>if</b>(c && !c.rendered){
73
c.render(target, position);
74
<b>if</b>(this.extraCls){
75
<b>var</b> t = c.getPositionEl ? c.getPositionEl() : c;
76
t.addClass(<b>this</b>.extraCls);
78
<b>if</b> (<b>this</b>.renderHidden && c != <b>this</b>.activeItem) {
81
}<b>else</b> if(c && !<b>this</b>.isValidParent(c, target)){
82
<b>if</b>(this.extraCls){
83
<b>var</b> t = c.getPositionEl ? c.getPositionEl() : c;
84
t.addClass(<b>this</b>.extraCls);
86
<b>if</b>(typeof position == <em>'number'</em>){
87
position = target.dom.childNodes[position];
89
target.dom.insertBefore(c.getEl().dom, position || null);
90
<b>if</b> (<b>this</b>.renderHidden && c != <b>this</b>.activeItem) {
97
onResize: <b>function</b>(){
98
<b>if</b>(this.container.collapsed){
101
<b>var</b> b = <b>this</b>.container.bufferResize;
103
<b>if</b>(!<b>this</b>.resizeTask){
104
<b>this</b>.resizeTask = <b>new</b> Ext.util.DelayedTask(<b>this</b>.layout, <b>this</b>);
105
<b>this</b>.resizeBuffer = <b>typeof</b> b == <em>'number'</em> ? b : 100;
107
<b>this</b>.resizeTask.delay(<b>this</b>.resizeBuffer);
109
<b>this</b>.layout();
114
setContainer : <b>function</b>(ct){
115
<b>if</b>(this.monitorResize && ct != <b>this</b>.container){
116
<b>if</b>(this.container){
117
<b>this</b>.container.un(<em>'resize'</em>, <b>this</b>.onResize, <b>this</b>);
120
ct.on(<em>'resize'</em>, <b>this</b>.onResize, <b>this</b>);
123
<b>this</b>.container = ct;
127
parseMargins : <b>function</b>(v){
128
<b>var</b> ms = v.split(<em>' '</em>);
129
<b>var</b> len = ms.length;
140
top:parseInt(ms[0], 10) || 0,
141
right:parseInt(ms[1], 10) || 0,
142
bottom:parseInt(ms[2], 10) || 0,
143
left:parseInt(ms[3], 10) || 0
148
* Destroys <b>this</b> layout. This is a template method that is empty by <b>default</b>, but should be implemented
149
* by subclasses that require explicit destruction to purge event handlers or remove DOM nodes.
152
destroy : Ext.emptyFn
154
Ext.Container.LAYOUTS[<em>'auto'</em>] = Ext.layout.ContainerLayout;</code></pre><hr><div style="font-size:10px;text-align:center;color:gray;">Ext - Copyright © 2006-2007 Ext JS, LLC<br />All rights reserved.</div>
b'\\ No newline at end of file'