PageRenderTime 351ms CodeModel.GetById 29ms RepoModel.GetById 2ms app.codeStats 0ms

/ext-4.1.0_b3/examples/layout/vbox.html

https://bitbucket.org/srogerf/javascript
HTML | 434 lines | 428 code | 5 blank | 1 comment | 0 complexity | ab55451900da01ed0fa41c70c805f4d5 MD5 | raw file
  1. <html>
  2. <head>
  3. <title>VBox Layout</title>
  4. <link rel="stylesheet" type="text/css" href="../../resources/css/ext-all.css" />
  5. <link rel="stylesheet" type="text/css" href="../shared/example.css" />
  6. <!-- GC -->
  7. <script type="text/javascript" src="../../ext-all.js"></script>
  8. <style type="text/css">
  9. html, body {
  10. font: normal 12px verdana;
  11. margin: 0;
  12. padding: 0;
  13. border: 0 none;
  14. }
  15. </style>
  16. <script type="text/javascript">
  17. Ext.onReady(function() {
  18. var currentName;
  19. var replace = function(config, name) {
  20. var btns = Ext.getCmp('btns');
  21. if (name && name != currentName) {
  22. currentName = name;
  23. btns.remove(0);
  24. btns.add(Ext.apply(config));
  25. }
  26. };
  27. var viewport = Ext.create('Ext.Viewport', {
  28. layout:'border',
  29. items: [{
  30. id:'btns',
  31. region:'west',
  32. baseCls:'x-plain',
  33. split:true,
  34. width:150,
  35. minWidth: 100,
  36. maxWidth: 250,
  37. layout:'fit',
  38. margins: '5 0 5 5',
  39. items: {
  40. baseCls: 'x-plain',
  41. html: '<p style="padding:10px;color:#556677;font-size:11px;">Select a configuration to the right &raquo;</p>'
  42. }
  43. }, {
  44. region:'center',
  45. margins: '5 5 5 0',
  46. layout: 'anchor',
  47. items:[{
  48. anchor: '100%',
  49. baseCls:'x-plain',
  50. layout: {
  51. type:'hbox',
  52. padding: 10
  53. },
  54. defaults:{
  55. margins:'0 5 0 0',
  56. pressed: false,
  57. toggleGroup:'btns',
  58. allowDepress: false
  59. },
  60. items: [{
  61. xtype:'button',
  62. text: 'Spaced / Align: left',
  63. handler: function(){
  64. replace({
  65. layout: {
  66. type:'vbox',
  67. padding:'5',
  68. align:'left'
  69. },
  70. defaults:{margins:'0 0 5 0'},
  71. items:[{
  72. xtype:'button',
  73. text: 'Button 1'
  74. },{
  75. xtype:'tbspacer',
  76. flex:1
  77. },{
  78. xtype:'button',
  79. text: 'Button 2'
  80. },{
  81. xtype:'button',
  82. text: 'Button 3'
  83. },{
  84. xtype:'button',
  85. text: 'Button 4',
  86. margins:'0'
  87. }]
  88. }, 'spaced');
  89. }
  90. },{
  91. xtype:'button',
  92. text: 'Multi-Spaced / Align: left',
  93. handler: function(){
  94. replace({
  95. layout: {
  96. type:'vbox',
  97. padding:'5',
  98. align:'left'
  99. },
  100. defaults:{margins:'0 0 5 0'},
  101. items:[{
  102. xtype:'button',
  103. text: 'Button 1'
  104. },{
  105. xtype:'tbspacer',
  106. flex:1
  107. },{
  108. xtype:'button',
  109. text: 'Button 2'
  110. },{
  111. xtype:'tbspacer',
  112. flex:1
  113. },{
  114. xtype:'button',
  115. text: 'Button 3'
  116. },{
  117. xtype:'tbspacer',
  118. flex:1
  119. },{
  120. xtype:'button',
  121. text: 'Button 4',
  122. margins:'0'
  123. }]
  124. }, 'multi spaced - align left');
  125. }
  126. },{
  127. xtype:'button',
  128. text: 'Align: left',
  129. handler: function(){
  130. replace({
  131. layout: {
  132. type:'vbox',
  133. padding:'5',
  134. align:'left'
  135. },
  136. defaults:{margins:'0 0 5 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. }, 'align left');
  151. }
  152. },{
  153. xtype:'button',
  154. text: 'Align: center',
  155. handler: function(){
  156. replace({
  157. layout: {
  158. type:'vbox',
  159. padding:'5',
  160. align:'center'
  161. },
  162. defaults:{margins:'0 0 5 0'},
  163. items:[{
  164. xtype:'button',
  165. text: 'Button 1'
  166. },{
  167. xtype:'button',
  168. text: 'Button 2'
  169. },{
  170. xtype:'button',
  171. text: 'Button 3'
  172. },{
  173. xtype:'button',
  174. text: 'Button 4'
  175. }]
  176. }, 'align center');
  177. }
  178. },{
  179. xtype:'button',
  180. text: 'Align: stretch',
  181. handler: function(){
  182. replace({
  183. layout: {
  184. type:'vbox',
  185. padding:'5',
  186. align:'stretch'
  187. },
  188. defaults:{margins:'0 0 5 0'},
  189. items:[{
  190. xtype:'button',
  191. text: 'Button 1'
  192. },{
  193. xtype:'button',
  194. text: 'Button 2'
  195. },{
  196. xtype:'button',
  197. text: 'Button 3'
  198. },{
  199. xtype:'button',
  200. text: 'Button 4'
  201. }]
  202. }, 'align stretch');
  203. }
  204. },{
  205. xtype:'button',
  206. text: 'Align: stretchmax',
  207. handler: function(){
  208. replace({
  209. layout: {
  210. type:'vbox',
  211. padding:'5',
  212. align:'stretchmax'
  213. },
  214. defaults:{margins:'0 0 5 0'},
  215. items:[{
  216. xtype:'button',
  217. text: 'Jamie'
  218. },{
  219. xtype:'button',
  220. text: 'Aaron'
  221. },{
  222. xtype:'button',
  223. text: 'Tommy'
  224. },{
  225. xtype:'button',
  226. text: 'Ed '
  227. }]
  228. }, 'align stretchmax');
  229. }
  230. }]
  231. },{
  232. anchor: '100%',
  233. baseCls:'x-plain',
  234. layout: {
  235. type:'hbox',
  236. padding: '0 10 10'
  237. },
  238. defaults:{
  239. margins:'0 5 0 0',
  240. pressed: false,
  241. toggleGroup:'btns',
  242. allowDepress: false
  243. },
  244. items: [{
  245. xtype:'button',
  246. text: 'Flex: Even / Align: center',
  247. handler: function(){
  248. replace({
  249. layout: {
  250. type:'vbox',
  251. padding:'5',
  252. align:'center'
  253. },
  254. defaults:{margins:'0 0 5 0'},
  255. items:[{
  256. xtype:'button',
  257. text: 'Button 1',
  258. flex:1
  259. },{
  260. xtype:'button',
  261. text: 'Button 2',
  262. flex:1
  263. },{
  264. xtype:'button',
  265. text: 'Button 3',
  266. flex:1
  267. },{
  268. xtype:'button',
  269. text: 'Button 4',
  270. flex:1,
  271. margins:'0'
  272. }]
  273. }, 'align flex even');
  274. }
  275. },{
  276. xtype:'button',
  277. text: 'Flex: Ratio / Align: center',
  278. handler: function(){
  279. replace({
  280. layout: {
  281. type:'vbox',
  282. padding:'5',
  283. align:'center'
  284. },
  285. defaults:{margins:'0 0 5 0'},
  286. items:[{
  287. xtype:'button',
  288. text: 'Button 1',
  289. flex:1
  290. },{
  291. xtype:'button',
  292. text: 'Button 2',
  293. flex:1
  294. },{
  295. xtype:'button',
  296. text: 'Button 3',
  297. flex:1
  298. },{
  299. xtype:'button',
  300. text: 'Button 4',
  301. flex:3,
  302. margins:'0'
  303. }]
  304. }, 'align flex ratio');
  305. }
  306. },{
  307. xtype:'button',
  308. text: 'Flex + Stretch',
  309. handler: function(){
  310. replace({
  311. layout: {
  312. type:'vbox',
  313. padding:'5',
  314. align:'stretch'
  315. },
  316. defaults:{margins:'0 0 5 0'},
  317. items:[{
  318. xtype:'button',
  319. text: 'Button 1',
  320. flex:1
  321. },{
  322. xtype:'button',
  323. text: 'Button 2',
  324. flex:1
  325. },{
  326. xtype:'button',
  327. text: 'Button 3',
  328. flex:1
  329. },{
  330. xtype:'button',
  331. text: 'Button 4',
  332. flex:3,
  333. margins:'0'
  334. }]
  335. }, 'align flex + stretch');
  336. }
  337. },{
  338. xtype:'button',
  339. text: 'Pack: start / Align: center',
  340. handler: function(){
  341. replace({
  342. layout: {
  343. type:'vbox',
  344. padding:'5',
  345. pack:'start',
  346. align:'center'
  347. },
  348. defaults:{margins:'0 0 5 0'},
  349. items:[{
  350. xtype:'button',
  351. text: 'Button 1'
  352. },{
  353. xtype:'button',
  354. text: 'Button 2'
  355. },{
  356. xtype:'button',
  357. text: 'Button 3'
  358. },{
  359. xtype:'button',
  360. text: 'Button 4'
  361. }]
  362. }, 'align pack start + align center');
  363. }
  364. },{
  365. xtype:'button',
  366. text: 'Pack: center / Align: center',
  367. handler: function(){
  368. replace({
  369. layout: {
  370. type:'vbox',
  371. padding:'5',
  372. pack:'center',
  373. align:'center'
  374. },
  375. defaults:{margins:'0 0 5 0'},
  376. items:[{
  377. xtype:'button',
  378. text: 'Button 1'
  379. },{
  380. xtype:'button',
  381. text: 'Button 2'
  382. },{
  383. xtype:'button',
  384. text: 'Button 3'
  385. },{
  386. xtype:'button',
  387. text: 'Button 4',
  388. margins:'0'
  389. }]
  390. }, 'align pack center + align center');
  391. }
  392. },{
  393. xtype:'button',
  394. text: 'Pack: end / Align: center',
  395. handler: function(){
  396. replace({
  397. layout: {
  398. type:'vbox',
  399. padding:'5',
  400. pack:'end',
  401. align:'center'
  402. },
  403. defaults:{margins:'0 0 5 0'},
  404. items:[{
  405. xtype:'button',
  406. text: 'Button 1'
  407. },{
  408. xtype:'button',
  409. text: 'Button 2'
  410. },{
  411. xtype:'button',
  412. text: 'Button 3'
  413. },{
  414. xtype:'button',
  415. text: 'Button 4',
  416. margins:'0'
  417. }]
  418. }, 'align pack end + align center');
  419. }
  420. }]
  421. }]
  422. }]
  423. });
  424. });
  425. </script>
  426. </head>
  427. <body>
  428. </body>
  429. </html>