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