3 <title>The source code</title>
\r
4 <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
\r
5 <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
\r
7 <body onload="prettyPrint();">
\r
8 <pre class="prettyprint lang-js">/**
\r
9 * @class Ext.EventManager
\r
11 Ext.apply(Ext.EventManager, function(){
\r
18 propRe = /^(?:scope|delay|buffer|single|stopEvent|preventDefault|stopPropagation|normalized|args|delegate)$/,
\r
21 // note 1: IE fires ONLY the keydown event on specialkey autorepeat
\r
22 // note 2: Safari < 3.1, Gecko (Mac/Linux) & Opera fire only the keypress event on specialkey autorepeat
\r
23 // (research done by @Jan Wolter at http://unixpapa.com/js/key.html)
\r
24 useKeydown = Ext.isSafari ?
\r
25 Ext.num(navigator.userAgent.toLowerCase().match(/version\/(\d+\.\d)/)[1] || 2) >= 3.1 :
\r
26 !((Ext.isGecko && !Ext.isWindows) || Ext.isOpera);
\r
30 doResizeEvent: function(){
\r
31 var h = D.getViewHeight(),
\r
32 w = D.getViewWidth();
\r
34 //whacky problem in IE where the resize event will fire even though the w/h are the same.
\r
35 if(curHeight != h || curWidth != w){
\r
36 resizeEvent.fire(curWidth = w, curHeight = h);
\r
40 <div id="method-Ext.EventManager-onWindowResize"></div>/**
\r
41 * Fires when the window is resized and provides resize event buffering (50 milliseconds), passes new viewport width and height to handlers.
\r
42 * @param {Function} fn The method the event invokes
\r
43 * @param {Object} scope An object that becomes the scope of the handler
\r
44 * @param {boolean} options
\r
46 onWindowResize : function(fn, scope, options){
\r
48 resizeEvent = new Ext.util.Event();
\r
49 resizeTask = new Ext.util.DelayedTask(this.doResizeEvent);
\r
50 E.on(window, "resize", this.fireWindowResize, this);
\r
52 resizeEvent.addListener(fn, scope, options);
\r
55 // exposed only to allow manual firing
\r
56 fireWindowResize : function(){
\r
58 if((Ext.isIE||Ext.isAir) && resizeTask){
\r
59 resizeTask.delay(50);
\r
61 resizeEvent.fire(D.getViewWidth(), D.getViewHeight());
\r
66 <div id="method-Ext.EventManager-onTextResize"></div>/**
\r
67 * Fires when the user changes the active text size. Handler gets called with 2 params, the old size and the new size.
\r
68 * @param {Function} fn The method the event invokes
\r
69 * @param {Object} scope An object that becomes the scope of the handler
\r
70 * @param {boolean} options
\r
72 onTextResize : function(fn, scope, options){
\r
74 textEvent = new Ext.util.Event();
\r
75 var textEl = new Ext.Element(document.createElement('div'));
\r
76 textEl.dom.className = 'x-text-resize';
\r
77 textEl.dom.innerHTML = 'X';
\r
78 textEl.appendTo(document.body);
\r
79 textSize = textEl.dom.offsetHeight;
\r
80 setInterval(function(){
\r
81 if(textEl.dom.offsetHeight != textSize){
\r
82 textEvent.fire(textSize, textSize = textEl.dom.offsetHeight);
\r
84 }, this.textResizeInterval);
\r
86 textEvent.addListener(fn, scope, options);
\r
89 <div id="method-Ext.EventManager-removeResizeListener"></div>/**
\r
90 * Removes the passed window resize listener.
\r
91 * @param {Function} fn The method the event invokes
\r
92 * @param {Object} scope The scope of handler
\r
94 removeResizeListener : function(fn, scope){
\r
96 resizeEvent.removeListener(fn, scope);
\r
101 fireResize : function(){
\r
103 resizeEvent.fire(D.getViewWidth(), D.getViewHeight());
\r
107 <div id="prop-Ext.EventManager-textResizeInterval"></div>/**
\r
108 * The frequency, in milliseconds, to check for text resize events (defaults to 50)
\r
110 textResizeInterval : 50,
\r
112 <div id="prop-Ext.EventManager-ieDeferSrc"></div>/**
\r
113 * Url used for onDocumentReady with using SSL (defaults to Ext.SSL_SECURE_URL)
\r
115 ieDeferSrc : false,
\r
117 // protected for use inside the framework
\r
118 // detects whether we should use keydown or keypress based on the browser.
\r
119 useKeydown: useKeydown
\r
123 Ext.EventManager.on = Ext.EventManager.addListener;
\r
126 Ext.apply(Ext.EventObjectImpl.prototype, {
\r
127 <div id="prop-Ext.EventManager-BACKSPACE"></div>/** Key constant @type Number */
\r
129 <div id="prop-Ext.EventManager-TAB"></div>/** Key constant @type Number */
\r
131 <div id="prop-Ext.EventManager-NUM_CENTER"></div>/** Key constant @type Number */
\r
133 <div id="prop-Ext.EventManager-ENTER"></div>/** Key constant @type Number */
\r
135 <div id="prop-Ext.EventManager-RETURN"></div>/** Key constant @type Number */
\r
137 <div id="prop-Ext.EventManager-SHIFT"></div>/** Key constant @type Number */
\r
139 <div id="prop-Ext.EventManager-CTRL"></div>/** Key constant @type Number */
\r
141 CONTROL : 17, // legacy
\r
142 <div id="prop-Ext.EventManager-ALT"></div>/** Key constant @type Number */
\r
144 <div id="prop-Ext.EventManager-PAUSE"></div>/** Key constant @type Number */
\r
146 <div id="prop-Ext.EventManager-CAPS_LOCK"></div>/** Key constant @type Number */
\r
148 <div id="prop-Ext.EventManager-ESC"></div>/** Key constant @type Number */
\r
150 <div id="prop-Ext.EventManager-SPACE"></div>/** Key constant @type Number */
\r
152 <div id="prop-Ext.EventManager-PAGE_UP"></div>/** Key constant @type Number */
\r
154 PAGEUP : 33, // legacy
\r
155 <div id="prop-Ext.EventManager-PAGE_DOWN"></div>/** Key constant @type Number */
\r
157 PAGEDOWN : 34, // legacy
\r
158 <div id="prop-Ext.EventManager-END"></div>/** Key constant @type Number */
\r
160 <div id="prop-Ext.EventManager-HOME"></div>/** Key constant @type Number */
\r
162 <div id="prop-Ext.EventManager-LEFT"></div>/** Key constant @type Number */
\r
164 <div id="prop-Ext.EventManager-UP"></div>/** Key constant @type Number */
\r
166 <div id="prop-Ext.EventManager-RIGHT"></div>/** Key constant @type Number */
\r
168 <div id="prop-Ext.EventManager-DOWN"></div>/** Key constant @type Number */
\r
170 <div id="prop-Ext.EventManager-PRINT_SCREEN"></div>/** Key constant @type Number */
\r
172 <div id="prop-Ext.EventManager-INSERT"></div>/** Key constant @type Number */
\r
174 <div id="prop-Ext.EventManager-DELETE"></div>/** Key constant @type Number */
\r
176 <div id="prop-Ext.EventManager-ZERO"></div>/** Key constant @type Number */
\r
178 <div id="prop-Ext.EventManager-ONE"></div>/** Key constant @type Number */
\r
180 <div id="prop-Ext.EventManager-TWO"></div>/** Key constant @type Number */
\r
182 <div id="prop-Ext.EventManager-THREE"></div>/** Key constant @type Number */
\r
184 <div id="prop-Ext.EventManager-FOUR"></div>/** Key constant @type Number */
\r
186 <div id="prop-Ext.EventManager-FIVE"></div>/** Key constant @type Number */
\r
188 <div id="prop-Ext.EventManager-SIX"></div>/** Key constant @type Number */
\r
190 <div id="prop-Ext.EventManager-SEVEN"></div>/** Key constant @type Number */
\r
192 <div id="prop-Ext.EventManager-EIGHT"></div>/** Key constant @type Number */
\r
194 <div id="prop-Ext.EventManager-NINE"></div>/** Key constant @type Number */
\r
196 <div id="prop-Ext.EventManager-A"></div>/** Key constant @type Number */
\r
198 <div id="prop-Ext.EventManager-B"></div>/** Key constant @type Number */
\r
200 <div id="prop-Ext.EventManager-C"></div>/** Key constant @type Number */
\r
202 <div id="prop-Ext.EventManager-D"></div>/** Key constant @type Number */
\r
204 <div id="prop-Ext.EventManager-E"></div>/** Key constant @type Number */
\r
206 <div id="prop-Ext.EventManager-F"></div>/** Key constant @type Number */
\r
208 <div id="prop-Ext.EventManager-G"></div>/** Key constant @type Number */
\r
210 <div id="prop-Ext.EventManager-H"></div>/** Key constant @type Number */
\r
212 <div id="prop-Ext.EventManager-I"></div>/** Key constant @type Number */
\r
214 <div id="prop-Ext.EventManager-J"></div>/** Key constant @type Number */
\r
216 <div id="prop-Ext.EventManager-K"></div>/** Key constant @type Number */
\r
218 <div id="prop-Ext.EventManager-L"></div>/** Key constant @type Number */
\r
220 <div id="prop-Ext.EventManager-M"></div>/** Key constant @type Number */
\r
222 <div id="prop-Ext.EventManager-N"></div>/** Key constant @type Number */
\r
224 <div id="prop-Ext.EventManager-O"></div>/** Key constant @type Number */
\r
226 <div id="prop-Ext.EventManager-P"></div>/** Key constant @type Number */
\r
228 <div id="prop-Ext.EventManager-Q"></div>/** Key constant @type Number */
\r
230 <div id="prop-Ext.EventManager-R"></div>/** Key constant @type Number */
\r
232 <div id="prop-Ext.EventManager-S"></div>/** Key constant @type Number */
\r
234 <div id="prop-Ext.EventManager-T"></div>/** Key constant @type Number */
\r
236 <div id="prop-Ext.EventManager-U"></div>/** Key constant @type Number */
\r
238 <div id="prop-Ext.EventManager-V"></div>/** Key constant @type Number */
\r
240 <div id="prop-Ext.EventManager-W"></div>/** Key constant @type Number */
\r
242 <div id="prop-Ext.EventManager-X"></div>/** Key constant @type Number */
\r
244 <div id="prop-Ext.EventManager-Y"></div>/** Key constant @type Number */
\r
246 <div id="prop-Ext.EventManager-Z"></div>/** Key constant @type Number */
\r
248 <div id="prop-Ext.EventManager-CONTEXT_MENU"></div>/** Key constant @type Number */
\r
250 <div id="prop-Ext.EventManager-NUM_ZERO"></div>/** Key constant @type Number */
\r
252 <div id="prop-Ext.EventManager-NUM_ONE"></div>/** Key constant @type Number */
\r
254 <div id="prop-Ext.EventManager-NUM_TWO"></div>/** Key constant @type Number */
\r
256 <div id="prop-Ext.EventManager-NUM_THREE"></div>/** Key constant @type Number */
\r
258 <div id="prop-Ext.EventManager-NUM_FOUR"></div>/** Key constant @type Number */
\r
260 <div id="prop-Ext.EventManager-NUM_FIVE"></div>/** Key constant @type Number */
\r
262 <div id="prop-Ext.EventManager-NUM_SIX"></div>/** Key constant @type Number */
\r
264 <div id="prop-Ext.EventManager-NUM_SEVEN"></div>/** Key constant @type Number */
\r
266 <div id="prop-Ext.EventManager-NUM_EIGHT"></div>/** Key constant @type Number */
\r
268 <div id="prop-Ext.EventManager-NUM_NINE"></div>/** Key constant @type Number */
\r
270 <div id="prop-Ext.EventManager-NUM_MULTIPLY"></div>/** Key constant @type Number */
\r
272 <div id="prop-Ext.EventManager-NUM_PLUS"></div>/** Key constant @type Number */
\r
274 <div id="prop-Ext.EventManager-NUM_MINUS"></div>/** Key constant @type Number */
\r
276 <div id="prop-Ext.EventManager-NUM_PERIOD"></div>/** Key constant @type Number */
\r
278 <div id="prop-Ext.EventManager-NUM_DIVISION"></div>/** Key constant @type Number */
\r
280 <div id="prop-Ext.EventManager-F1"></div>/** Key constant @type Number */
\r
282 <div id="prop-Ext.EventManager-F2"></div>/** Key constant @type Number */
\r
284 <div id="prop-Ext.EventManager-F3"></div>/** Key constant @type Number */
\r
286 <div id="prop-Ext.EventManager-F4"></div>/** Key constant @type Number */
\r
288 <div id="prop-Ext.EventManager-F5"></div>/** Key constant @type Number */
\r
290 <div id="prop-Ext.EventManager-F6"></div>/** Key constant @type Number */
\r
292 <div id="prop-Ext.EventManager-F7"></div>/** Key constant @type Number */
\r
294 <div id="prop-Ext.EventManager-F8"></div>/** Key constant @type Number */
\r
296 <div id="prop-Ext.EventManager-F9"></div>/** Key constant @type Number */
\r
298 <div id="prop-Ext.EventManager-F10"></div>/** Key constant @type Number */
\r
300 <div id="prop-Ext.EventManager-F11"></div>/** Key constant @type Number */
\r
302 <div id="prop-Ext.EventManager-F12"></div>/** Key constant @type Number */
\r
306 isNavKeyPress : function(){
\r
308 k = this.normalizeKey(me.keyCode);
\r
309 return (k >= 33 && k <= 40) || // Page Up/Down, End, Home, Left, Up, Right, Down
\r
315 isSpecialKey : function(){
\r
316 var k = this.normalizeKey(this.keyCode);
\r
317 return (this.type == 'keypress' && this.ctrlKey) ||
\r
318 this.isNavKeyPress() ||
\r
319 (k == this.BACKSPACE) || // Backspace
\r
320 (k >= 16 && k <= 20) || // Shift, Ctrl, Alt, Pause, Caps Lock
\r
321 (k >= 44 && k <= 45); // Print Screen, Insert
\r
324 getPoint : function(){
\r
325 return new Ext.lib.Point(this.xy[0], this.xy[1]);
\r
328 <div id="method-Ext.EventManager-hasModifier"></div>/**
\r
329 * Returns true if the control, meta, shift or alt key was pressed during this event.
\r
330 * @return {Boolean}
\r
332 hasModifier : function(){
\r
333 return ((this.ctrlKey || this.altKey) || this.shiftKey);
\r