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