3 This file is part of Ext JS 4
5 Copyright (c) 2011 Sencha Inc
7 Contact: http://www.sencha.com/contact
9 GNU General Public License Usage
10 This file may be used under the terms of the GNU General Public License version 3.0 as published by the Free Software Foundation and appearing in the file LICENSE included in the packaging of this file. Please review the following information to ensure the GNU General Public License version 3.0 requirements will be met: http://www.gnu.org/copyleft/gpl.html.
12 If you are unsure which license is appropriate for your use, please contact the sales department at http://www.sencha.com/contact.
16 // Note that these are all defined as panel configs, rather than instantiated
17 // as panel objects. You could just as easily do this instead:
19 // var absolute = Ext.create('Ext.Panel', { ... });
21 // However, by passing configs into the main container instead of objects, we can defer
22 // layout AND object instantiation until absolutely needed. Since most of these panels
23 // won't be shown by default until requested, this will save us some processing
24 // time up front when initially rendering the page.
26 // Since all of these configs are being added into a layout container, they are
27 // automatically assumed to be panel configs, and so the xtype of 'panel' is
28 // implicit. To define a config of some other type of component to be added into
29 // the layout, simply provide the appropriate xtype config explicitly.
31 function getBasicLayouts() {
32 // This is a fake CardLayout navigation function. A real implementation would
33 // likely be more sophisticated, with logic to validate navigation flow. It will
34 // be assigned next as the handling function for the buttons in the CardLayout example.
35 var cardNav = function(incr){
36 var l = Ext.getCmp('card-wizard-panel').getLayout();
37 var i = l.activeItem.id.split('card-')[1];
38 var next = parseInt(i, 10) + incr;
39 l.setActiveItem(next);
40 Ext.getCmp('card-prev').setDisabled(next===0);
41 Ext.getCmp('card-next').setDisabled(next===2);
45 * ================ Start page config =======================
47 // The default start page, also a simple example of a FitLayout.
52 bodyStyle: 'padding:25px',
53 contentEl: 'start-div' // pull existing content from the page
57 * ================ AbsoluteLayout config =======================
61 title: 'Absolute Layout',
64 bodyStyle: 'padding:15px;',
73 html: 'Positioned at x:50, y:50'
78 html: 'Positioned at x:125, y:125'
83 * ================ AccordionLayout config =======================
86 id: 'accordion-panel',
87 title: 'Accordion Layout',
89 bodyStyle: 'background-color:#DFE8F6', // if all accordion panels are collapsed, this looks better in this layout
90 defaults: {bodyStyle: 'padding:15px'},
92 title: 'Introduction',
93 tools: [{type:'gear'},{type:'refresh'}],
94 html: '<p>Here is some accordion content. Click on one of the other bars below for more.</p>'
96 title: 'Basic Content',
97 html: '<br /><br /><p>More content. Open the third panel for a customized look and feel example.</p>',
100 text: 'Show Next Panel',
102 Ext.getCmp('acc-custom').expand(true);
107 title: 'Custom Panel Look and Feel',
108 cls: 'custom-accordion', // look in layout-browser.css to see the CSS rules for this class
109 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>'
114 * ================ AnchorLayout config =======================
118 title: 'Anchor Layout',
120 defaults: {bodyStyle: 'padding:15px'},
125 html: '<p>Width = 50% of the container</p>'
130 html: '<p>Width = container width - 100 pixels</p>'
134 html: '<p>Width = container width - 10 pixels</p><p>Height = container height - 262 pixels</p>'
139 * ================ BorderLayout config =======================
143 title: 'Border Layout',
152 bodyStyle: 'padding:15px'
161 html: '<p>Footer content</p>'
171 html: '<p>Secondary content like navigation links could go here</p>'
173 title: 'Main Content',
177 html: '<h1>Main Page</h1><p>This is where the main content would go</p>'
182 * ================ CardLayout config (TabPanel) =======================
184 // Note that the TabPanel component uses an internal CardLayout -- it is not
185 // something you have to explicitly configure. However, it is still a perfect
186 // example of how this layout style can be used in a complex component.
189 id: 'card-tabs-panel',
190 plain: true, //remove the header border
192 style: 'background-color:#dfe8f6; ',
193 defaults: {bodyStyle: 'padding:15px'},
196 html: 'This is tab 1 content.'
199 html: 'This is tab 2 content.'
202 html: 'This is tab 3 content.'
207 * ================ CardLayout config (Wizard) =======================
210 id:'card-wizard-panel',
211 title: 'Card Layout (Wizard)',
214 bodyStyle: 'padding:15px',
215 defaults: {border:false},
218 text: '« Previous',
219 handler: Ext.Function.bind(cardNav, this, [-1]),
223 text: 'Next »',
224 handler: Ext.Function.bind(cardNav, this, [1])
228 html: '<h1>Welcome to the Demo Wizard!</h1><p>Step 1 of 3</p><p>Please click the "Next" button to continue...</p>'
231 html: '<p>Step 2 of 3</p><p>Almost there. Please click the "Next" button to continue...</p>'
234 html: '<h1>Congratulations!</h1><p>Step 3 of 3 - Complete</p>'
239 * ================ ColumnLayout config =======================
243 title: 'Column Layout',
245 bodyStyle: 'padding:5px',
246 defaults: {bodyStyle:'padding:15px'},
248 title: 'Width = 0.25',
250 html: '<p>This is some short content.</p>'
252 title: 'Width = 0.75',
254 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>'
256 title: 'Width = 250px',
258 html: 'Not much here!'
263 * ================ FitLayout config =======================
270 title: 'Inner Panel',
271 html: '<p>This panel is fit within its container.</p>',
272 bodyStyle: 'padding:15px',
278 * ================ FormLayout config =======================
280 // NOTE: While you can create a basic Panel with layout:'form', practically
281 // you should usually use a FormPanel to also get its form-specific functionality.
282 // Note that the layout config is not required on FormPanels.
284 xtype: 'form', // since we are not using the default 'panel' xtype, we must specify it
287 title: 'Form Layout',
288 bodyStyle: 'padding:15px',
297 defaultType: 'textfield',
299 fieldLabel: 'First Name',
303 fieldLabel: 'Last Name',
306 fieldLabel: 'Company',
314 buttons: [{text: 'Save'},{text: 'Cancel'}]
318 * ================ TableLayout config =======================
322 title: 'Table Layout',
328 bodyStyle:'padding:15px 20px'
331 title: 'Lots of Spanning',
332 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>',
335 title: 'Basic Table Cell',
336 html: '<p>Basic panel in a table cell.</p>',
337 cellId: 'basic-cell',
338 cellCls: 'custom-cls'
340 html: '<p>Plain panel</p>'
342 title: 'Another Cell',
343 html: '<p>Row spanning.</p><br /><p>Row spanning.</p><br /><p>Row spanning.</p><br /><p>Row spanning.</p>',
347 html: 'Plain cell spanning two columns',
350 title: 'More Column Spanning',
351 html: '<p>Spanning three columns.</p>',
354 title: 'Spanning All Columns',
355 html: '<p>Spanning all columns.</p>',
362 * ================ VBoxLayout config =======================
366 title: 'vBox Layout',
391 * ================ HBoxLayout config =======================
395 title: 'hBox Layout',