3 <title>The source code</title>
\r
4 <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
\r
5 <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
\r
7 <body onload="prettyPrint();">
\r
8 <pre class="prettyprint lang-js">//
9 // Note that these are all defined as panel configs, rather than instantiated
10 // as panel objects. You could just as easily do this instead:
12 // var absolute = new Ext.Panel({ ... });
14 // However, by passing configs into the main container instead of objects, we can defer
15 // layout AND object instantiation until absolutely needed. Since most of these panels
16 // won't be shown by default until requested, this will save us some processing
17 // time up front when initially rendering the page.
19 // Since all of these configs are being added into a layout container, they are
20 // automatically assumed to be panel configs, and so the xtype of 'panel' is
21 // implicit. To define a config of some other type of component to be added into
22 // the layout, simply provide the appropriate xtype config explicitly.
25 * ================ Start page config =======================
27 // The default start page, also a simple example of a FitLayout.
32 bodyStyle: 'padding:25px',
33 contentEl: 'start-div' // pull existing content from the page
37 * ================ AbsoluteLayout config =======================
41 title: 'Absolute Layout',
44 bodyStyle: 'padding:15px;',
53 html: 'Positioned at x:50, y:50'
58 html: 'Positioned at x:125, y:125'
63 * ================ AccordionLayout config =======================
66 id: 'accordion-panel',
67 title: 'Accordion Layout',
69 bodyBorder: false, // useful for accordion containers since the inner panels have borders already
70 bodyStyle: 'background-color:#DFE8F6', // if all accordion panels are collapsed, this looks better in this layout
71 defaults: {bodyStyle: 'padding:15px'},
73 title: 'Introduction',
74 tools: [{id:'gear'},{id:'refresh'}],
75 html: '<p>Here is some accordion content. Click on one of the other bars below for more.</p>'
77 title: 'Basic Content',
78 html: '<br /><p>More content. Open the third panel for a customized look and feel example.</p>',
81 text: 'Show Next Panel',
83 Ext.getCmp('acc-custom').expand(true);
88 title: 'Custom Panel Look and Feel',
89 cls: 'custom-accordion', // look in layout-browser.css to see the CSS rules for this class
90 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>'
95 * ================ AnchorLayout config =======================
99 title: 'Anchor Layout',
101 defaults: {bodyStyle: 'padding:15px'},
106 html: '<p>Width = 50% of the container</p>'
111 html: '<p>Width = container width - 100 pixels</p>'
115 html: '<p>Width = container width - 10 pixels</p><p>Height = container height - 262 pixels</p>'
120 * ================ BorderLayout config =======================
124 title: 'Border Layout',
133 bodyStyle: 'padding:15px'
142 html: '<p>Footer content</p>'
152 html: '<p>Secondary content like navigation links could go here</p>'
154 title: 'Main Content',
158 html: '<h1>Main Page</h1><p>This is where the main content would go</p>'
163 * ================ CardLayout config (TabPanel) =======================
165 // Note that the TabPanel component uses an internal CardLayout -- it is not
166 // something you have to explicitly configure. However, it is still a perfect
167 // example of how this layout style can be used in a complex component.
170 id: 'card-tabs-panel',
171 plain: true, //remove the header border
173 defaults: {bodyStyle: 'padding:15px'},
176 html: 'This is tab 1 content.'
179 html: 'This is tab 2 content.'
182 html: 'This is tab 3 content.'
186 // This is a fake CardLayout navigation function. A real implementation would
187 // likely be more sophisticated, with logic to validate navigation flow. It will
188 // be assigned next as the handling function for the buttons in the CardLayout example.
189 var cardNav = function(incr){
190 var l = Ext.getCmp('card-wizard-panel').getLayout();
191 var i = l.activeItem.id.split('card-')[1];
192 var next = parseInt(i) + incr;
193 l.setActiveItem(next);
194 Ext.getCmp('card-prev').setDisabled(next==0);
195 Ext.getCmp('card-next').setDisabled(next==2);
199 * ================ CardLayout config (Wizard) =======================
202 id:'card-wizard-panel',
203 title: 'Card Layout (Wizard)',
206 bodyStyle: 'padding:15px',
207 defaults: {border:false},
210 text: '« Previous',
211 handler: cardNav.createDelegate(this, [-1]),
215 text: 'Next »',
216 handler: cardNav.createDelegate(this, [1])
220 html: '<h1>Welcome to the Demo Wizard!</h1><p>Step 1 of 3</p><p>Please click the "Next" button to continue...</p>'
223 html: '<p>Step 2 of 3</p><p>Almost there. Please click the "Next" button to continue...</p>'
226 html: '<h1>Congratulations!</h1><p>Step 3 of 3 - Complete</p>'
231 * ================ ColumnLayout config =======================
235 title: 'Column Layout',
237 bodyStyle: 'padding:5px',
238 defaults: {bodyStyle:'padding:15px'},
240 title: 'Width = 0.25',
242 html: '<p>This is some short content.</p>'
244 title: 'Width = 0.75',
246 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>'
248 title: 'Width = 250px',
250 html: 'Not much here!'
255 * ================ FitLayout config =======================
262 title: 'Inner Panel',
263 html: '<p>This panel is fit within its container.</p>',
264 bodyStyle: 'margin:15px',
270 * ================ FormLayout config =======================
272 // NOTE: While you can create a basic Panel with layout:'form', practically
273 // you should usually use a FormPanel to also get its form-specific functionality.
274 // Note that the layout config is not required on FormPanels.
276 xtype: 'form', // since we are not using the default 'panel' xtype, we must specify it
279 title: 'Form Layout',
280 bodyStyle: 'padding:15px',
290 defaultType: 'textfield',
292 fieldLabel: 'First Name',
296 fieldLabel: 'Last Name',
299 fieldLabel: 'Company',
307 buttons: [{text: 'Save'},{text: 'Cancel'}]
311 * ================ TableLayout config =======================
315 title: 'Table Layout',
321 bodyStyle:'padding:15px 20px'
324 title: 'Lots of Spanning',
325 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>',
328 title: 'Basic Table Cell',
329 html: '<p>Basic panel in a table cell.</p>',
330 cellId: 'basic-cell',
331 cellCls: 'custom-cls'
333 html: '<p>Plain panel</p>'
335 title: 'Another Cell',
336 html: '<p>Row spanning.</p><br /><p>Row spanning.</p><br /><p>Row spanning.</p><br /><p>Row spanning.</p>',
340 html: 'Plain cell spanning two columns',
343 title: 'More Column Spanning',
344 html: '<p>Spanning three columns.</p>',
347 title: 'Spanning All Columns',
348 html: '<p>Spanning all columns.</p>',
355 * ================ VBoxLayout config =======================
359 title: 'vBox Layout',
\r
375 html: 'height: 100'
\r
384 * ================ HBoxLayout config =======================
388 title: 'hBox Layout',
\r
404 html: 'width : 100'
\r