source: trunk/web/addons/job_monarch/lib/extjs-30/examples/layout/hbox.html @ 625

Last change on this file since 625 was 625, checked in by ramonb, 15 years ago

lib/extjs-30:

  • new ExtJS 3.0
File size: 15.8 KB
Line 
1<html>
2<head>
3    <title>HBox Layout</title>
4    <link rel="stylesheet" type="text/css" href="../../resources/css/ext-all.css"/>
5
6    <!-- GC -->
7    <!-- LIBS -->
8    <script type="text/javascript" src="../../adapter/ext/ext-base.js"></script>
9    <!-- ENDLIBS -->
10
11    <script type="text/javascript" src="../../ext-all.js"></script>
12
13    <style type="text/css">
14        html, body {
15            font: normal 12px verdana;
16            margin: 0;
17            padding: 0;
18            border: 0 none;
19        }
20    </style>
21    <script type="text/javascript">
22       
23        Ext.onReady(function() {
24
25            var replace = function(config){
26                var btns = Ext.getCmp('btns');
27
28                btns.remove(0);
29
30                btns.add(Ext.apply(config, {
31                    layout:'hbox'
32                }));
33
34                btns.doLayout();
35            }
36
37
38            var viewport = new Ext.Viewport({
39                layout:'border',
40
41                items: [{
42                    id:'btns',
43                    region:'north',
44                    baseCls:'x-plain',
45                    split:true,
46                    height:50,
47                    minHeight: 40,
48                    maxHeight: 85,
49                    layout:'fit',
50                    margins: '5 5 0 5',
51                    items: {
52                        baseCls: 'x-plain',
53                        html: '<p style="padding:10px;color:#556677;">Select a configuration below:</p>'
54                    }
55               }, {
56                    region:'center',
57                    margins: '0 5 5 5',
58                    layout:'anchor',
59
60                    items:[{
61                        anchor:'100%',
62                        baseCls:'x-plain',
63                        layout:'hbox',
64                        layoutConfig: {
65                            padding: 10
66                        },
67                        defaults:{
68                            margins:'0 5 0 0',
69                            pressed: false,
70                            toggleGroup:'btns',
71                            allowDepress: false
72                        },
73                        items: [{
74                            xtype:'button',
75                            text: 'Spaced',
76                            handler: function(){
77                                replace({
78                                    layoutConfig: {
79                                        padding:'5',
80                                        align:'top'
81                                    },
82                                    defaults:{margins:'0 5 0 0'},
83                                    items:[{
84                                        xtype:'button',
85                                        text: 'Button 1'
86                                    },{
87                                        xtype:'spacer',
88                                        flex:1
89                                    },{
90                                        xtype:'button',
91                                        text: 'Button 2'
92                                    },{
93                                        xtype:'button',
94                                        text: 'Button 3'
95                                    },{
96                                        xtype:'button',
97                                        text: 'Button 4',
98                                        margins:'0'
99                                    }]
100                                });
101                            }
102                        },{
103                            xtype:'button',
104                            text: 'Align: top',
105                            handler: function(){
106                                replace({
107                                    layoutConfig: {
108                                        padding:'5',
109                                        align:'top'
110                                    },
111                                    defaults:{margins:'0 5 0 0'},
112                                    items:[{
113                                        xtype:'button',
114                                        text: 'Button 1'
115                                    },{
116                                        xtype:'button',
117                                        text: 'Button 2'
118                                    },{
119                                        xtype:'button',
120                                        text: 'Button 3'
121                                    },{
122                                        xtype:'button',
123                                        text: 'Button 4'
124                                    }]
125                                });
126                            }
127                        },{
128                            xtype:'button',
129                            text: 'Align: middle',
130                            handler: function(){
131                                replace({
132                                    layoutConfig: {
133                                        padding:'5',
134                                        align:'middle'
135                                    },
136                                    defaults:{margins:'0 5 0 0'},
137                                    items:[{
138                                        xtype:'button',
139                                        text: 'Button 1'
140                                    },{
141                                        xtype:'button',
142                                        text: 'Button 2'
143                                    },{
144                                        xtype:'button',
145                                        text: 'Button 3'
146                                    },{
147                                        xtype:'button',
148                                        text: 'Button 4'
149                                    }]
150                                });
151                            }
152                        },{
153                            xtype:'button',
154                            text: 'Align: stretch',
155                            handler: function(){
156                                replace({
157                                    layoutConfig: {
158                                        padding:'5',
159                                        align:'stretch'
160                                    },
161                                    defaults:{margins:'0 5 0 0'},
162                                    items:[{
163                                        xtype:'button',
164                                        text: 'Button 1'
165                                    },{
166                                        xtype:'button',
167                                        text: 'Button 2'
168                                    },{
169                                        xtype:'button',
170                                        text: 'Button 3'
171                                    },{
172                                        xtype:'button',
173                                        text: 'Button 4'
174                                    }]
175                                });
176                            }
177                        },{
178                            xtype:'button',
179                            text: 'Align: stretchmax',
180                            handler: function(){
181                                replace({
182                                    layoutConfig: {
183                                        padding:'5',
184                                        align:'stretchmax'
185                                    },
186                                    defaults:{margins:'0 5 0 0'},
187                                    items:[{
188                                        xtype:'button',
189                                        text: 'Button 1'
190                                    },{
191                                        xtype:'button',
192                                        text: 'Button 2'
193                                    },{
194                                        xtype:'button',
195                                        text: 'Button 3'
196                                    },{
197                                        xtype:'button',
198                                        text: 'Button 4'
199                                    }]
200                                });
201                            }
202                        }]
203                    },{
204                        anchor:'100%',
205                        baseCls:'x-plain',
206                        layout:'hbox',
207                        layoutConfig: {
208                            padding: '0 10 10'
209                        },
210                        defaults:{
211                            margins:'0 5 0 0',
212                            pressed: false,
213                            toggleGroup:'btns',
214                            allowDepress: false
215                        },
216                        items: [{
217                            xtype:'button',
218                            text: 'Flex: All even',
219                            handler: function(){
220                                replace({
221                                    layoutConfig: {
222                                        padding:'5',
223                                        align:'middle'
224                                    },
225                                    defaults:{margins:'0 5 0 0'},
226                                    items:[{
227                                        xtype:'button',
228                                        text: 'Button 1',
229                                        flex:1
230                                    },{
231                                        xtype:'button',
232                                        text: 'Button 2',
233                                        flex:1
234                                    },{
235                                        xtype:'button',
236                                        text: 'Button 3',
237                                        flex:1
238                                    },{
239                                        xtype:'button',
240                                        text: 'Button 4',
241                                        flex:1,
242                                        margins:'0'
243                                    }]
244                                });
245                            }
246                        },{
247                            xtype:'button',
248                            text: 'Flex: Ratio',
249                            handler: function(){
250                                replace({
251                                    layoutConfig: {
252                                        padding:'5',
253                                        align:'middle'
254                                    },
255                                    defaults:{margins:'0 5 0 0'},
256                                    items:[{
257                                        xtype:'button',
258                                        text: 'Button 1',
259                                        flex:1
260                                    },{
261                                        xtype:'button',
262                                        text: 'Button 2',
263                                        flex:1
264                                    },{
265                                        xtype:'button',
266                                        text: 'Button 3',
267                                        flex:1
268                                    },{
269                                        xtype:'button',
270                                        text: 'Button 4',
271                                        flex:3,
272                                        margins:'0'
273                                    }]
274                                });
275                            }
276                        },{
277                            xtype:'button',
278                            text: 'Pack: start',
279                            handler: function(){
280                                replace({
281                                    layoutConfig: {
282                                        padding:'5',
283                                        pack:'start',
284                                        align:'middle'
285                                    },
286                                    defaults:{margins:'0 5 0 0'},
287                                    items:[{
288                                        xtype:'button',
289                                        text: 'Button 1'
290                                    },{
291                                        xtype:'button',
292                                        text: 'Button 2'
293                                    },{
294                                        xtype:'button',
295                                        text: 'Button 3'
296                                    },{
297                                        xtype:'button',
298                                        text: 'Button 4'
299                                    }]
300                                });
301                            }
302                        },{
303                            xtype:'button',
304                            text: 'Pack: center',
305                            handler: function(){
306                                replace({
307                                    layoutConfig: {
308                                        padding:'5',
309                                        pack:'center',
310                                        align:'middle'
311                                    },
312                                    defaults:{margins:'0 5 0 0'},
313                                    items:[{
314                                        xtype:'button',
315                                        text: 'Button 1'
316                                    },{
317                                        xtype:'button',
318                                        text: 'Button 2'
319                                    },{
320                                        xtype:'button',
321                                        text: 'Button 3'
322                                    },{
323                                        xtype:'button',
324                                        text: 'Button 4',
325                                        margins:'0'
326                                    }]
327                                });
328                            }
329                        },{
330                            xtype:'button',
331                            text: 'Pack: end',
332                            handler: function(){
333                                replace({
334                                    layoutConfig: {
335                                        padding:'5',
336                                        pack:'end',
337                                        align:'middle'
338                                    },
339                                    defaults:{margins:'0 5 0 0'},
340                                    items:[{
341                                        xtype:'button',
342                                        text: 'Button 1'
343                                    },{
344                                        xtype:'button',
345                                        text: 'Button 2'
346                                    },{
347                                        xtype:'button',
348                                        text: 'Button 3'
349                                    },{
350                                        xtype:'button',
351                                        text: 'Button 4',
352                                        margins:'0'
353                                    }]
354                                });
355                            }
356                        }]
357                    }]
358                }]
359            });
360        });
361    </script>
362</head>
363<body>
364</body>
365</html>
Note: See TracBrowser for help on using the repository browser.