border.js 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. Ext.require(['*']);
  2. Ext.onReady(function() {
  3. var cw;
  4. function closeRegion (e, target, header, tool) {
  5. var region = header.ownerCt;
  6. newRegions.unshift(region.initialConfig);
  7. viewport.remove(region);
  8. }
  9. var newRegions = [{
  10. region: 'north',
  11. title: 'North 2',
  12. height: 100,
  13. collapsible: true,
  14. weight: -120
  15. }, {
  16. region: 'east',
  17. title: 'East 2',
  18. width: 100,
  19. collapsible: true,
  20. weight: -110
  21. }, {
  22. region: 'west',
  23. title: 'West 2',
  24. width: 100,
  25. collapsible: true,
  26. weight: -110
  27. }];
  28. var viewport = Ext.create('Ext.Viewport', {
  29. layout: {
  30. type: 'border',
  31. padding: 5
  32. },
  33. defaults: {
  34. split: true
  35. },
  36. items: [{
  37. region: 'north',
  38. collapsible: true,
  39. title: 'North',
  40. split: true,
  41. height: 100,
  42. minHeight: 60,
  43. html: 'north'
  44. },{
  45. region: 'west',
  46. collapsible: true,
  47. title: 'Starts at width 30%',
  48. split: true,
  49. width: '30%',
  50. minWidth: 100,
  51. minHeight: 140,
  52. html: 'west<br>I am floatable'
  53. },{
  54. region: 'center',
  55. html: 'center center',
  56. title: 'Center',
  57. minHeight: 80,
  58. items: [cw = Ext.create('Ext.Window', {
  59. xtype: 'window',
  60. closable: false,
  61. minimizable: true,
  62. title: 'Constrained Window',
  63. height: 200,
  64. width: 400,
  65. constrain: true,
  66. html: 'I am in a Container',
  67. itemId: 'center-window',
  68. minimize: function() {
  69. this.floatParent.down('button#toggleCw').toggle();
  70. }
  71. })],
  72. bbar: [ 'Text followed by a spacer', ' ', {
  73. itemId: 'toggleCw',
  74. text: 'Constrained Window',
  75. enableToggle: true,
  76. toggleHandler: function() {
  77. cw.setVisible(!cw.isVisible());
  78. }
  79. }, {
  80. text: 'Add Region',
  81. listeners: {
  82. click: function () {
  83. if (newRegions.length) {
  84. var region = newRegions.pop();
  85. region.tools = [ { type: 'close', handler: closeRegion }];
  86. viewport.add(region);
  87. } else {
  88. Ext.Msg.show({
  89. title: 'All added',
  90. msg: 'Close one of the dynamic regions first',
  91. //minWidth: Ext.Msg.minWidth,
  92. buttons: Ext.Msg.OK,
  93. icon: Ext.Msg.ERROR
  94. });
  95. }
  96. }
  97. }
  98. }, {
  99. text: 'Change Titles',
  100. listeners: {
  101. click: function () {
  102. var panels = viewport.query('panel');
  103. Ext.each(panels, function (panel) {
  104. panel.setTitle(panel.title + '!');
  105. })
  106. }
  107. }
  108. }]
  109. },{
  110. region: 'east',
  111. collapsible: true,
  112. floatable: true,
  113. split: true,
  114. width: 200,
  115. minWidth: 120,
  116. minHeight: 140,
  117. title: 'East',
  118. layout: {
  119. type: 'vbox',
  120. padding: 5,
  121. align: 'stretch'
  122. },
  123. items: [{
  124. xtype: 'textfield',
  125. labelWidth: 70,
  126. fieldLabel: 'Text field'
  127. }, {
  128. xtype: 'component',
  129. html: 'I am floatable'
  130. }]
  131. },{
  132. region: 'south',
  133. height: 100,
  134. split: true,
  135. collapsible: true,
  136. title: 'Splitter above me',
  137. minHeight: 60,
  138. html: 'center south',
  139. weight: -100
  140. },{
  141. region: 'south',
  142. collapsible: true,
  143. split: true,
  144. height: 200,
  145. minHeight: 120,
  146. title: 'South',
  147. layout: {
  148. type: 'border',
  149. padding: 5
  150. },
  151. items: [{
  152. title: 'South Central',
  153. region: 'center',
  154. minWidth: 80,
  155. html: 'South Central'
  156. }, {
  157. title: 'South Eastern',
  158. region: 'east',
  159. flex: 1,
  160. minWidth: 80,
  161. html: 'South Eastern',
  162. split: true,
  163. collapsible: true
  164. }, {
  165. title: 'South Western - not resizable',
  166. region: 'west',
  167. flex: 1,
  168. minWidth: 80,
  169. html: 'South Western<br>I collapse to nothing',
  170. split: true,
  171. collapsible: true,
  172. splitterResize: false,
  173. collapseMode: 'mini'
  174. }]
  175. }]
  176. });
  177. });