1 <!DOCTYPE html><html><head><title>Sencha Documentation Project</title><link rel="stylesheet" href="../reset.css" type="text/css"><link rel="stylesheet" href="../prettify.css" type="text/css"><link rel="stylesheet" href="../prettify_sa.css" type="text/css"><script type="text/javascript" src="../prettify.js"></script></head><body onload="prettyPrint()"><pre class="prettyprint"><pre><span id='Ext-EventManager'>/**
2 </span> * @class Ext.EventManager
3 * Registers event handlers that want to receive a normalized EventObject instead of the standard browser event and provides
4 * several useful events directly.
5 * See {@link Ext.EventObject} for more details on normalized event objects.
10 // --------------------- onReady ---------------------
12 <span id='Ext-EventManager-property-hasBoundOnReady'> /**
13 </span> * Check if we have bound our global onReady listener
16 hasBoundOnReady: false,
18 <span id='Ext-EventManager-property-hasFiredReady'> /**
19 </span> * Check if fireDocReady has been called
24 <span id='Ext-EventManager-property-readyTimeout'> /**
25 </span> * Timer for the document ready event in old IE versions
30 <span id='Ext-EventManager-property-hasOnReadyStateChange'> /**
31 </span> * Checks if we have bound an onreadystatechange event
34 hasOnReadyStateChange: false,
36 <span id='Ext-EventManager-property-readyEvent'> /**
37 </span> * Holds references to any onReady functions
40 readyEvent: new Ext.util.Event(),
42 <span id='Ext-EventManager-method-checkReadyState'> /**
43 </span> * Check the ready state for old IE versions
45 * @return {Boolean} True if the document is ready
47 checkReadyState: function(){
48 var me = Ext.EventManager;
50 if(window.attachEvent){
51 // See here for reference: http://javascript.nwbox.com/IEContentLoaded/
56 document.documentElement.doScroll('left');
63 if (document.readyState == 'complete') {
67 me.readyTimeout = setTimeout(arguments.callee, 2);
71 <span id='Ext-EventManager-method-bindReadyEvent'> /**
72 </span> * Binds the appropriate browser event for checking if the DOM has loaded.
75 bindReadyEvent: function(){
76 var me = Ext.EventManager;
77 if (me.hasBoundOnReady) {
81 if (document.addEventListener) {
82 document.addEventListener('DOMContentLoaded', me.fireDocReady, false);
83 // fallback, load will ~always~ fire
84 window.addEventListener('load', me.fireDocReady, false);
86 // check if the document is ready, this will also kick off the scroll checking timer
87 if (!me.checkReadyState()) {
88 document.attachEvent('onreadystatechange', me.checkReadyState);
89 me.hasOnReadyStateChange = true;
91 // fallback, onload will ~always~ fire
92 window.attachEvent('onload', me.fireDocReady, false);
94 me.hasBoundOnReady = true;
97 <span id='Ext-EventManager-method-fireDocReady'> /**
98 </span> * We know the document is loaded, so trigger any onReady events.
101 fireDocReady: function(){
102 var me = Ext.EventManager;
104 // only unbind these events once
105 if (!me.hasFiredReady) {
106 me.hasFiredReady = true;
108 if (document.addEventListener) {
109 document.removeEventListener('DOMContentLoaded', me.fireDocReady, false);
110 window.removeEventListener('load', me.fireDocReady, false);
112 if (me.readyTimeout !== null) {
113 clearTimeout(me.readyTimeout);
115 if (me.hasOnReadyStateChange) {
116 document.detachEvent('onreadystatechange', me.checkReadyState);
118 window.detachEvent('onload', me.fireDocReady);
125 me.readyEvent.fire();
129 <span id='Ext-EventManager-method-onDocumentReady'> /**
130 </span> * Adds a listener to be notified when the document is ready (before onload and before images are loaded). Can be
131 * accessed shorthanded as Ext.onReady().
132 * @param {Function} fn The method the event invokes.
133 * @param {Object} scope (optional) The scope (<code>this</code> reference) in which the handler function executes. Defaults to the browser window.
134 * @param {boolean} options (optional) Options object as passed to {@link Ext.core.Element#addListener}.
136 onDocumentReady: function(fn, scope, options){
137 options = options || {};
138 var me = Ext.EventManager,
139 readyEvent = me.readyEvent;
141 // force single to be true so our event is only ever fired once.
142 options.single = true;
144 // Document already loaded, let's just fire it
146 readyEvent.addListener(fn, scope, options);
149 options.delay = options.delay || 1;
150 readyEvent.addListener(fn, scope, options);
156 // --------------------- event binding ---------------------
158 <span id='Ext-EventManager-property-stoppedMouseDownEvent'> /**
159 </span> * Contains a list of all document mouse downs, so we can ensure they fire even when stopEvent is called.
162 stoppedMouseDownEvent: new Ext.util.Event(),
164 <span id='Ext-EventManager-property-propRe'> /**
165 </span> * Options to parse for the 4th argument to addListener.
168 propRe: /^(?:scope|delay|buffer|single|stopEvent|preventDefault|stopPropagation|normalized|args|delegate|freezeEvent)$/,
170 <span id='Ext-EventManager-method-getId'> /**
171 </span> * Get the id of the element. If one has not been assigned, automatically assign it.
172 * @param {Mixed} element The element to get the id for.
173 * @return {String} id
175 getId : function(element) {
176 var skipGarbageCollection = false,
179 element = Ext.getDom(element);
181 if (element === document || element === window) {
182 id = element === document ? Ext.documentId : Ext.windowId;
185 id = Ext.id(element);
187 // skip garbage collection for special elements (window, document, iframes)
188 if (element && (element.getElementById || element.navigator)) {
189 skipGarbageCollection = true;
193 Ext.core.Element.addToCache(new Ext.core.Element(element), id);
194 if (skipGarbageCollection) {
195 Ext.cache[id].skipGarbageCollection = true;
201 <span id='Ext-EventManager-method-prepareListenerConfig'> /**
202 </span> * Convert a "config style" listener into a set of flat arguments so they can be passed to addListener
204 * @param {Object} element The element the event is for
205 * @param {Object} event The event configuration
206 * @param {Object} isRemove True if a removal should be performed, otherwise an add will be done.
208 prepareListenerConfig: function(element, config, isRemove){
213 // loop over all the keys in the object
214 for (key in config) {
215 if (config.hasOwnProperty(key)) {
216 // if the key is something else then an event option
217 if (!propRe.test(key)) {
219 // if the value is a function it must be something like click: function(){}, scope: this
220 // which means that there might be multiple event listeners with shared options
221 if (Ext.isFunction(value)) {
223 args = [element, key, value, config.scope, config];
225 // if its not a function, it must be an object like click: {fn: function(){}, scope: this}
226 args = [element, key, value.fn, value.scope, value];
229 if (isRemove === true) {
230 me.removeListener.apply(this, args);
232 me.addListener.apply(me, args);
239 <span id='Ext-EventManager-method-normalizeEvent'> /**
240 </span> * Normalize cross browser event differences
242 * @param {Object} eventName The event name
243 * @param {Object} fn The function to execute
244 * @return {Object} The new event name/function
246 normalizeEvent: function(eventName, fn){
247 if (/mouseenter|mouseleave/.test(eventName) && !Ext.supports.MouseEnterLeave) {
249 fn = Ext.Function.createInterceptor(fn, this.contains, this);
251 eventName = eventName == 'mouseenter' ? 'mouseover' : 'mouseout';
252 } else if (eventName == 'mousewheel' && !Ext.supports.MouseWheel && !Ext.isOpera){
253 eventName = 'DOMMouseScroll';
256 eventName: eventName,
261 <span id='Ext-EventManager-method-contains'> /**
262 </span> * Checks whether the event's relatedTarget is contained inside (or <b>is</b>) the element.
264 * @param {Object} event
266 contains: function(event){
267 var parent = event.browserEvent.currentTarget,
268 child = this.getRelatedTarget(event);
270 if (parent && parent.firstChild) {
272 if (child === parent) {
275 child = child.parentNode;
276 if (child && (child.nodeType != 1)) {
284 <span id='Ext-EventManager-method-addListener'> /**
285 </span> * Appends an event handler to an element. The shorthand version {@link #on} is equivalent. Typically you will
286 * use {@link Ext.core.Element#addListener} directly on an Element in favor of calling this version.
287 * @param {String/HTMLElement} el The html element or id to assign the event handler to.
288 * @param {String} eventName The name of the event to listen for.
289 * @param {Function} handler The handler function the event invokes. This function is passed
290 * the following parameters:<ul>
291 * <li>evt : EventObject<div class="sub-desc">The {@link Ext.EventObject EventObject} describing the event.</div></li>
292 * <li>t : Element<div class="sub-desc">The {@link Ext.core.Element Element} which was the target of the event.
293 * Note that this may be filtered by using the <tt>delegate</tt> option.</div></li>
294 * <li>o : Object<div class="sub-desc">The options object from the addListener call.</div></li>
296 * @param {Object} scope (optional) The scope (<b><code>this</code></b> reference) in which the handler function is executed. <b>Defaults to the Element</b>.
297 * @param {Object} options (optional) An object containing handler configuration properties.
298 * This may contain any of the following properties:<ul>
299 * <li>scope : Object<div class="sub-desc">The scope (<b><code>this</code></b> reference) in which the handler function is executed. <b>Defaults to the Element</b>.</div></li>
300 * <li>delegate : String<div class="sub-desc">A simple selector to filter the target or look for a descendant of the target</div></li>
301 * <li>stopEvent : Boolean<div class="sub-desc">True to stop the event. That is stop propagation, and prevent the default action.</div></li>
302 * <li>preventDefault : Boolean<div class="sub-desc">True to prevent the default action</div></li>
303 * <li>stopPropagation : Boolean<div class="sub-desc">True to prevent event propagation</div></li>
304 * <li>normalized : Boolean<div class="sub-desc">False to pass a browser event to the handler function instead of an Ext.EventObject</div></li>
305 * <li>delay : Number<div class="sub-desc">The number of milliseconds to delay the invocation of the handler after te event fires.</div></li>
306 * <li>single : Boolean<div class="sub-desc">True to add a handler to handle just the next firing of the event, and then remove itself.</div></li>
307 * <li>buffer : Number<div class="sub-desc">Causes the handler to be scheduled to run in an {@link Ext.util.DelayedTask} delayed
308 * by the specified number of milliseconds. If the event fires again within that time, the original
309 * handler is <em>not</em> invoked, but the new handler is scheduled in its place.</div></li>
310 * <li>target : Element<div class="sub-desc">Only call the handler if the event was fired on the target Element, <i>not</i> if the event was bubbled up from a child node.</div></li>
311 * </ul><br>
312 * <p>See {@link Ext.core.Element#addListener} for examples of how to use these options.</p>
314 addListener: function(element, eventName, fn, scope, options){
315 // Check if we've been passed a "config style" event.
316 if (Ext.isObject(eventName)) {
317 this.prepareListenerConfig(element, eventName);
321 var dom = Ext.getDom(element),
328 sourceClass: 'Ext.EventManager',
329 sourceMethod: 'addListener',
330 targetElement: element,
331 eventName: eventName,
332 msg: 'Error adding "' + eventName + '\" listener for nonexistent element "' + element + '"'
337 sourceClass: 'Ext.EventManager',
338 sourceMethod: 'addListener',
339 targetElement: element,
340 eventName: eventName,
341 msg: 'Error adding "' + eventName + '\" listener. The handler function is undefined.'
346 // create the wrapper function
347 options = options || {};
349 bind = this.normalizeEvent(eventName, fn);
350 wrap = this.createListenerWrap(dom, eventName, bind.fn, scope, options);
353 if (dom.attachEvent) {
354 dom.attachEvent('on' + bind.eventName, wrap);
356 dom.addEventListener(bind.eventName, wrap, options.capture || false);
359 if (dom == document && eventName == 'mousedown') {
360 this.stoppedMouseDownEvent.addListener(wrap);
363 // add all required data into the event cache
364 this.getEventListenerCache(dom, eventName).push({
371 <span id='Ext-EventManager-method-removeListener'> /**
372 </span> * Removes an event handler from an element. The shorthand version {@link #un} is equivalent. Typically
373 * you will use {@link Ext.core.Element#removeListener} directly on an Element in favor of calling this version.
374 * @param {String/HTMLElement} el The id or html element from which to remove the listener.
375 * @param {String} eventName The name of the event.
376 * @param {Function} fn The handler function to remove. <b>This must be a reference to the function passed into the {@link #addListener} call.</b>
377 * @param {Object} scope If a scope (<b><code>this</code></b> reference) was specified when the listener was added,
378 * then this must refer to the same object.
380 removeListener : function(element, eventName, fn, scope) {
381 // handle our listener config object syntax
382 if (Ext.isObject(eventName)) {
383 this.prepareListenerConfig(element, eventName, true);
387 var dom = Ext.getDom(element),
388 cache = this.getEventListenerCache(dom, eventName),
389 bindName = this.normalizeEvent(eventName).eventName,
391 listener, wrap, tasks;
397 if (listener && (!fn || listener.fn == fn) && (!scope || listener.scope === scope)) {
398 wrap = listener.wrap;
400 // clear buffered calls
402 clearTimeout(wrap.task);
406 // clear delayed calls
407 j = wrap.tasks && wrap.tasks.length;
410 clearTimeout(wrap.tasks[j]);
415 if (dom.detachEvent) {
416 dom.detachEvent('on' + bindName, wrap);
418 dom.removeEventListener(bindName, wrap, false);
421 if (wrap && dom == document && eventName == 'mousedown') {
422 this.stoppedMouseDownEvent.removeListener(wrap);
425 // remove listener from cache
431 <span id='Ext-EventManager-method-removeAll'> /**
432 </span> * Removes all event handers from an element. Typically you will use {@link Ext.core.Element#removeAllListeners}
433 * directly on an Element in favor of calling this version.
434 * @param {String/HTMLElement} el The id or html element from which to remove all event handlers.
436 removeAll : function(element){
437 var dom = Ext.getDom(element),
442 cache = this.getElementEventCache(dom);
445 if (cache.hasOwnProperty(ev)) {
446 this.removeListener(dom, ev);
449 Ext.cache[dom.id].events = {};
452 <span id='Ext-EventManager-method-purgeElement'> /**
453 </span> * Recursively removes all previous added listeners from an element and its children. Typically you will use {@link Ext.core.Element#purgeAllListeners}
454 * directly on an Element in favor of calling this version.
455 * @param {String/HTMLElement} el The id or html element from which to remove all event handlers.
456 * @param {String} eventName (optional) The name of the event.
458 purgeElement : function(element, eventName) {
459 var dom = Ext.getDom(element),
463 this.removeListener(dom, eventName);
469 if(dom && dom.childNodes) {
470 for(len = element.childNodes.length; i < len; i++) {
471 this.purgeElement(element.childNodes[i], eventName);
476 <span id='Ext-EventManager-method-createListenerWrap'> /**
477 </span> * Create the wrapper function for the event
479 * @param {HTMLElement} dom The dom element
480 * @param {String} ename The event name
481 * @param {Function} fn The function to execute
482 * @param {Object} scope The scope to execute callback in
483 * @param {Object} o The options
485 createListenerWrap : function(dom, ename, fn, scope, options) {
486 options = !Ext.isObject(options) ? {} : options;
488 var f = ['if(!Ext) {return;}'],
491 if(options.buffer || options.delay || options.freezeEvent) {
492 f.push('e = new Ext.EventObjectImpl(e, ' + (options.freezeEvent ? 'true' : 'false' ) + ');');
494 f.push('e = Ext.EventObject.setEvent(e);');
497 if (options.delegate) {
498 f.push('var t = e.getTarget("' + options.delegate + '", this);');
499 f.push('if(!t) {return;}');
501 f.push('var t = e.target;');
504 if (options.target) {
505 f.push('if(e.target !== options.target) {return;}');
508 if(options.stopEvent) {
509 f.push('e.stopEvent();');
511 if(options.preventDefault) {
512 f.push('e.preventDefault();');
514 if(options.stopPropagation) {
515 f.push('e.stopPropagation();');
519 if(options.normalized === false) {
520 f.push('e = e.browserEvent;');
524 f.push('(wrap.task && clearTimeout(wrap.task));');
525 f.push('wrap.task = setTimeout(function(){');
529 f.push('wrap.tasks = wrap.tasks || [];');
530 f.push('wrap.tasks.push(setTimeout(function(){');
533 // finally call the actual handler fn
534 f.push('fn.call(scope || dom, e, t, options);');
537 f.push('Ext.EventManager.removeListener(dom, ename, fn, scope);');
541 f.push('}, ' + options.delay + '));');
545 f.push('}, ' + options.buffer + ');');
548 gen = Ext.functionFactory('e', 'options', 'fn', 'scope', 'ename', 'dom', 'wrap', 'args', f.join('\n'));
550 return function wrap(e, args) {
551 gen.call(dom, e, options, fn, scope, ename, dom, wrap, args);
555 <span id='Ext-EventManager-method-getEventListenerCache'> /**
556 </span> * Get the event cache for a particular element for a particular event
558 * @param {HTMLElement} element The element
559 * @param {Object} eventName The event name
560 * @return {Array} The events for the element
562 getEventListenerCache : function(element, eventName) {
563 var eventCache = this.getElementEventCache(element);
564 return eventCache[eventName] || (eventCache[eventName] = []);
567 <span id='Ext-EventManager-method-getElementEventCache'> /**
568 </span> * Gets the event cache for the object
570 * @param {HTMLElement} element The element
571 * @return {Object} The event cache for the object
573 getElementEventCache : function(element) {
574 var elementCache = Ext.cache[this.getId(element)];
575 return elementCache.events || (elementCache.events = {});
578 // --------------------- utility methods ---------------------
579 mouseLeaveRe: /(mouseout|mouseleave)/,
580 mouseEnterRe: /(mouseover|mouseenter)/,
582 <span id='Ext-EventManager-method-stopEvent'> /**
583 </span> * Stop the event (preventDefault and stopPropagation)
584 * @param {Event} The event to stop
586 stopEvent: function(event) {
587 this.stopPropagation(event);
588 this.preventDefault(event);
591 <span id='Ext-EventManager-method-stopPropagation'> /**
592 </span> * Cancels bubbling of the event.
593 * @param {Event} The event to stop bubbling.
595 stopPropagation: function(event) {
596 event = event.browserEvent || event;
597 if (event.stopPropagation) {
598 event.stopPropagation();
600 event.cancelBubble = true;
604 <span id='Ext-EventManager-method-preventDefault'> /**
605 </span> * Prevents the browsers default handling of the event.
606 * @param {Event} The event to prevent the default
608 preventDefault: function(event) {
609 event = event.browserEvent || event;
610 if (event.preventDefault) {
611 event.preventDefault();
613 event.returnValue = false;
614 // Some keys events require setting the keyCode to -1 to be prevented
616 // all ctrl + X and F1 -> F12
617 if (event.ctrlKey || event.keyCode > 111 && event.keyCode < 124) {
621 // see this outdated document http://support.microsoft.com/kb/934364/en-us for more info
626 <span id='Ext-EventManager-method-getRelatedTarget'> /**
627 </span> * Gets the related target from the event.
628 * @param {Object} event The event
629 * @return {HTMLElement} The related target.
631 getRelatedTarget: function(event) {
632 event = event.browserEvent || event;
633 var target = event.relatedTarget;
635 if (this.mouseLeaveRe.test(event.type)) {
636 target = event.toElement;
637 } else if (this.mouseEnterRe.test(event.type)) {
638 target = event.fromElement;
641 return this.resolveTextNode(target);
644 <span id='Ext-EventManager-method-getPageX'> /**
645 </span> * Gets the x coordinate from the event
646 * @param {Object} event The event
647 * @return {Number} The x coordinate
649 getPageX: function(event) {
650 return this.getXY(event)[0];
653 <span id='Ext-EventManager-method-getPageY'> /**
654 </span> * Gets the y coordinate from the event
655 * @param {Object} event The event
656 * @return {Number} The y coordinate
658 getPageY: function(event) {
659 return this.getXY(event)[1];
662 <span id='Ext-EventManager-method-getPageXY'> /**
663 </span> * Gets the x & ycoordinate from the event
664 * @param {Object} event The event
665 * @return {Array} The x/y coordinate
667 getPageXY: function(event) {
668 event = event.browserEvent || event;
671 doc = document.documentElement,
672 body = document.body;
674 // pageX/pageY not available (undefined, not null), use clientX/clientY instead
675 if (!x && x !== 0) {
676 x = event.clientX + (doc && doc.scrollLeft || body && body.scrollLeft || 0) - (doc && doc.clientLeft || body && body.clientLeft || 0);
677 y = event.clientY + (doc && doc.scrollTop || body && body.scrollTop || 0) - (doc && doc.clientTop || body && body.clientTop || 0);
682 <span id='Ext-EventManager-method-getTarget'> /**
683 </span> * Gets the target of the event.
684 * @param {Object} event The event
685 * @return {HTMLElement} target
687 getTarget: function(event) {
688 event = event.browserEvent || event;
689 return this.resolveTextNode(event.target || event.srcElement);
692 <span id='Ext-EventManager-property-resolveTextNode'> /**
693 </span> * Resolve any text nodes accounting for browser differences.
695 * @param {HTMLElement} node The node
696 * @return {HTMLElement} The resolved node
698 // technically no need to browser sniff this, however it makes no sense to check this every time, for every event, whether the string is equal.
699 resolveTextNode: Ext.isGecko ?
704 // work around firefox bug, https://bugzilla.mozilla.org/show_bug.cgi?id=101197
705 var s = HTMLElement.prototype.toString.call(node);
706 if (s == '[xpconnect wrapped native prototype]' || s == '[object XULElement]') {
709 return node.nodeType == 3 ? node.parentNode: node;
711 return node && node.nodeType == 3 ? node.parentNode: node;
714 // --------------------- custom event binding ---------------------
716 // Keep track of the current width/height
720 <span id='Ext-EventManager-method-onWindowResize'> /**
721 </span> * Adds a listener to be notified when the browser window is resized and provides resize event buffering (100 milliseconds),
722 * passes new viewport width and height to handlers.
723 * @param {Function} fn The handler function the window resize event invokes.
724 * @param {Object} scope The scope (<code>this</code> reference) in which the handler function executes. Defaults to the browser window.
725 * @param {boolean} options Options object as passed to {@link Ext.core.Element#addListener}
727 onWindowResize: function(fn, scope, options){
728 var resize = this.resizeEvent;
730 this.resizeEvent = resize = new Ext.util.Event();
731 this.on(window, 'resize', this.fireResize, this, {buffer: 100});
733 resize.addListener(fn, scope, options);
736 <span id='Ext-EventManager-method-fireResize'> /**
737 </span> * Fire the resize event.
740 fireResize: function(){
742 w = Ext.core.Element.getViewWidth(),
743 h = Ext.core.Element.getViewHeight();
745 //whacky problem in IE where the resize event will sometimes fire even though the w/h are the same.
746 if(me.curHeight != h || me.curWidth != w){
749 me.resizeEvent.fire(w, h);
753 <span id='Ext-EventManager-method-removeResizeListener'> /**
754 </span> * Removes the passed window resize listener.
755 * @param {Function} fn The method the event invokes
756 * @param {Object} scope The scope of handler
758 removeResizeListener: function(fn, scope){
759 if (this.resizeEvent) {
760 this.resizeEvent.removeListener(fn, scope);
764 onWindowUnload: function() {
765 var unload = this.unloadEvent;
767 this.unloadEvent = unload = new Ext.util.Event();
768 this.addListener(window, 'unload', this.fireUnload, this);
772 <span id='Ext-EventManager-method-fireUnload'> /**
773 </span> * Fires the unload event for items bound with onWindowUnload
776 fireUnload: function() {
777 // wrap in a try catch, could have some problems during unload
779 this.removeUnloadListener();
780 // Work around FF3 remembering the last scroll position when refreshing the grid and then losing grid view
782 var gridviews = Ext.ComponentQuery.query('gridview'),
784 ln = gridviews.length;
785 for (; i < ln; i++) {
786 gridviews[i].scrollToTop();
789 // Purge all elements in the cache
793 if (cache.hasOwnProperty(el)) {
794 Ext.EventManager.removeAll(el);
801 <span id='Ext-EventManager-method-removeUnloadListener'> /**
802 </span> * Removes the passed window unload listener.
803 * @param {Function} fn The method the event invokes
804 * @param {Object} scope The scope of handler
806 removeUnloadListener: function(){
807 if (this.unloadEvent) {
808 this.removeListener(window, 'unload', this.fireUnload);
812 <span id='Ext-EventManager-property-useKeyDown'> /**
813 </span> * note 1: IE fires ONLY the keydown event on specialkey autorepeat
814 * note 2: Safari < 3.1, Gecko (Mac/Linux) & Opera fire only the keypress event on specialkey autorepeat
815 * (research done by @Jan Wolter at http://unixpapa.com/js/key.html)
818 useKeyDown: Ext.isWebKit ?
819 parseInt(navigator.userAgent.match(/AppleWebKit\/(\d+)/)[1], 10) >= 525 :
820 !((Ext.isGecko && !Ext.isWindows) || Ext.isOpera),
822 <span id='Ext-EventManager-method-getKeyEvent'> /**
823 </span> * Indicates which event to use for getting key presses.
824 * @return {String} The appropriate event name.
826 getKeyEvent: function(){
827 return this.useKeyDown ? 'keydown' : 'keypress';
831 <span id='Ext-method-onReady'>/**
832 </span> * Alias for {@link Ext.Loader#onReady Ext.Loader.onReady} with withDomReady set to true
836 Ext.onReady = function(fn, scope, options) {
837 Ext.Loader.onReady(fn, scope, true, options);
840 <span id='Ext-method-onDocumentReady'>/**
841 </span> * Alias for {@link Ext.EventManager#onDocumentReady Ext.EventManager.onDocumentReady}
843 * @method onDocumentReady
845 Ext.onDocumentReady = Ext.EventManager.onDocumentReady;
847 <span id='Ext-EventManager-method-on'>/**
848 </span> * Alias for {@link Ext.EventManager#addListener Ext.EventManager.addListener}
849 * @member Ext.EventManager
852 Ext.EventManager.on = Ext.EventManager.addListener;
854 <span id='Ext-EventManager-method-un'>/**
855 </span> * Alias for {@link Ext.EventManager#removeListener Ext.EventManager.removeListener}
856 * @member Ext.EventManager
859 Ext.EventManager.un = Ext.EventManager.removeListener;
862 var initExtCss = function() {
863 // find the body element
864 var bd = document.body || document.getElementsByTagName('body')[0],
865 baseCSSPrefix = Ext.baseCSSPrefix,
874 html = bd.parentNode;
876 //Let's keep this human readable!
878 cls.push(baseCSSPrefix + 'ie');
881 cls.push(baseCSSPrefix + 'ie6');
884 cls.push(baseCSSPrefix + 'ie7');
887 cls.push(baseCSSPrefix + 'ie8');
890 cls.push(baseCSSPrefix + 'ie9');
893 cls.push(baseCSSPrefix + 'gecko');
896 cls.push(baseCSSPrefix + 'gecko3');
899 cls.push(baseCSSPrefix + 'gecko4');
902 cls.push(baseCSSPrefix + 'opera');
905 cls.push(baseCSSPrefix + 'webkit');
908 cls.push(baseCSSPrefix + 'safari');
911 cls.push(baseCSSPrefix + 'safari2');
914 cls.push(baseCSSPrefix + 'safari3');
917 cls.push(baseCSSPrefix + 'safari4');
920 cls.push(baseCSSPrefix + 'chrome');
923 cls.push(baseCSSPrefix + 'mac');
926 cls.push(baseCSSPrefix + 'linux');
928 if (!Ext.supports.CSS3BorderRadius) {
929 cls.push(baseCSSPrefix + 'nbr');
931 if (!Ext.supports.CSS3LinearGradient) {
932 cls.push(baseCSSPrefix + 'nlg');
934 if (!Ext.scopeResetCSS) {
935 cls.push(baseCSSPrefix + 'reset');
938 // add to the parent to allow for selectors x-strict x-border-box, also set the isBorderBox property correctly
940 if (Ext.isStrict && (Ext.isIE6 || Ext.isIE7)) {
941 Ext.isBorderBox = false;
944 Ext.isBorderBox = true;
947 htmlCls.push(baseCSSPrefix + (Ext.isBorderBox ? 'border-box' : 'strict'));
949 htmlCls.push(baseCSSPrefix + 'quirks');
950 if (Ext.isIE && !Ext.isStrict) {
951 Ext.isIEQuirks = true;
954 Ext.fly(html, '_internal').addCls(htmlCls);
957 Ext.fly(bd, '_internal').addCls(cls);
961 Ext.onReady(initExtCss);
963 </pre></pre></body></html>