major doc changes
[roojs1] / Roo / bootstrap / panel / Nest.js
1
2 /**
3  * @class Roo.bootstrap.panel.Nest
4  * @extends Roo.bootstrap.panel.Content
5  * @constructor
6  * Create a new Panel, that can contain a layout.Border.
7  * 
8  * 
9  * @param {String/Object} config A string to set only the title or a config object
10  */
11 Roo.bootstrap.panel.Nest = function(config)
12 {
13     // construct with only one argument..
14     /* FIXME - implement nicer consturctors
15     if (layout.layout) {
16         config = layout;
17         layout = config.layout;
18         delete config.layout;
19     }
20     if (layout.xtype && !layout.getEl) {
21         // then layout needs constructing..
22         layout = Roo.factory(layout, Roo);
23     }
24     */
25     
26     config.el =  config.layout.getEl();
27     
28     Roo.bootstrap.panel.Nest.superclass.constructor.call(this, config);
29     
30     config.layout.monitorWindowResize = false; // turn off autosizing
31     this.layout = config.layout;
32     this.layout.getEl().addClass("roo-layout-nested-layout");
33     this.layout.parent = this;
34     
35     
36     
37     
38 };
39
40 Roo.extend(Roo.bootstrap.panel.Nest, Roo.bootstrap.panel.Content, {
41     /**
42     * @cfg {Roo.BorderLayout} layout The layout for this panel
43     */
44     layout : false,
45
46     setSize : function(width, height){
47         if(!this.ignoreResize(width, height)){
48             var size = this.adjustForComponents(width, height);
49             var el = this.layout.getEl();
50             if (size.height < 1) {
51                 el.setWidth(size.width);   
52             } else {
53                 el.setSize(size.width, size.height);
54             }
55             var touch = el.dom.offsetWidth;
56             this.layout.layout();
57             // ie requires a double layout on the first pass
58             if(Roo.isIE && !this.initialized){
59                 this.initialized = true;
60                 this.layout.layout();
61             }
62         }
63     },
64     
65     // activate all subpanels if not currently active..
66     
67     setActiveState : function(active){
68         this.active = active;
69         this.setActiveClass(active);
70         
71         if(!active){
72             this.fireEvent("deactivate", this);
73             return;
74         }
75         
76         this.fireEvent("activate", this);
77         // not sure if this should happen before or after..
78         if (!this.layout) {
79             return; // should not happen..
80         }
81         var reg = false;
82         for (var r in this.layout.regions) {
83             reg = this.layout.getRegion(r);
84             if (reg.getActivePanel()) {
85                 //reg.showPanel(reg.getActivePanel()); // force it to activate.. 
86                 reg.setActivePanel(reg.getActivePanel());
87                 continue;
88             }
89             if (!reg.panels.length) {
90                 continue;
91             }
92             reg.showPanel(reg.getPanel(0));
93         }
94         
95         
96         
97         
98     },
99     
100     /**
101      * Returns the nested BorderLayout for this panel
102      * @return {Roo.BorderLayout} 
103      */
104     getLayout : function(){
105         return this.layout;
106     },
107     
108      /**
109      * Adds a xtype elements to the layout of the nested panel
110      * <pre><code>
111
112 panel.addxtype({
113        xtype : 'ContentPanel',
114        region: 'west',
115        items: [ .... ]
116    }
117 );
118
119 panel.addxtype({
120         xtype : 'NestedLayoutPanel',
121         region: 'west',
122         layout: {
123            center: { },
124            west: { }   
125         },
126         items : [ ... list of content panels or nested layout panels.. ]
127    }
128 );
129 </code></pre>
130      * @param {Object} cfg Xtype definition of item to add.
131      */
132     addxtype : function(cfg) {
133         return this.layout.addxtype(cfg);
134     
135     }
136 });