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 (50 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 if((Ext.isIE||Ext.isAir) && resizeTask){
62 resizeEvent.fire(D.getViewWidth(), D.getViewHeight());
67 <div id="method-Ext.EventManager-onTextResize"></div>/**
68 * 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.
69 * @param {Function} fn The function the event invokes.
70 * @param {Object} scope The scope (<code>this</code> reference) in which the handler function executes. Defaults to the browser window.
71 * @param {boolean} options Options object as passed to {@link Ext.Element#addListener}
73 onTextResize : function(fn, scope, options){
75 textEvent = new Ext.util.Event();
76 var textEl = new Ext.Element(document.createElement('div'));
77 textEl.dom.className = 'x-text-resize';
78 textEl.dom.innerHTML = 'X';
79 textEl.appendTo(document.body);
80 textSize = textEl.dom.offsetHeight;
81 setInterval(function(){
82 if(textEl.dom.offsetHeight != textSize){
83 textEvent.fire(textSize, textSize = textEl.dom.offsetHeight);
85 }, this.textResizeInterval);
87 textEvent.addListener(fn, scope, options);
90 <div id="method-Ext.EventManager-removeResizeListener"></div>/**
91 * Removes the passed window resize listener.
92 * @param {Function} fn The method the event invokes
93 * @param {Object} scope The scope of handler
95 removeResizeListener : function(fn, scope){
97 resizeEvent.removeListener(fn, scope);
102 fireResize : function(){
104 resizeEvent.fire(D.getViewWidth(), D.getViewHeight());
108 <div id="prop-Ext.EventManager-textResizeInterval"></div>/**
109 * The frequency, in milliseconds, to check for text resize events (defaults to 50)
111 textResizeInterval : 50,
113 <div id="prop-Ext.EventManager-ieDeferSrc"></div>/**
114 * Url used for onDocumentReady with using SSL (defaults to Ext.SSL_SECURE_URL)
118 // protected for use inside the framework
119 // detects whether we should use keydown or keypress based on the browser.
120 useKeydown: useKeydown
124 Ext.EventManager.on = Ext.EventManager.addListener;
127 Ext.apply(Ext.EventObjectImpl.prototype, {
128 <div id="prop-Ext.EventManager-BACKSPACE"></div>/** Key constant @type Number */
130 <div id="prop-Ext.EventManager-TAB"></div>/** Key constant @type Number */
132 <div id="prop-Ext.EventManager-NUM_CENTER"></div>/** Key constant @type Number */
134 <div id="prop-Ext.EventManager-ENTER"></div>/** Key constant @type Number */
136 <div id="prop-Ext.EventManager-RETURN"></div>/** Key constant @type Number */
138 <div id="prop-Ext.EventManager-SHIFT"></div>/** Key constant @type Number */
140 <div id="prop-Ext.EventManager-CTRL"></div>/** Key constant @type Number */
142 CONTROL : 17, // legacy
143 <div id="prop-Ext.EventManager-ALT"></div>/** Key constant @type Number */
145 <div id="prop-Ext.EventManager-PAUSE"></div>/** Key constant @type Number */
147 <div id="prop-Ext.EventManager-CAPS_LOCK"></div>/** Key constant @type Number */
149 <div id="prop-Ext.EventManager-ESC"></div>/** Key constant @type Number */
151 <div id="prop-Ext.EventManager-SPACE"></div>/** Key constant @type Number */
153 <div id="prop-Ext.EventManager-PAGE_UP"></div>/** Key constant @type Number */
155 PAGEUP : 33, // legacy
156 <div id="prop-Ext.EventManager-PAGE_DOWN"></div>/** Key constant @type Number */
158 PAGEDOWN : 34, // legacy
159 <div id="prop-Ext.EventManager-END"></div>/** Key constant @type Number */
161 <div id="prop-Ext.EventManager-HOME"></div>/** Key constant @type Number */
163 <div id="prop-Ext.EventManager-LEFT"></div>/** Key constant @type Number */
165 <div id="prop-Ext.EventManager-UP"></div>/** Key constant @type Number */
167 <div id="prop-Ext.EventManager-RIGHT"></div>/** Key constant @type Number */
169 <div id="prop-Ext.EventManager-DOWN"></div>/** Key constant @type Number */
171 <div id="prop-Ext.EventManager-PRINT_SCREEN"></div>/** Key constant @type Number */
173 <div id="prop-Ext.EventManager-INSERT"></div>/** Key constant @type Number */
175 <div id="prop-Ext.EventManager-DELETE"></div>/** Key constant @type Number */
177 <div id="prop-Ext.EventManager-ZERO"></div>/** Key constant @type Number */
179 <div id="prop-Ext.EventManager-ONE"></div>/** Key constant @type Number */
181 <div id="prop-Ext.EventManager-TWO"></div>/** Key constant @type Number */
183 <div id="prop-Ext.EventManager-THREE"></div>/** Key constant @type Number */
185 <div id="prop-Ext.EventManager-FOUR"></div>/** Key constant @type Number */
187 <div id="prop-Ext.EventManager-FIVE"></div>/** Key constant @type Number */
189 <div id="prop-Ext.EventManager-SIX"></div>/** Key constant @type Number */
191 <div id="prop-Ext.EventManager-SEVEN"></div>/** Key constant @type Number */
193 <div id="prop-Ext.EventManager-EIGHT"></div>/** Key constant @type Number */
195 <div id="prop-Ext.EventManager-NINE"></div>/** Key constant @type Number */
197 <div id="prop-Ext.EventManager-A"></div>/** Key constant @type Number */
199 <div id="prop-Ext.EventManager-B"></div>/** Key constant @type Number */
201 <div id="prop-Ext.EventManager-C"></div>/** Key constant @type Number */
203 <div id="prop-Ext.EventManager-D"></div>/** Key constant @type Number */
205 <div id="prop-Ext.EventManager-E"></div>/** Key constant @type Number */
207 <div id="prop-Ext.EventManager-F"></div>/** Key constant @type Number */
209 <div id="prop-Ext.EventManager-G"></div>/** Key constant @type Number */
211 <div id="prop-Ext.EventManager-H"></div>/** Key constant @type Number */
213 <div id="prop-Ext.EventManager-I"></div>/** Key constant @type Number */
215 <div id="prop-Ext.EventManager-J"></div>/** Key constant @type Number */
217 <div id="prop-Ext.EventManager-K"></div>/** Key constant @type Number */
219 <div id="prop-Ext.EventManager-L"></div>/** Key constant @type Number */
221 <div id="prop-Ext.EventManager-M"></div>/** Key constant @type Number */
223 <div id="prop-Ext.EventManager-N"></div>/** Key constant @type Number */
225 <div id="prop-Ext.EventManager-O"></div>/** Key constant @type Number */
227 <div id="prop-Ext.EventManager-P"></div>/** Key constant @type Number */
229 <div id="prop-Ext.EventManager-Q"></div>/** Key constant @type Number */
231 <div id="prop-Ext.EventManager-R"></div>/** Key constant @type Number */
233 <div id="prop-Ext.EventManager-S"></div>/** Key constant @type Number */
235 <div id="prop-Ext.EventManager-T"></div>/** Key constant @type Number */
237 <div id="prop-Ext.EventManager-U"></div>/** Key constant @type Number */
239 <div id="prop-Ext.EventManager-V"></div>/** Key constant @type Number */
241 <div id="prop-Ext.EventManager-W"></div>/** Key constant @type Number */
243 <div id="prop-Ext.EventManager-X"></div>/** Key constant @type Number */
245 <div id="prop-Ext.EventManager-Y"></div>/** Key constant @type Number */
247 <div id="prop-Ext.EventManager-Z"></div>/** Key constant @type Number */
249 <div id="prop-Ext.EventManager-CONTEXT_MENU"></div>/** Key constant @type Number */
251 <div id="prop-Ext.EventManager-NUM_ZERO"></div>/** Key constant @type Number */
253 <div id="prop-Ext.EventManager-NUM_ONE"></div>/** Key constant @type Number */
255 <div id="prop-Ext.EventManager-NUM_TWO"></div>/** Key constant @type Number */
257 <div id="prop-Ext.EventManager-NUM_THREE"></div>/** Key constant @type Number */
259 <div id="prop-Ext.EventManager-NUM_FOUR"></div>/** Key constant @type Number */
261 <div id="prop-Ext.EventManager-NUM_FIVE"></div>/** Key constant @type Number */
263 <div id="prop-Ext.EventManager-NUM_SIX"></div>/** Key constant @type Number */
265 <div id="prop-Ext.EventManager-NUM_SEVEN"></div>/** Key constant @type Number */
267 <div id="prop-Ext.EventManager-NUM_EIGHT"></div>/** Key constant @type Number */
269 <div id="prop-Ext.EventManager-NUM_NINE"></div>/** Key constant @type Number */
271 <div id="prop-Ext.EventManager-NUM_MULTIPLY"></div>/** Key constant @type Number */
273 <div id="prop-Ext.EventManager-NUM_PLUS"></div>/** Key constant @type Number */
275 <div id="prop-Ext.EventManager-NUM_MINUS"></div>/** Key constant @type Number */
277 <div id="prop-Ext.EventManager-NUM_PERIOD"></div>/** Key constant @type Number */
279 <div id="prop-Ext.EventManager-NUM_DIVISION"></div>/** Key constant @type Number */
281 <div id="prop-Ext.EventManager-F1"></div>/** Key constant @type Number */
283 <div id="prop-Ext.EventManager-F2"></div>/** Key constant @type Number */
285 <div id="prop-Ext.EventManager-F3"></div>/** Key constant @type Number */
287 <div id="prop-Ext.EventManager-F4"></div>/** Key constant @type Number */
289 <div id="prop-Ext.EventManager-F5"></div>/** Key constant @type Number */
291 <div id="prop-Ext.EventManager-F6"></div>/** Key constant @type Number */
293 <div id="prop-Ext.EventManager-F7"></div>/** Key constant @type Number */
295 <div id="prop-Ext.EventManager-F8"></div>/** Key constant @type Number */
297 <div id="prop-Ext.EventManager-F9"></div>/** Key constant @type Number */
299 <div id="prop-Ext.EventManager-F10"></div>/** Key constant @type Number */
301 <div id="prop-Ext.EventManager-F11"></div>/** Key constant @type Number */
303 <div id="prop-Ext.EventManager-F12"></div>/** Key constant @type Number */
307 isNavKeyPress : function(){
309 k = this.normalizeKey(me.keyCode);
310 return (k >= 33 && k <= 40) || // Page Up/Down, End, Home, Left, Up, Right, Down
316 isSpecialKey : function(){
317 var k = this.normalizeKey(this.keyCode);
318 return (this.type == 'keypress' && this.ctrlKey) ||
319 this.isNavKeyPress() ||
320 (k == this.BACKSPACE) || // Backspace
321 (k >= 16 && k <= 20) || // Shift, Ctrl, Alt, Pause, Caps Lock
322 (k >= 44 && k <= 45); // Print Screen, Insert
325 getPoint : function(){
326 return new Ext.lib.Point(this.xy[0], this.xy[1]);
329 <div id="method-Ext.EventManager-hasModifier"></div>/**
330 * Returns true if the control, meta, shift or alt key was pressed during this event.
333 hasModifier : function(){
334 return ((this.ctrlKey || this.altKey) || this.shiftKey);