3 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
4 <title>The source code</title>
5 <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
6 <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
8 <body onload="prettyPrint();">
9 <pre class="prettyprint lang-js">/*!
10 * Ext JS Library 3.2.1
11 * Copyright(c) 2006-2010 Ext JS, Inc.
13 * http://www.extjs.com/license
16 * @class Ext.EventManager
18 Ext.apply(Ext.EventManager, function(){
24 propRe = /^(?:scope|delay|buffer|single|stopEvent|preventDefault|stopPropagation|normalized|args|delegate)$/,
27 // note 1: IE fires ONLY the keydown event on specialkey autorepeat
28 // note 2: Safari < 3.1, Gecko (Mac/Linux) & Opera fire only the keypress event on specialkey autorepeat
29 // (research done by @Jan Wolter at http://unixpapa.com/js/key.html)
30 useKeydown = Ext.isWebKit ?
31 Ext.num(navigator.userAgent.match(/AppleWebKit\/(\d+)/)[1]) >= 525 :
32 !((Ext.isGecko && !Ext.isWindows) || Ext.isOpera);
36 doResizeEvent: function(){
37 var h = D.getViewHeight(),
40 //whacky problem in IE where the resize event will fire even though the w/h are the same.
41 if(curHeight != h || curWidth != w){
42 resizeEvent.fire(curWidth = w, curHeight = h);
46 <div id="method-Ext.EventManager-onWindowResize"></div>/**
47 * Adds a listener to be notified when the browser window is resized and provides resize event buffering (100 milliseconds),
48 * passes new viewport width and height to handlers.
49 * @param {Function} fn The handler function the window resize event invokes.
50 * @param {Object} scope The scope (<code>this</code> reference) in which the handler function executes. Defaults to the browser window.
51 * @param {boolean} options Options object as passed to {@link Ext.Element#addListener}
53 onWindowResize : function(fn, scope, options){
55 resizeEvent = new Ext.util.Event();
56 resizeTask = new Ext.util.DelayedTask(this.doResizeEvent);
57 Ext.EventManager.on(window, "resize", this.fireWindowResize, this);
59 resizeEvent.addListener(fn, scope, options);
62 // exposed only to allow manual firing
63 fireWindowResize : function(){
65 resizeTask.delay(100);
69 <div id="method-Ext.EventManager-onTextResize"></div>/**
70 * Adds a listener to be notified when the user changes the active text size. Handler gets called with 2 params, the old size and the new size.
71 * @param {Function} fn The function the event invokes.
72 * @param {Object} scope The scope (<code>this</code> reference) in which the handler function executes. Defaults to the browser window.
73 * @param {boolean} options Options object as passed to {@link Ext.Element#addListener}
75 onTextResize : function(fn, scope, options){
77 textEvent = new Ext.util.Event();
78 var textEl = new Ext.Element(document.createElement('div'));
79 textEl.dom.className = 'x-text-resize';
80 textEl.dom.innerHTML = 'X';
81 textEl.appendTo(document.body);
82 textSize = textEl.dom.offsetHeight;
83 setInterval(function(){
84 if(textEl.dom.offsetHeight != textSize){
85 textEvent.fire(textSize, textSize = textEl.dom.offsetHeight);
87 }, this.textResizeInterval);
89 textEvent.addListener(fn, scope, options);
92 <div id="method-Ext.EventManager-removeResizeListener"></div>/**
93 * Removes the passed window resize listener.
94 * @param {Function} fn The method the event invokes
95 * @param {Object} scope The scope of handler
97 removeResizeListener : function(fn, scope){
99 resizeEvent.removeListener(fn, scope);
104 fireResize : function(){
106 resizeEvent.fire(D.getViewWidth(), D.getViewHeight());
110 <div id="prop-Ext.EventManager-textResizeInterval"></div>/**
111 * The frequency, in milliseconds, to check for text resize events (defaults to 50)
113 textResizeInterval : 50,
115 <div id="prop-Ext.EventManager-ieDeferSrc"></div>/**
116 * Url used for onDocumentReady with using SSL (defaults to Ext.SSL_SECURE_URL)
120 // protected for use inside the framework
121 // detects whether we should use keydown or keypress based on the browser.
122 useKeydown: useKeydown
126 Ext.EventManager.on = Ext.EventManager.addListener;
129 Ext.apply(Ext.EventObjectImpl.prototype, {
130 <div id="prop-Ext.EventManager-BACKSPACE"></div>/** Key constant @type Number */
132 <div id="prop-Ext.EventManager-TAB"></div>/** Key constant @type Number */
134 <div id="prop-Ext.EventManager-NUM_CENTER"></div>/** Key constant @type Number */
136 <div id="prop-Ext.EventManager-ENTER"></div>/** Key constant @type Number */
138 <div id="prop-Ext.EventManager-RETURN"></div>/** Key constant @type Number */
140 <div id="prop-Ext.EventManager-SHIFT"></div>/** Key constant @type Number */
142 <div id="prop-Ext.EventManager-CTRL"></div>/** Key constant @type Number */
144 CONTROL : 17, // legacy
145 <div id="prop-Ext.EventManager-ALT"></div>/** Key constant @type Number */
147 <div id="prop-Ext.EventManager-PAUSE"></div>/** Key constant @type Number */
149 <div id="prop-Ext.EventManager-CAPS_LOCK"></div>/** Key constant @type Number */
151 <div id="prop-Ext.EventManager-ESC"></div>/** Key constant @type Number */
153 <div id="prop-Ext.EventManager-SPACE"></div>/** Key constant @type Number */
155 <div id="prop-Ext.EventManager-PAGE_UP"></div>/** Key constant @type Number */
157 PAGEUP : 33, // legacy
158 <div id="prop-Ext.EventManager-PAGE_DOWN"></div>/** Key constant @type Number */
160 PAGEDOWN : 34, // legacy
161 <div id="prop-Ext.EventManager-END"></div>/** Key constant @type Number */
163 <div id="prop-Ext.EventManager-HOME"></div>/** Key constant @type Number */
165 <div id="prop-Ext.EventManager-LEFT"></div>/** Key constant @type Number */
167 <div id="prop-Ext.EventManager-UP"></div>/** Key constant @type Number */
169 <div id="prop-Ext.EventManager-RIGHT"></div>/** Key constant @type Number */
171 <div id="prop-Ext.EventManager-DOWN"></div>/** Key constant @type Number */
173 <div id="prop-Ext.EventManager-PRINT_SCREEN"></div>/** Key constant @type Number */
175 <div id="prop-Ext.EventManager-INSERT"></div>/** Key constant @type Number */
177 <div id="prop-Ext.EventManager-DELETE"></div>/** Key constant @type Number */
179 <div id="prop-Ext.EventManager-ZERO"></div>/** Key constant @type Number */
181 <div id="prop-Ext.EventManager-ONE"></div>/** Key constant @type Number */
183 <div id="prop-Ext.EventManager-TWO"></div>/** Key constant @type Number */
185 <div id="prop-Ext.EventManager-THREE"></div>/** Key constant @type Number */
187 <div id="prop-Ext.EventManager-FOUR"></div>/** Key constant @type Number */
189 <div id="prop-Ext.EventManager-FIVE"></div>/** Key constant @type Number */
191 <div id="prop-Ext.EventManager-SIX"></div>/** Key constant @type Number */
193 <div id="prop-Ext.EventManager-SEVEN"></div>/** Key constant @type Number */
195 <div id="prop-Ext.EventManager-EIGHT"></div>/** Key constant @type Number */
197 <div id="prop-Ext.EventManager-NINE"></div>/** Key constant @type Number */
199 <div id="prop-Ext.EventManager-A"></div>/** Key constant @type Number */
201 <div id="prop-Ext.EventManager-B"></div>/** Key constant @type Number */
203 <div id="prop-Ext.EventManager-C"></div>/** Key constant @type Number */
205 <div id="prop-Ext.EventManager-D"></div>/** Key constant @type Number */
207 <div id="prop-Ext.EventManager-E"></div>/** Key constant @type Number */
209 <div id="prop-Ext.EventManager-F"></div>/** Key constant @type Number */
211 <div id="prop-Ext.EventManager-G"></div>/** Key constant @type Number */
213 <div id="prop-Ext.EventManager-H"></div>/** Key constant @type Number */
215 <div id="prop-Ext.EventManager-I"></div>/** Key constant @type Number */
217 <div id="prop-Ext.EventManager-J"></div>/** Key constant @type Number */
219 <div id="prop-Ext.EventManager-K"></div>/** Key constant @type Number */
221 <div id="prop-Ext.EventManager-L"></div>/** Key constant @type Number */
223 <div id="prop-Ext.EventManager-M"></div>/** Key constant @type Number */
225 <div id="prop-Ext.EventManager-N"></div>/** Key constant @type Number */
227 <div id="prop-Ext.EventManager-O"></div>/** Key constant @type Number */
229 <div id="prop-Ext.EventManager-P"></div>/** Key constant @type Number */
231 <div id="prop-Ext.EventManager-Q"></div>/** Key constant @type Number */
233 <div id="prop-Ext.EventManager-R"></div>/** Key constant @type Number */
235 <div id="prop-Ext.EventManager-S"></div>/** Key constant @type Number */
237 <div id="prop-Ext.EventManager-T"></div>/** Key constant @type Number */
239 <div id="prop-Ext.EventManager-U"></div>/** Key constant @type Number */
241 <div id="prop-Ext.EventManager-V"></div>/** Key constant @type Number */
243 <div id="prop-Ext.EventManager-W"></div>/** Key constant @type Number */
245 <div id="prop-Ext.EventManager-X"></div>/** Key constant @type Number */
247 <div id="prop-Ext.EventManager-Y"></div>/** Key constant @type Number */
249 <div id="prop-Ext.EventManager-Z"></div>/** Key constant @type Number */
251 <div id="prop-Ext.EventManager-CONTEXT_MENU"></div>/** Key constant @type Number */
253 <div id="prop-Ext.EventManager-NUM_ZERO"></div>/** Key constant @type Number */
255 <div id="prop-Ext.EventManager-NUM_ONE"></div>/** Key constant @type Number */
257 <div id="prop-Ext.EventManager-NUM_TWO"></div>/** Key constant @type Number */
259 <div id="prop-Ext.EventManager-NUM_THREE"></div>/** Key constant @type Number */
261 <div id="prop-Ext.EventManager-NUM_FOUR"></div>/** Key constant @type Number */
263 <div id="prop-Ext.EventManager-NUM_FIVE"></div>/** Key constant @type Number */
265 <div id="prop-Ext.EventManager-NUM_SIX"></div>/** Key constant @type Number */
267 <div id="prop-Ext.EventManager-NUM_SEVEN"></div>/** Key constant @type Number */
269 <div id="prop-Ext.EventManager-NUM_EIGHT"></div>/** Key constant @type Number */
271 <div id="prop-Ext.EventManager-NUM_NINE"></div>/** Key constant @type Number */
273 <div id="prop-Ext.EventManager-NUM_MULTIPLY"></div>/** Key constant @type Number */
275 <div id="prop-Ext.EventManager-NUM_PLUS"></div>/** Key constant @type Number */
277 <div id="prop-Ext.EventManager-NUM_MINUS"></div>/** Key constant @type Number */
279 <div id="prop-Ext.EventManager-NUM_PERIOD"></div>/** Key constant @type Number */
281 <div id="prop-Ext.EventManager-NUM_DIVISION"></div>/** Key constant @type Number */
283 <div id="prop-Ext.EventManager-F1"></div>/** Key constant @type Number */
285 <div id="prop-Ext.EventManager-F2"></div>/** Key constant @type Number */
287 <div id="prop-Ext.EventManager-F3"></div>/** Key constant @type Number */
289 <div id="prop-Ext.EventManager-F4"></div>/** Key constant @type Number */
291 <div id="prop-Ext.EventManager-F5"></div>/** Key constant @type Number */
293 <div id="prop-Ext.EventManager-F6"></div>/** Key constant @type Number */
295 <div id="prop-Ext.EventManager-F7"></div>/** Key constant @type Number */
297 <div id="prop-Ext.EventManager-F8"></div>/** Key constant @type Number */
299 <div id="prop-Ext.EventManager-F9"></div>/** Key constant @type Number */
301 <div id="prop-Ext.EventManager-F10"></div>/** Key constant @type Number */
303 <div id="prop-Ext.EventManager-F11"></div>/** Key constant @type Number */
305 <div id="prop-Ext.EventManager-F12"></div>/** Key constant @type Number */
309 isNavKeyPress : function(){
311 k = this.normalizeKey(me.keyCode);
312 return (k >= 33 && k <= 40) || // Page Up/Down, End, Home, Left, Up, Right, Down
318 isSpecialKey : function(){
319 var k = this.normalizeKey(this.keyCode);
320 return (this.type == 'keypress' && this.ctrlKey) ||
321 this.isNavKeyPress() ||
322 (k == this.BACKSPACE) || // Backspace
323 (k >= 16 && k <= 20) || // Shift, Ctrl, Alt, Pause, Caps Lock
324 (k >= 44 && k <= 46); // Print Screen, Insert, Delete
327 getPoint : function(){
328 return new Ext.lib.Point(this.xy[0], this.xy[1]);
331 <div id="method-Ext.EventManager-hasModifier"></div>/**
332 * Returns true if the control, meta, shift or alt key was pressed during this event.
335 hasModifier : function(){
336 return ((this.ctrlKey || this.altKey) || this.shiftKey);