2 // Note that these are all defined as panel configs, rather than instantiated
3 // as panel objects. You could just as easily do this instead:
5 // var absolute = Ext.create('Ext.Panel', { ... });
7 // However, by passing configs into the main container instead of objects, we can defer
8 // layout AND object instantiation until absolutely needed. Since most of these panels
9 // won't be shown by default until requested, this will save us some processing
10 // time up front when initially rendering the page.
12 // Since all of these configs are being added into a layout container, they are
13 // automatically assumed to be panel configs, and so the xtype of 'panel' is
14 // implicit. To define a config of some other type of component to be added into
15 // the layout, simply provide the appropriate xtype config explicitly.
17 function getBasicLayouts() {
18 // This is a fake CardLayout navigation function. A real implementation would
19 // likely be more sophisticated, with logic to validate navigation flow. It will
20 // be assigned next as the handling function for the buttons in the CardLayout example.
21 var cardNav = function(incr){
22 var l = Ext.getCmp('card-wizard-panel').getLayout();
23 var i = l.activeItem.id.split('card-')[1];
24 var next = parseInt(i, 10) + incr;
25 l.setActiveItem(next);
26 Ext.getCmp('card-prev').setDisabled(next===0);
27 Ext.getCmp('card-next').setDisabled(next===2);
31 * ================ Start page config =======================
33 // The default start page, also a simple example of a FitLayout.
38 bodyStyle: 'padding:25px',
39 contentEl: 'start-div' // pull existing content from the page
43 * ================ AbsoluteLayout config =======================
47 title: 'Absolute Layout',
50 bodyStyle: 'padding:15px;',
59 html: 'Positioned at x:50, y:50'
64 html: 'Positioned at x:125, y:125'
69 * ================ AccordionLayout config =======================
72 id: 'accordion-panel',
73 title: 'Accordion Layout',
75 bodyStyle: 'background-color:#DFE8F6', // if all accordion panels are collapsed, this looks better in this layout
76 defaults: {bodyStyle: 'padding:15px'},
78 title: 'Introduction',
79 tools: [{type:'gear'},{type:'refresh'}],
80 html: '<p>Here is some accordion content. Click on one of the other bars below for more.</p>'
82 title: 'Basic Content',
83 html: '<br /><br /><p>More content. Open the third panel for a customized look and feel example.</p>',
86 text: 'Show Next Panel',
88 Ext.getCmp('acc-custom').expand(true);
93 title: 'Custom Panel Look and Feel',
94 cls: 'custom-accordion', // look in layout-browser.css to see the CSS rules for this class
95 html: '<p>Here is an example of how easy it is to completely customize the look and feel of an individual panel simply by adding a CSS class in the config.</p>'
100 * ================ AnchorLayout config =======================
104 title: 'Anchor Layout',
106 defaults: {bodyStyle: 'padding:15px'},
111 html: '<p>Width = 50% of the container</p>'
116 html: '<p>Width = container width - 100 pixels</p>'
120 html: '<p>Width = container width - 10 pixels</p><p>Height = container height - 262 pixels</p>'
125 * ================ BorderLayout config =======================
129 title: 'Border Layout',
138 bodyStyle: 'padding:15px'
147 html: '<p>Footer content</p>'
157 html: '<p>Secondary content like navigation links could go here</p>'
159 title: 'Main Content',
163 html: '<h1>Main Page</h1><p>This is where the main content would go</p>'
168 * ================ CardLayout config (TabPanel) =======================
170 // Note that the TabPanel component uses an internal CardLayout -- it is not
171 // something you have to explicitly configure. However, it is still a perfect
172 // example of how this layout style can be used in a complex component.
175 id: 'card-tabs-panel',
176 plain: true, //remove the header border
178 style: 'background-color:#dfe8f6; ',
179 defaults: {bodyStyle: 'padding:15px'},
182 html: 'This is tab 1 content.'
185 html: 'This is tab 2 content.'
188 html: 'This is tab 3 content.'
193 * ================ CardLayout config (Wizard) =======================
196 id:'card-wizard-panel',
197 title: 'Card Layout (Wizard)',
200 bodyStyle: 'padding:15px',
201 defaults: {border:false},
204 text: '« Previous',
205 handler: Ext.Function.bind(cardNav, this, [-1]),
209 text: 'Next »',
210 handler: Ext.Function.bind(cardNav, this, [1])
214 html: '<h1>Welcome to the Demo Wizard!</h1><p>Step 1 of 3</p><p>Please click the "Next" button to continue...</p>'
217 html: '<p>Step 2 of 3</p><p>Almost there. Please click the "Next" button to continue...</p>'
220 html: '<h1>Congratulations!</h1><p>Step 3 of 3 - Complete</p>'
225 * ================ ColumnLayout config =======================
229 title: 'Column Layout',
231 bodyStyle: 'padding:5px',
232 defaults: {bodyStyle:'padding:15px'},
234 title: 'Width = 0.25',
236 html: '<p>This is some short content.</p>'
238 title: 'Width = 0.75',
240 html: '<p>This is some longer content.</p><p>This is some longer content.</p><p>This is some longer content.</p><p>This is some longer content.</p><p>This is some longer content.</p><p>This is some longer content.</p>'
242 title: 'Width = 250px',
244 html: 'Not much here!'
249 * ================ FitLayout config =======================
256 title: 'Inner Panel',
257 html: '<p>This panel is fit within its container.</p>',
258 bodyStyle: 'padding:15px',
264 * ================ FormLayout config =======================
266 // NOTE: While you can create a basic Panel with layout:'form', practically
267 // you should usually use a FormPanel to also get its form-specific functionality.
268 // Note that the layout config is not required on FormPanels.
270 xtype: 'form', // since we are not using the default 'panel' xtype, we must specify it
273 title: 'Form Layout',
274 bodyStyle: 'padding:15px',
283 defaultType: 'textfield',
285 fieldLabel: 'First Name',
289 fieldLabel: 'Last Name',
292 fieldLabel: 'Company',
300 buttons: [{text: 'Save'},{text: 'Cancel'}]
304 * ================ TableLayout config =======================
308 title: 'Table Layout',
314 bodyStyle:'padding:15px 20px'
317 title: 'Lots of Spanning',
318 html: '<p>Row spanning.</p><br /><p>Row spanning.</p><br /><p>Row spanning.</p><br /><p>Row spanning.</p><br /><p>Row spanning.</p><br /><p>Row spanning.</p>',
321 title: 'Basic Table Cell',
322 html: '<p>Basic panel in a table cell.</p>',
323 cellId: 'basic-cell',
324 cellCls: 'custom-cls'
326 html: '<p>Plain panel</p>'
328 title: 'Another Cell',
329 html: '<p>Row spanning.</p><br /><p>Row spanning.</p><br /><p>Row spanning.</p><br /><p>Row spanning.</p>',
333 html: 'Plain cell spanning two columns',
336 title: 'More Column Spanning',
337 html: '<p>Spanning three columns.</p>',
340 title: 'Spanning All Columns',
341 html: '<p>Spanning all columns.</p>',
348 * ================ VBoxLayout config =======================
352 title: 'vBox Layout',
377 * ================ HBoxLayout config =======================
381 title: 'hBox Layout',