~mortenoh/+junk/dhis2-detailed-import-export

« back to all changes in this revision

Viewing changes to gis/dhis-gis-geostat/mfbase/ext/source/core/EventManager.js

  • Committer: larshelge at gmail
  • Date: 2009-03-03 16:46:36 UTC
  • Revision ID: larshelge@gmail.com-20090303164636-2sjlrquo7ib1gf7r
Initial check-in

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Ext JS Library 2.2
 
3
 * Copyright(c) 2006-2008, Ext JS, LLC.
 
4
 * licensing@extjs.com
 
5
 * 
 
6
 * http://extjs.com/license
 
7
 */
 
8
 
 
9
/**
 
10
 * @class Ext.EventManager
 
11
 * Registers event handlers that want to receive a normalized EventObject instead of the standard browser event and provides
 
12
 * several useful events directly.
 
13
 * See {@link Ext.EventObject} for more details on normalized event objects.
 
14
 * @singleton
 
15
 */
 
16
Ext.EventManager = function(){
 
17
    var docReadyEvent, docReadyProcId, docReadyState = false;
 
18
    var resizeEvent, resizeTask, textEvent, textSize;
 
19
    var E = Ext.lib.Event;
 
20
    var D = Ext.lib.Dom;
 
21
    // fix parser confusion
 
22
    var xname = 'Ex' + 't';
 
23
 
 
24
    var elHash = {};
 
25
 
 
26
    var addListener = function(el, ename, fn, wrap, scope){
 
27
        var id = Ext.id(el);
 
28
        if(!elHash[id]){
 
29
            elHash[id] = {};
 
30
        }
 
31
        var es = elHash[id];
 
32
        if(!es[ename]){
 
33
            es[ename] = [];
 
34
        }
 
35
        var ls = es[ename];
 
36
        ls.push({
 
37
            id: id,
 
38
            ename: ename,
 
39
            fn: fn,
 
40
            wrap: wrap,
 
41
            scope: scope
 
42
        });
 
43
 
 
44
         E.on(el, ename, wrap);
 
45
 
 
46
        if(ename == "mousewheel" && el.addEventListener){ // workaround for jQuery
 
47
            el.addEventListener("DOMMouseScroll", wrap, false);
 
48
            E.on(window, 'unload', function(){
 
49
                el.removeEventListener("DOMMouseScroll", wrap, false);
 
50
            });
 
51
        }
 
52
        if(ename == "mousedown" && el == document){ // fix stopped mousedowns on the document
 
53
            Ext.EventManager.stoppedMouseDownEvent.addListener(wrap);
 
54
        }
 
55
    }
 
56
 
 
57
    var removeListener = function(el, ename, fn, scope){
 
58
        el = Ext.getDom(el);
 
59
        var id = Ext.id(el), es = elHash[id], wrap;
 
60
        if(es){
 
61
            var ls = es[ename], l;
 
62
            if(ls){
 
63
                for(var i = 0, len = ls.length; i < len; i++){
 
64
                    l = ls[i];
 
65
                    if(l.fn == fn && (!scope || l.scope == scope)){
 
66
                        wrap = l.wrap;
 
67
                        E.un(el, ename, wrap);
 
68
                        ls.splice(i, 1);
 
69
                        break;
 
70
                    }
 
71
                }
 
72
            }
 
73
        }
 
74
        if(ename == "mousewheel" && el.addEventListener && wrap){
 
75
            el.removeEventListener("DOMMouseScroll", wrap, false);
 
76
        }
 
77
        if(ename == "mousedown" && el == document && wrap){ // fix stopped mousedowns on the document
 
78
            Ext.EventManager.stoppedMouseDownEvent.removeListener(wrap);
 
79
        }
 
80
    }
 
81
 
 
82
    var removeAll = function(el){
 
83
        el = Ext.getDom(el);
 
84
        var id = Ext.id(el), es = elHash[id], ls;
 
85
        if(es){
 
86
            for(var ename in es){
 
87
                if(es.hasOwnProperty(ename)){
 
88
                    ls = es[ename];
 
89
                    for(var i = 0, len = ls.length; i < len; i++){
 
90
                        E.un(el, ename, ls[i].wrap);
 
91
                        ls[i] = null;
 
92
                    }
 
93
                }
 
94
                es[ename] = null;
 
95
            }
 
96
            delete elHash[id];
 
97
        }
 
98
    }
 
99
 
 
100
     var fireDocReady = function(){
 
101
        if(!docReadyState){
 
102
            docReadyState = Ext.isReady = true;
 
103
            if(Ext.isGecko || Ext.isOpera) {
 
104
                document.removeEventListener("DOMContentLoaded", fireDocReady, false);
 
105
            }
 
106
        }
 
107
        if(docReadyProcId){
 
108
            clearInterval(docReadyProcId);
 
109
            docReadyProcId = null;
 
110
        }
 
111
        if(docReadyEvent){
 
112
            docReadyEvent.fire();
 
113
            docReadyEvent.clearListeners();
 
114
       }
 
115
    };
 
116
 
 
117
    var initDocReady = function(){
 
118
        docReadyEvent = new Ext.util.Event();
 
119
 
 
120
        if(Ext.isReady){
 
121
            return;
 
122
        }
 
123
 
 
124
        // no matter what, make sure it fires on load
 
125
        E.on(window, 'load', fireDocReady);
 
126
 
 
127
        if(Ext.isGecko || Ext.isOpera) {
 
128
            document.addEventListener('DOMContentLoaded', fireDocReady, false);
 
129
        }
 
130
        else if(Ext.isIE){
 
131
            docReadyProcId = setInterval(function(){
 
132
                try{
 
133
                    // throws errors until DOM is ready
 
134
                    Ext.isReady || (document.documentElement.doScroll('left'));
 
135
                }catch(e){
 
136
                    return;
 
137
                }
 
138
                fireDocReady();  // no errors, fire
 
139
            }, 5);
 
140
 
 
141
                        document.onreadystatechange = function(){
 
142
                                if(document.readyState == 'complete'){
 
143
                                        document.onreadystatechange = null;
 
144
                                        fireDocReady();
 
145
                                }
 
146
            };
 
147
        }
 
148
        else if(Ext.isSafari){
 
149
            docReadyProcId = setInterval(function(){
 
150
                var rs = document.readyState;
 
151
                if(rs == 'complete') {
 
152
                    fireDocReady();
 
153
                 }
 
154
            }, 10);
 
155
        }
 
156
    };
 
157
 
 
158
    var createBuffered = function(h, o){
 
159
        var task = new Ext.util.DelayedTask(h);
 
160
        return function(e){
 
161
            // create new event object impl so new events don't wipe out properties
 
162
            e = new Ext.EventObjectImpl(e);
 
163
            task.delay(o.buffer, h, null, [e]);
 
164
        };
 
165
    };
 
166
 
 
167
    var createSingle = function(h, el, ename, fn, scope){
 
168
        return function(e){
 
169
            Ext.EventManager.removeListener(el, ename, fn, scope);
 
170
            h(e);
 
171
        };
 
172
    };
 
173
 
 
174
    var createDelayed = function(h, o){
 
175
        return function(e){
 
176
            // create new event object impl so new events don't wipe out properties
 
177
            e = new Ext.EventObjectImpl(e);
 
178
            setTimeout(function(){
 
179
                h(e);
 
180
            }, o.delay || 10);
 
181
        };
 
182
    };
 
183
 
 
184
    var listen = function(element, ename, opt, fn, scope){
 
185
        var o = (!opt || typeof opt == "boolean") ? {} : opt;
 
186
        fn = fn || o.fn; scope = scope || o.scope;
 
187
        var el = Ext.getDom(element);
 
188
        if(!el){
 
189
            throw "Error listening for \"" + ename + '\". Element "' + element + '" doesn\'t exist.';
 
190
        }
 
191
        var h = function(e){
 
192
            // prevent errors while unload occurring
 
193
            if(!window[xname]){
 
194
                return;
 
195
            }
 
196
            e = Ext.EventObject.setEvent(e);
 
197
            var t;
 
198
            if(o.delegate){
 
199
                t = e.getTarget(o.delegate, el);
 
200
                if(!t){
 
201
                    return;
 
202
                }
 
203
            }else{
 
204
                t = e.target;
 
205
            }
 
206
            if(o.stopEvent === true){
 
207
                e.stopEvent();
 
208
            }
 
209
            if(o.preventDefault === true){
 
210
               e.preventDefault();
 
211
            }
 
212
            if(o.stopPropagation === true){
 
213
                e.stopPropagation();
 
214
            }
 
215
 
 
216
            if(o.normalized === false){
 
217
                e = e.browserEvent;
 
218
            }
 
219
 
 
220
            fn.call(scope || el, e, t, o);
 
221
        };
 
222
        if(o.delay){
 
223
            h = createDelayed(h, o);
 
224
        }
 
225
        if(o.single){
 
226
            h = createSingle(h, el, ename, fn, scope);
 
227
        }
 
228
        if(o.buffer){
 
229
            h = createBuffered(h, o);
 
230
        }
 
231
 
 
232
        addListener(el, ename, fn, h, scope);
 
233
        return h;
 
234
    };
 
235
 
 
236
    var propRe = /^(?:scope|delay|buffer|single|stopEvent|preventDefault|stopPropagation|normalized|args|delegate)$/;
 
237
    var pub = {
 
238
 
 
239
    /**
 
240
     * Appends an event handler to an element.  The shorthand version {@link #on} is equivalent.  Typically you will
 
241
     * use {@link Ext.Element#addListener} directly on an Element in favor of calling this version.
 
242
     * @param {String/HTMLElement} el The html element or id to assign the event handler to
 
243
     * @param {String} eventName The type of event to listen for
 
244
     * @param {Function} handler The handler function the event invokes This function is passed
 
245
     * the following parameters:<ul>
 
246
     * <li>evt : EventObject<div class="sub-desc">The {@link Ext.EventObject EventObject} describing the event.</div></li>
 
247
     * <li>t : Element<div class="sub-desc">The {@link Ext.Element Element} which was the target of the event.
 
248
     * Note that this may be filtered by using the <tt>delegate</tt> option.</div></li>
 
249
     * <li>o : Object<div class="sub-desc">The options object from the addListener call.</div></li>
 
250
     * </ul>
 
251
     * @param {Object} scope (optional) The scope in which to execute the handler
 
252
     * function (the handler function's "this" context)
 
253
     * @param {Object} options (optional) An object containing handler configuration properties.
 
254
     * This may contain any of the following properties:<ul>
 
255
     * <li>scope {Object} : The scope in which to execute the handler function. The handler function's "this" context.</li>
 
256
     * <li>delegate {String} : A simple selector to filter the target or look for a descendant of the target</li>
 
257
     * <li>stopEvent {Boolean} : True to stop the event. That is stop propagation, and prevent the default action.</li>
 
258
     * <li>preventDefault {Boolean} : True to prevent the default action</li>
 
259
     * <li>stopPropagation {Boolean} : True to prevent event propagation</li>
 
260
     * <li>normalized {Boolean} : False to pass a browser event to the handler function instead of an Ext.EventObject</li>
 
261
     * <li>delay {Number} : The number of milliseconds to delay the invocation of the handler after te event fires.</li>
 
262
     * <li>single {Boolean} : True to add a handler to handle just the next firing of the event, and then remove itself.</li>
 
263
     * <li>buffer {Number} : Causes the handler to be scheduled to run in an {@link Ext.util.DelayedTask} delayed
 
264
     * by the specified number of milliseconds. If the event fires again within that time, the original
 
265
     * handler is <em>not</em> invoked, but the new handler is scheduled in its place.</li>
 
266
     * </ul><br>
 
267
     * <p>See {@link Ext.Element#addListener} for examples of how to use these options.</p>
 
268
     */
 
269
        addListener : function(element, eventName, fn, scope, options){
 
270
            if(typeof eventName == "object"){
 
271
                var o = eventName;
 
272
                for(var e in o){
 
273
                    if(propRe.test(e)){
 
274
                        continue;
 
275
                    }
 
276
                    if(typeof o[e] == "function"){
 
277
                        // shared options
 
278
                        listen(element, e, o, o[e], o.scope);
 
279
                    }else{
 
280
                        // individual options
 
281
                        listen(element, e, o[e]);
 
282
                    }
 
283
                }
 
284
                return;
 
285
            }
 
286
            return listen(element, eventName, options, fn, scope);
 
287
        },
 
288
 
 
289
        /**
 
290
         * Removes an event handler from an element.  The shorthand version {@link #un} is equivalent.  Typically
 
291
         * you will use {@link Ext.Element#removeListener} directly on an Element in favor of calling this version.
 
292
         * @param {String/HTMLElement} el The id or html element from which to remove the event
 
293
         * @param {String} eventName The type of event
 
294
         * @param {Function} fn The handler function to remove
 
295
         */
 
296
        removeListener : function(element, eventName, fn, scope){
 
297
            return removeListener(element, eventName, fn, scope);
 
298
        },
 
299
 
 
300
        /**
 
301
         * Removes all event handers from an element.  Typically you will use {@link Ext.Element#removeAllListeners}
 
302
         * directly on an Element in favor of calling this version.
 
303
         * @param {String/HTMLElement} el The id or html element from which to remove the event
 
304
         */
 
305
        removeAll : function(element){
 
306
            return removeAll(element);
 
307
        },
 
308
 
 
309
        /**
 
310
         * Fires when the document is ready (before onload and before images are loaded). Can be
 
311
         * accessed shorthanded as Ext.onReady().
 
312
         * @param {Function} fn The method the event invokes
 
313
         * @param {Object} scope (optional) An object that becomes the scope of the handler
 
314
         * @param {boolean} options (optional) An object containing standard {@link #addListener} options
 
315
         */
 
316
         onDocumentReady : function(fn, scope, options){
 
317
                        if(!docReadyEvent){
 
318
                initDocReady();
 
319
                        }
 
320
                        if(docReadyState || Ext.isReady){ // if it already fired
 
321
                                options || (options = {});
 
322
                                fn.defer(options.delay||0, scope);
 
323
                        }else{
 
324
                                docReadyEvent.addListener(fn, scope, options);
 
325
                        }
 
326
        },
 
327
 
 
328
        /**
 
329
         * Fires when the window is resized and provides resize event buffering (50 milliseconds), passes new viewport width and height to handlers.
 
330
         * @param {Function} fn        The method the event invokes
 
331
         * @param {Object}   scope    An object that becomes the scope of the handler
 
332
         * @param {boolean}  options
 
333
         */
 
334
        onWindowResize : function(fn, scope, options){
 
335
            if(!resizeEvent){
 
336
                resizeEvent = new Ext.util.Event();
 
337
                resizeTask = new Ext.util.DelayedTask(function(){
 
338
                    resizeEvent.fire(D.getViewWidth(), D.getViewHeight());
 
339
                });
 
340
                E.on(window, "resize", this.fireWindowResize, this);
 
341
            }
 
342
            resizeEvent.addListener(fn, scope, options);
 
343
        },
 
344
 
 
345
        // exposed only to allow manual firing
 
346
        fireWindowResize : function(){
 
347
            if(resizeEvent){
 
348
                if((Ext.isIE||Ext.isAir) && resizeTask){
 
349
                    resizeTask.delay(50);
 
350
                }else{
 
351
                    resizeEvent.fire(D.getViewWidth(), D.getViewHeight());
 
352
                }
 
353
            }
 
354
        },
 
355
 
 
356
        /**
 
357
         * Fires when the user changes the active text size. Handler gets called with 2 params, the old size and the new size.
 
358
         * @param {Function} fn        The method the event invokes
 
359
         * @param {Object}   scope    An object that becomes the scope of the handler
 
360
         * @param {boolean}  options
 
361
         */
 
362
        onTextResize : function(fn, scope, options){
 
363
            if(!textEvent){
 
364
                textEvent = new Ext.util.Event();
 
365
                var textEl = new Ext.Element(document.createElement('div'));
 
366
                textEl.dom.className = 'x-text-resize';
 
367
                textEl.dom.innerHTML = 'X';
 
368
                textEl.appendTo(document.body);
 
369
                textSize = textEl.dom.offsetHeight;
 
370
                setInterval(function(){
 
371
                    if(textEl.dom.offsetHeight != textSize){
 
372
                        textEvent.fire(textSize, textSize = textEl.dom.offsetHeight);
 
373
                    }
 
374
                }, this.textResizeInterval);
 
375
            }
 
376
            textEvent.addListener(fn, scope, options);
 
377
        },
 
378
 
 
379
        /**
 
380
         * Removes the passed window resize listener.
 
381
         * @param {Function} fn        The method the event invokes
 
382
         * @param {Object}   scope    The scope of handler
 
383
         */
 
384
        removeResizeListener : function(fn, scope){
 
385
            if(resizeEvent){
 
386
                resizeEvent.removeListener(fn, scope);
 
387
            }
 
388
        },
 
389
 
 
390
        // private
 
391
        fireResize : function(){
 
392
            if(resizeEvent){
 
393
                resizeEvent.fire(D.getViewWidth(), D.getViewHeight());
 
394
            }
 
395
        },
 
396
        /**
 
397
         * Url used for onDocumentReady with using SSL (defaults to Ext.SSL_SECURE_URL)
 
398
         */
 
399
        ieDeferSrc : false,
 
400
        /**
 
401
         * The frequency, in milliseconds, to check for text resize events (defaults to 50)
 
402
         */
 
403
        textResizeInterval : 50
 
404
    };
 
405
     /**
 
406
     * Appends an event handler to an element.  Shorthand for {@link #addListener}.
 
407
     * @param {String/HTMLElement} el The html element or id to assign the event handler to
 
408
     * @param {String} eventName The type of event to listen for
 
409
     * @param {Function} handler The handler function the event invokes
 
410
     * @param {Object} scope (optional) The scope in which to execute the handler
 
411
     * function (the handler function's "this" context)
 
412
     * @param {Object} options (optional) An object containing standard {@link #addListener} options
 
413
     * @member Ext.EventManager
 
414
     * @method on
 
415
     */
 
416
    pub.on = pub.addListener;
 
417
    /**
 
418
     * Removes an event handler from an element.  Shorthand for {@link #removeListener}.
 
419
     * @param {String/HTMLElement} el The id or html element from which to remove the event
 
420
     * @param {String} eventName The type of event
 
421
     * @param {Function} fn The handler function to remove
 
422
     * @return {Boolean} True if a listener was actually removed, else false
 
423
     * @member Ext.EventManager
 
424
     * @method un
 
425
     */
 
426
    pub.un = pub.removeListener;
 
427
 
 
428
    pub.stoppedMouseDownEvent = new Ext.util.Event();
 
429
    return pub;
 
430
}();
 
431
/**
 
432
  * Fires when the document is ready (before onload and before images are loaded).  Shorthand of {@link Ext.EventManager#onDocumentReady}.
 
433
  * @param {Function} fn        The method the event invokes
 
434
  * @param {Object}   scope    An  object that becomes the scope of the handler
 
435
  * @param {boolean}  override If true, the obj passed in becomes
 
436
  *                             the execution scope of the listener
 
437
  * @member Ext
 
438
  * @method onReady
 
439
 */
 
440
Ext.onReady = Ext.EventManager.onDocumentReady;
 
441
 
 
442
 
 
443
// Initialize doc classes
 
444
(function(){
 
445
    var initExtCss = function(){
 
446
        // find the body element
 
447
        var bd = document.body || document.getElementsByTagName('body')[0];
 
448
        if(!bd){ return false; }
 
449
        var cls = [' ',
 
450
                Ext.isIE ? "ext-ie " + (Ext.isIE6 ? 'ext-ie6' : 'ext-ie7')
 
451
                : Ext.isGecko ? "ext-gecko " + (Ext.isGecko2 ? 'ext-gecko2' : 'ext-gecko3')
 
452
                : Ext.isOpera ? "ext-opera"
 
453
                : Ext.isSafari ? "ext-safari" : ""];
 
454
 
 
455
        if(Ext.isMac){
 
456
            cls.push("ext-mac");
 
457
        }
 
458
        if(Ext.isLinux){
 
459
            cls.push("ext-linux");
 
460
        }
 
461
        if(Ext.isBorderBox){
 
462
            cls.push('ext-border-box');
 
463
        }
 
464
        if(Ext.isStrict){ // add to the parent to allow for selectors like ".ext-strict .ext-ie"
 
465
            var p = bd.parentNode;
 
466
            if(p){
 
467
                p.className += ' ext-strict';
 
468
            }
 
469
        }
 
470
        bd.className += cls.join(' ');
 
471
        return true;
 
472
    }
 
473
 
 
474
    if(!initExtCss()){
 
475
        Ext.onReady(initExtCss);
 
476
    }
 
477
})();
 
478
 
 
479
/**
 
480
 * @class Ext.EventObject
 
481
 * EventObject exposes the Yahoo! UI Event functionality directly on the object
 
482
 * passed to your event handler. It exists mostly for convenience. It also fixes the annoying null checks automatically to cleanup your code
 
483
 * Example:
 
484
 * <pre><code>
 
485
 function handleClick(e){ // e is not a standard event object, it is a Ext.EventObject
 
486
    e.preventDefault();
 
487
    var target = e.getTarget();
 
488
    ...
 
489
 }
 
490
 var myDiv = Ext.get("myDiv");
 
491
 myDiv.on("click", handleClick);
 
492
 //or
 
493
 Ext.EventManager.on("myDiv", 'click', handleClick);
 
494
 Ext.EventManager.addListener("myDiv", 'click', handleClick);
 
495
 </code></pre>
 
496
 * @singleton
 
497
 */
 
498
Ext.EventObject = function(){
 
499
 
 
500
    var E = Ext.lib.Event;
 
501
 
 
502
    // safari keypress events for special keys return bad keycodes
 
503
    var safariKeys = {
 
504
        3 : 13, // enter
 
505
        63234 : 37, // left
 
506
        63235 : 39, // right
 
507
        63232 : 38, // up
 
508
        63233 : 40, // down
 
509
        63276 : 33, // page up
 
510
        63277 : 34, // page down
 
511
        63272 : 46, // delete
 
512
        63273 : 36, // home
 
513
        63275 : 35  // end
 
514
    };
 
515
 
 
516
    // normalize button clicks
 
517
    var btnMap = Ext.isIE ? {1:0,4:1,2:2} :
 
518
                (Ext.isSafari ? {1:0,2:1,3:2} : {0:0,1:1,2:2});
 
519
 
 
520
    Ext.EventObjectImpl = function(e){
 
521
        if(e){
 
522
            this.setEvent(e.browserEvent || e);
 
523
        }
 
524
    };
 
525
 
 
526
    Ext.EventObjectImpl.prototype = {
 
527
        /** The normal browser event */
 
528
        browserEvent : null,
 
529
        /** The button pressed in a mouse event */
 
530
        button : -1,
 
531
        /** True if the shift key was down during the event */
 
532
        shiftKey : false,
 
533
        /** True if the control key was down during the event */
 
534
        ctrlKey : false,
 
535
        /** True if the alt key was down during the event */
 
536
        altKey : false,
 
537
 
 
538
        /** Key constant @type Number */
 
539
        BACKSPACE: 8,
 
540
        /** Key constant @type Number */
 
541
        TAB: 9,
 
542
        /** Key constant @type Number */
 
543
        NUM_CENTER: 12,
 
544
        /** Key constant @type Number */
 
545
        ENTER: 13,
 
546
        /** Key constant @type Number */
 
547
        RETURN: 13,
 
548
        /** Key constant @type Number */
 
549
        SHIFT: 16,
 
550
        /** Key constant @type Number */
 
551
        CTRL: 17,
 
552
        CONTROL : 17, // legacy
 
553
        /** Key constant @type Number */
 
554
        ALT: 18,
 
555
        /** Key constant @type Number */
 
556
        PAUSE: 19,
 
557
        /** Key constant @type Number */
 
558
        CAPS_LOCK: 20,
 
559
        /** Key constant @type Number */
 
560
        ESC: 27,
 
561
        /** Key constant @type Number */
 
562
        SPACE: 32,
 
563
        /** Key constant @type Number */
 
564
        PAGE_UP: 33,
 
565
        PAGEUP : 33, // legacy
 
566
        /** Key constant @type Number */
 
567
        PAGE_DOWN: 34,
 
568
        PAGEDOWN : 34, // legacy
 
569
        /** Key constant @type Number */
 
570
        END: 35,
 
571
        /** Key constant @type Number */
 
572
        HOME: 36,
 
573
        /** Key constant @type Number */
 
574
        LEFT: 37,
 
575
        /** Key constant @type Number */
 
576
        UP: 38,
 
577
        /** Key constant @type Number */
 
578
        RIGHT: 39,
 
579
        /** Key constant @type Number */
 
580
        DOWN: 40,
 
581
        /** Key constant @type Number */
 
582
        PRINT_SCREEN: 44,
 
583
        /** Key constant @type Number */
 
584
        INSERT: 45,
 
585
        /** Key constant @type Number */
 
586
        DELETE: 46,
 
587
        /** Key constant @type Number */
 
588
        ZERO: 48,
 
589
        /** Key constant @type Number */
 
590
        ONE: 49,
 
591
        /** Key constant @type Number */
 
592
        TWO: 50,
 
593
        /** Key constant @type Number */
 
594
        THREE: 51,
 
595
        /** Key constant @type Number */
 
596
        FOUR: 52,
 
597
        /** Key constant @type Number */
 
598
        FIVE: 53,
 
599
        /** Key constant @type Number */
 
600
        SIX: 54,
 
601
        /** Key constant @type Number */
 
602
        SEVEN: 55,
 
603
        /** Key constant @type Number */
 
604
        EIGHT: 56,
 
605
        /** Key constant @type Number */
 
606
        NINE: 57,
 
607
        /** Key constant @type Number */
 
608
        A: 65,
 
609
        /** Key constant @type Number */
 
610
        B: 66,
 
611
        /** Key constant @type Number */
 
612
        C: 67,
 
613
        /** Key constant @type Number */
 
614
        D: 68,
 
615
        /** Key constant @type Number */
 
616
        E: 69,
 
617
        /** Key constant @type Number */
 
618
        F: 70,
 
619
        /** Key constant @type Number */
 
620
        G: 71,
 
621
        /** Key constant @type Number */
 
622
        H: 72,
 
623
        /** Key constant @type Number */
 
624
        I: 73,
 
625
        /** Key constant @type Number */
 
626
        J: 74,
 
627
        /** Key constant @type Number */
 
628
        K: 75,
 
629
        /** Key constant @type Number */
 
630
        L: 76,
 
631
        /** Key constant @type Number */
 
632
        M: 77,
 
633
        /** Key constant @type Number */
 
634
        N: 78,
 
635
        /** Key constant @type Number */
 
636
        O: 79,
 
637
        /** Key constant @type Number */
 
638
        P: 80,
 
639
        /** Key constant @type Number */
 
640
        Q: 81,
 
641
        /** Key constant @type Number */
 
642
        R: 82,
 
643
        /** Key constant @type Number */
 
644
        S: 83,
 
645
        /** Key constant @type Number */
 
646
        T: 84,
 
647
        /** Key constant @type Number */
 
648
        U: 85,
 
649
        /** Key constant @type Number */
 
650
        V: 86,
 
651
        /** Key constant @type Number */
 
652
        W: 87,
 
653
        /** Key constant @type Number */
 
654
        X: 88,
 
655
        /** Key constant @type Number */
 
656
        Y: 89,
 
657
        /** Key constant @type Number */
 
658
        Z: 90,
 
659
        /** Key constant @type Number */
 
660
        CONTEXT_MENU: 93,
 
661
        /** Key constant @type Number */
 
662
        NUM_ZERO: 96,
 
663
        /** Key constant @type Number */
 
664
        NUM_ONE: 97,
 
665
        /** Key constant @type Number */
 
666
        NUM_TWO: 98,
 
667
        /** Key constant @type Number */
 
668
        NUM_THREE: 99,
 
669
        /** Key constant @type Number */
 
670
        NUM_FOUR: 100,
 
671
        /** Key constant @type Number */
 
672
        NUM_FIVE: 101,
 
673
        /** Key constant @type Number */
 
674
        NUM_SIX: 102,
 
675
        /** Key constant @type Number */
 
676
        NUM_SEVEN: 103,
 
677
        /** Key constant @type Number */
 
678
        NUM_EIGHT: 104,
 
679
        /** Key constant @type Number */
 
680
        NUM_NINE: 105,
 
681
        /** Key constant @type Number */
 
682
        NUM_MULTIPLY: 106,
 
683
        /** Key constant @type Number */
 
684
        NUM_PLUS: 107,
 
685
        /** Key constant @type Number */
 
686
        NUM_MINUS: 109,
 
687
        /** Key constant @type Number */
 
688
        NUM_PERIOD: 110,
 
689
        /** Key constant @type Number */
 
690
        NUM_DIVISION: 111,
 
691
        /** Key constant @type Number */
 
692
        F1: 112,
 
693
        /** Key constant @type Number */
 
694
        F2: 113,
 
695
        /** Key constant @type Number */
 
696
        F3: 114,
 
697
        /** Key constant @type Number */
 
698
        F4: 115,
 
699
        /** Key constant @type Number */
 
700
        F5: 116,
 
701
        /** Key constant @type Number */
 
702
        F6: 117,
 
703
        /** Key constant @type Number */
 
704
        F7: 118,
 
705
        /** Key constant @type Number */
 
706
        F8: 119,
 
707
        /** Key constant @type Number */
 
708
        F9: 120,
 
709
        /** Key constant @type Number */
 
710
        F10: 121,
 
711
        /** Key constant @type Number */
 
712
        F11: 122,
 
713
        /** Key constant @type Number */
 
714
        F12: 123,
 
715
 
 
716
           /** @private */
 
717
        setEvent : function(e){
 
718
            if(e == this || (e && e.browserEvent)){ // already wrapped
 
719
                return e;
 
720
            }
 
721
            this.browserEvent = e;
 
722
            if(e){
 
723
                // normalize buttons
 
724
                this.button = e.button ? btnMap[e.button] : (e.which ? e.which-1 : -1);
 
725
                if(e.type == 'click' && this.button == -1){
 
726
                    this.button = 0;
 
727
                }
 
728
                this.type = e.type;
 
729
                this.shiftKey = e.shiftKey;
 
730
                // mac metaKey behaves like ctrlKey
 
731
                this.ctrlKey = e.ctrlKey || e.metaKey;
 
732
                this.altKey = e.altKey;
 
733
                // in getKey these will be normalized for the mac
 
734
                this.keyCode = e.keyCode;
 
735
                this.charCode = e.charCode;
 
736
                // cache the target for the delayed and or buffered events
 
737
                this.target = E.getTarget(e);
 
738
                // same for XY
 
739
                this.xy = E.getXY(e);
 
740
            }else{
 
741
                this.button = -1;
 
742
                this.shiftKey = false;
 
743
                this.ctrlKey = false;
 
744
                this.altKey = false;
 
745
                this.keyCode = 0;
 
746
                this.charCode = 0;
 
747
                this.target = null;
 
748
                this.xy = [0, 0];
 
749
            }
 
750
            return this;
 
751
        },
 
752
 
 
753
        /**
 
754
         * Stop the event (preventDefault and stopPropagation)
 
755
         */
 
756
        stopEvent : function(){
 
757
            if(this.browserEvent){
 
758
                if(this.browserEvent.type == 'mousedown'){
 
759
                    Ext.EventManager.stoppedMouseDownEvent.fire(this);
 
760
                }
 
761
                E.stopEvent(this.browserEvent);
 
762
            }
 
763
        },
 
764
 
 
765
        /**
 
766
         * Prevents the browsers default handling of the event.
 
767
         */
 
768
        preventDefault : function(){
 
769
            if(this.browserEvent){
 
770
                E.preventDefault(this.browserEvent);
 
771
            }
 
772
        },
 
773
 
 
774
        /** @private */
 
775
        isNavKeyPress : function(){
 
776
            var k = this.keyCode;
 
777
            k = Ext.isSafari ? (safariKeys[k] || k) : k;
 
778
            return (k >= 33 && k <= 40) || k == this.RETURN || k == this.TAB || k == this.ESC;
 
779
        },
 
780
 
 
781
        isSpecialKey : function(){
 
782
            var k = this.keyCode;
 
783
            return (this.type == 'keypress' && this.ctrlKey) || k == 9 || k == 13  || k == 40 || k == 27 ||
 
784
            (k == 16) || (k == 17) ||
 
785
            (k >= 18 && k <= 20) ||
 
786
            (k >= 33 && k <= 35) ||
 
787
            (k >= 36 && k <= 39) ||
 
788
            (k >= 44 && k <= 45);
 
789
        },
 
790
 
 
791
        /**
 
792
         * Cancels bubbling of the event.
 
793
         */
 
794
        stopPropagation : function(){
 
795
            if(this.browserEvent){
 
796
                if(this.browserEvent.type == 'mousedown'){
 
797
                    Ext.EventManager.stoppedMouseDownEvent.fire(this);
 
798
                }
 
799
                E.stopPropagation(this.browserEvent);
 
800
            }
 
801
        },
 
802
 
 
803
        /**
 
804
         * Gets the character code for the event.
 
805
         * @return {Number}
 
806
         */
 
807
        getCharCode : function(){
 
808
            return this.charCode || this.keyCode;
 
809
        },
 
810
 
 
811
        /**
 
812
         * Returns a normalized keyCode for the event.
 
813
         * @return {Number} The key code
 
814
         */
 
815
        getKey : function(){
 
816
            var k = this.keyCode || this.charCode;
 
817
            return Ext.isSafari ? (safariKeys[k] || k) : k;
 
818
        },
 
819
 
 
820
        /**
 
821
         * Gets the x coordinate of the event.
 
822
         * @return {Number}
 
823
         */
 
824
        getPageX : function(){
 
825
            return this.xy[0];
 
826
        },
 
827
 
 
828
        /**
 
829
         * Gets the y coordinate of the event.
 
830
         * @return {Number}
 
831
         */
 
832
        getPageY : function(){
 
833
            return this.xy[1];
 
834
        },
 
835
 
 
836
        /**
 
837
         * Gets the time of the event.
 
838
         * @return {Number}
 
839
         */
 
840
        getTime : function(){
 
841
            if(this.browserEvent){
 
842
                return E.getTime(this.browserEvent);
 
843
            }
 
844
            return null;
 
845
        },
 
846
 
 
847
        /**
 
848
         * Gets the page coordinates of the event.
 
849
         * @return {Array} The xy values like [x, y]
 
850
         */
 
851
        getXY : function(){
 
852
            return this.xy;
 
853
        },
 
854
 
 
855
        /**
 
856
         * Gets the target for the event.
 
857
         * @param {String} selector (optional) A simple selector to filter the target or look for an ancestor of the target
 
858
         * @param {Number/Mixed} maxDepth (optional) The max depth to
 
859
                search as a number or element (defaults to 10 || document.body)
 
860
         * @param {Boolean} returnEl (optional) True to return a Ext.Element object instead of DOM node
 
861
         * @return {HTMLelement}
 
862
         */
 
863
        getTarget : function(selector, maxDepth, returnEl){
 
864
            return selector ? Ext.fly(this.target).findParent(selector, maxDepth, returnEl) : (returnEl ? Ext.get(this.target) : this.target);
 
865
        },
 
866
 
 
867
        /**
 
868
         * Gets the related target.
 
869
         * @return {HTMLElement}
 
870
         */
 
871
        getRelatedTarget : function(){
 
872
            if(this.browserEvent){
 
873
                return E.getRelatedTarget(this.browserEvent);
 
874
            }
 
875
            return null;
 
876
        },
 
877
 
 
878
        /**
 
879
         * Normalizes mouse wheel delta across browsers
 
880
         * @return {Number} The delta
 
881
         */
 
882
        getWheelDelta : function(){
 
883
            var e = this.browserEvent;
 
884
            var delta = 0;
 
885
            if(e.wheelDelta){ /* IE/Opera. */
 
886
                delta = e.wheelDelta/120;
 
887
            }else if(e.detail){ /* Mozilla case. */
 
888
                delta = -e.detail/3;
 
889
            }
 
890
            return delta;
 
891
        },
 
892
 
 
893
        /**
 
894
         * Returns true if the control, meta, shift or alt key was pressed during this event.
 
895
         * @return {Boolean}
 
896
         */
 
897
        hasModifier : function(){
 
898
            return ((this.ctrlKey || this.altKey) || this.shiftKey) ? true : false;
 
899
        },
 
900
 
 
901
        /**
 
902
         * Returns true if the target of this event is a child of el.  If the target is el, it returns false.
 
903
         * Example usage:<pre><code>
 
904
// Handle click on any child of an element
 
905
Ext.getBody().on('click', function(e){
 
906
    if(e.within('some-el')){
 
907
        alert('Clicked on a child of some-el!');
 
908
    }
 
909
});
 
910
 
 
911
// Handle click directly on an element, ignoring clicks on child nodes
 
912
Ext.getBody().on('click', function(e,t){
 
913
    if((t.id == 'some-el') && !e.within(t, true)){
 
914
        alert('Clicked directly on some-el!');
 
915
    }
 
916
});
 
917
</code></pre>
 
918
         * @param {Mixed} el The id, DOM element or Ext.Element to check
 
919
         * @param {Boolean} related (optional) true to test if the related target is within el instead of the target
 
920
         * @return {Boolean}
 
921
         */
 
922
        within : function(el, related){
 
923
            var t = this[related ? "getRelatedTarget" : "getTarget"]();
 
924
            return t && Ext.fly(el).contains(t);
 
925
        },
 
926
 
 
927
        getPoint : function(){
 
928
            return new Ext.lib.Point(this.xy[0], this.xy[1]);
 
929
        }
 
930
    };
 
931
 
 
932
    return new Ext.EventObjectImpl();
 
933
}();
 
 
b'\\ No newline at end of file'