Upgrade to ExtJS 4.0.2 - Released 06/09/2011
[extjs.git] / examples / window / window.js
1 /*
2
3 This file is part of Ext JS 4
4
5 Copyright (c) 2011 Sencha Inc
6
7 Contact:  http://www.sencha.com/contact
8
9 GNU General Public License Usage
10 This file may be used under the terms of the GNU General Public License version 3.0 as published by the Free Software Foundation and appearing in the file LICENSE included in the packaging of this file.  Please review the following information to ensure the GNU General Public License version 3.0 requirements will be met: http://www.gnu.org/copyleft/gpl.html.
11
12 If you are unsure which license is appropriate for your use, please contact the sales department at http://www.sencha.com/contact.
13
14 */
15 Ext.require([
16     'Ext.window.Window',
17     'Ext.tab.*',
18     'Ext.toolbar.Spacer',
19     'Ext.layout.container.Card',
20     'Ext.layout.container.Border'
21 ]);
22
23 Ext.onReady(function(){
24     var floater, constrainedWin, constrainedWin2;
25
26     Ext.util.Region.override({
27         colors: ['red', 'orange', 'yellow', 'green', 'blue', 'indigo', 'violet'],
28         nextColor: 0,
29         show: function(){
30             var style = {
31                 display: 'block',
32                 position: 'absolute',
33                 top: this.top + 'px',
34                 left: this.left + 'px',
35                 height: ((this.bottom - this.top) + 1) + 'px',
36                 width: ((this.right - this.left) + 1) + 'px',
37                 opacity: 0.3,
38                 'pointer-events': 'none',
39                 'z-index': 9999999
40             };
41             if (!this.highlightEl) {
42                 style['background-color'] = this.colors[this.nextColor];
43                 Ext.util.Region.prototype.nextColor++;
44                 this.highlightEl = Ext.getBody().createChild({
45                     style: style
46                 });
47                 if (this.nextColor >= this.colors.length) {
48                     this.nextColor = 0;
49                 }
50             } else {
51                 this.highlightEl.setStyle(style);
52             }
53         },
54         hide: function(){
55             if (this.highlightEl) {
56                 this.highlightEl.setStyle({
57                     display: 'none'
58                 });
59             }
60         }
61     });
62
63     var win2 = Ext.create('widget.window', {
64         height: 200,
65         width: 400,
66         x: 450,
67         y: 450,
68         title: 'Constraining Window, plain: true',
69         closable: false,
70         plain: true,
71         layout: 'fit',
72         items: [floater = Ext.create('Ext.Component', {
73             xtype: 'component',
74             floating: {
75                 shadow: false
76             },
77             height: 50,
78             width: 50,
79             x: 175,
80             y: 75
81         }), constrainedWin = Ext.create('Ext.Window', {
82             title: 'Constrained Window',
83             width: 100,
84             height: 100,
85             x: 20,
86             y: 20,
87             constrain: true,
88             layout: 'fit',
89             items: {
90                 border: false
91             }
92         }), constrainedWin2 = Ext.create('Ext.Window', {
93             title: 'Header-Constrained Win',
94             width: 100,
95             height: 100,
96             x: 120,
97             y: 120,
98             constrainHeader: true,
99             layout: 'fit',
100             items: {
101                 border: false
102             }
103         }),{
104             border: false
105         }]
106     });
107     win2.show();
108     floater.show();
109     constrainedWin.show();
110     constrainedWin2.show();
111
112     Ext.create('Ext.Window', {
113         title: 'Left Header, plain: true',
114         width: 400,
115         height: 200,
116         x: 10,
117         y: 200,
118         plain: true,
119         headerPosition: 'left',
120         layout: 'fit',
121         items: {
122             border: false
123         }
124     }).show();
125
126     Ext.create('Ext.Window', {
127         title: 'Right Header, plain: true',
128         width: 400,
129         height: 200,
130         x: 450,
131         y: 200,
132         headerPosition: 'right',
133         layout: 'fit',
134         items: {
135             border: false
136         }
137     }).show();
138
139     Ext.create('Ext.Window', {
140         title: 'Bottom Header, plain: true',
141         width: 400,
142         height: 200,
143         x: 10,
144         y: 450,
145         plain: true,
146         headerPosition: 'bottom',
147         layout: 'fit',
148         items: {
149             border: false
150         }
151     }).show();
152 });
153