window.js 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. Ext.require([
  2. 'Ext.window.Window',
  3. 'Ext.tab.*',
  4. 'Ext.toolbar.Spacer',
  5. 'Ext.layout.container.Card',
  6. 'Ext.layout.container.Border'
  7. ]);
  8. Ext.onReady(function(){
  9. var constrainedWin, constrainedWin2;
  10. Ext.util.Region.override({
  11. colors: ['red', 'orange', 'yellow', 'green', 'blue', 'indigo', 'violet'],
  12. nextColor: 0,
  13. show: function(){
  14. var style = {
  15. display: 'block',
  16. position: 'absolute',
  17. top: this.top + 'px',
  18. left: this.left + 'px',
  19. height: ((this.bottom - this.top) + 1) + 'px',
  20. width: ((this.right - this.left) + 1) + 'px',
  21. opacity: 0.3,
  22. 'pointer-events': 'none',
  23. 'z-index': 9999999
  24. };
  25. if (!this.highlightEl) {
  26. style['background-color'] = this.colors[this.nextColor];
  27. Ext.util.Region.prototype.nextColor++;
  28. this.highlightEl = Ext.getBody().createChild({
  29. style: style
  30. });
  31. if (this.nextColor >= this.colors.length) {
  32. this.nextColor = 0;
  33. }
  34. } else {
  35. this.highlightEl.setStyle(style);
  36. }
  37. },
  38. hide: function(){
  39. if (this.highlightEl) {
  40. this.highlightEl.setStyle({
  41. display: 'none'
  42. });
  43. }
  44. }
  45. });
  46. var win2 = Ext.create('widget.window', {
  47. height: 200,
  48. width: 400,
  49. x: 450,
  50. y: 450,
  51. title: 'Constraining Window, plain: true',
  52. closable: false,
  53. plain: true,
  54. layout: 'fit',
  55. items: [constrainedWin = Ext.create('Ext.Window', {
  56. title: 'Constrained Window',
  57. width: 200,
  58. height: 100,
  59. // Constraining will pull the Window leftwards so that it's within the parent Window
  60. x: 1000,
  61. y: 20,
  62. constrain: true,
  63. layout: 'fit',
  64. items: {
  65. border: false
  66. }
  67. }), constrainedWin2 = Ext.create('Ext.Window', {
  68. title: 'Header-Constrained Win',
  69. width: 200,
  70. height: 100,
  71. x: 120,
  72. y: 120,
  73. constrainHeader: true,
  74. layout: 'fit',
  75. items: {
  76. border: false
  77. }
  78. }),{
  79. border: false
  80. }]
  81. });
  82. win2.show();
  83. constrainedWin.show();
  84. constrainedWin2.show();
  85. Ext.create('Ext.Window', {
  86. title: 'Left Header, plain: true',
  87. width: 400,
  88. height: 200,
  89. x: 10,
  90. y: 200,
  91. plain: true,
  92. headerPosition: 'left',
  93. layout: 'fit',
  94. items: {
  95. border: false
  96. }
  97. }).show();
  98. Ext.create('Ext.Window', {
  99. title: 'Right Header, plain: true',
  100. width: 400,
  101. height: 200,
  102. x: 450,
  103. y: 200,
  104. headerPosition: 'right',
  105. layout: 'fit',
  106. items: {
  107. border: false
  108. }
  109. }).show();
  110. Ext.create('Ext.Window', {
  111. title: 'Bottom Header, plain: true',
  112. width: 400,
  113. height: 200,
  114. x: 10,
  115. y: 450,
  116. plain: true,
  117. headerPosition: 'bottom',
  118. layout: 'fit',
  119. items: {
  120. border: false
  121. }
  122. }).show();
  123. });