4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
5 <title>The source code</title>
6 <link href="../prettify/prettify.css" type="text/css" rel="stylesheet" />
7 <script type="text/javascript" src="../prettify/prettify.js"></script>
8 <style type="text/css">
9 .highlight { display: block; background-color: #ddd; }
11 <script type="text/javascript">
12 function highlight() {
13 document.getElementById(location.hash.replace(/#/, "")).className = "highlight";
17 <body onload="prettyPrint(); highlight();">
18 <pre class="prettyprint lang-js"><span id='Ext-EventManager'>/**
19 </span> * @class Ext.EventManager
20 * Registers event handlers that want to receive a normalized EventObject instead of the standard browser event and provides
21 * several useful events directly.
22 * See {@link Ext.EventObject} for more details on normalized event objects.
27 // --------------------- onReady ---------------------
29 <span id='Ext-EventManager-property-hasBoundOnReady'> /**
30 </span> * Check if we have bound our global onReady listener
33 hasBoundOnReady: false,
35 <span id='Ext-EventManager-property-hasFiredReady'> /**
36 </span> * Check if fireDocReady has been called
41 <span id='Ext-EventManager-property-readyTimeout'> /**
42 </span> * Timer for the document ready event in old IE versions
47 <span id='Ext-EventManager-property-hasOnReadyStateChange'> /**
48 </span> * Checks if we have bound an onreadystatechange event
51 hasOnReadyStateChange: false,
53 <span id='Ext-EventManager-property-readyEvent'> /**
54 </span> * Holds references to any onReady functions
57 readyEvent: new Ext.util.Event(),
59 <span id='Ext-EventManager-method-checkReadyState'> /**
60 </span> * Check the ready state for old IE versions
62 * @return {Boolean} True if the document is ready
64 checkReadyState: function(){
65 var me = Ext.EventManager;
67 if(window.attachEvent){
68 // See here for reference: http://javascript.nwbox.com/IEContentLoaded/
73 document.documentElement.doScroll('left');
80 if (document.readyState == 'complete') {
84 me.readyTimeout = setTimeout(arguments.callee, 2);
88 <span id='Ext-EventManager-method-bindReadyEvent'> /**
89 </span> * Binds the appropriate browser event for checking if the DOM has loaded.
92 bindReadyEvent: function(){
93 var me = Ext.EventManager;
94 if (me.hasBoundOnReady) {
98 if (document.addEventListener) {
99 document.addEventListener('DOMContentLoaded', me.fireDocReady, false);
100 // fallback, load will ~always~ fire
101 window.addEventListener('load', me.fireDocReady, false);
103 // check if the document is ready, this will also kick off the scroll checking timer
104 if (!me.checkReadyState()) {
105 document.attachEvent('onreadystatechange', me.checkReadyState);
106 me.hasOnReadyStateChange = true;
108 // fallback, onload will ~always~ fire
109 window.attachEvent('onload', me.fireDocReady, false);
111 me.hasBoundOnReady = true;
114 <span id='Ext-EventManager-method-fireDocReady'> /**
115 </span> * We know the document is loaded, so trigger any onReady events.
118 fireDocReady: function(){
119 var me = Ext.EventManager;
121 // only unbind these events once
122 if (!me.hasFiredReady) {
123 me.hasFiredReady = true;
125 if (document.addEventListener) {
126 document.removeEventListener('DOMContentLoaded', me.fireDocReady, false);
127 window.removeEventListener('load', me.fireDocReady, false);
129 if (me.readyTimeout !== null) {
130 clearTimeout(me.readyTimeout);
132 if (me.hasOnReadyStateChange) {
133 document.detachEvent('onreadystatechange', me.checkReadyState);
135 window.detachEvent('onload', me.fireDocReady);
142 me.readyEvent.fire();
146 <span id='Ext-EventManager-method-onDocumentReady'> /**
147 </span> * Adds a listener to be notified when the document is ready (before onload and before images are loaded). Can be
148 * accessed shorthanded as Ext.onReady().
149 * @param {Function} fn The method the event invokes.
150 * @param {Object} scope (optional) The scope (<code>this</code> reference) in which the handler function executes. Defaults to the browser window.
151 * @param {boolean} options (optional) Options object as passed to {@link Ext.core.Element#addListener}.
153 onDocumentReady: function(fn, scope, options){
154 options = options || {};
155 var me = Ext.EventManager,
156 readyEvent = me.readyEvent;
158 // force single to be true so our event is only ever fired once.
159 options.single = true;
161 // Document already loaded, let's just fire it
163 readyEvent.addListener(fn, scope, options);
166 options.delay = options.delay || 1;
167 readyEvent.addListener(fn, scope, options);
173 // --------------------- event binding ---------------------
175 <span id='Ext-EventManager-property-stoppedMouseDownEvent'> /**
176 </span> * Contains a list of all document mouse downs, so we can ensure they fire even when stopEvent is called.
179 stoppedMouseDownEvent: new Ext.util.Event(),
181 <span id='Ext-EventManager-property-propRe'> /**
182 </span> * Options to parse for the 4th argument to addListener.
185 propRe: /^(?:scope|delay|buffer|single|stopEvent|preventDefault|stopPropagation|normalized|args|delegate|freezeEvent)$/,
187 <span id='Ext-EventManager-method-getId'> /**
188 </span> * Get the id of the element. If one has not been assigned, automatically assign it.
189 * @param {Mixed} element The element to get the id for.
190 * @return {String} id
192 getId : function(element) {
193 var skipGarbageCollection = false,
196 element = Ext.getDom(element);
198 if (element === document || element === window) {
199 id = element === document ? Ext.documentId : Ext.windowId;
202 id = Ext.id(element);
204 // skip garbage collection for special elements (window, document, iframes)
205 if (element && (element.getElementById || element.navigator)) {
206 skipGarbageCollection = true;
210 Ext.core.Element.addToCache(new Ext.core.Element(element), id);
211 if (skipGarbageCollection) {
212 Ext.cache[id].skipGarbageCollection = true;
218 <span id='Ext-EventManager-method-prepareListenerConfig'> /**
219 </span> * Convert a "config style" listener into a set of flat arguments so they can be passed to addListener
221 * @param {Object} element The element the event is for
222 * @param {Object} event The event configuration
223 * @param {Object} isRemove True if a removal should be performed, otherwise an add will be done.
225 prepareListenerConfig: function(element, config, isRemove){
230 // loop over all the keys in the object
231 for (key in config) {
232 if (config.hasOwnProperty(key)) {
233 // if the key is something else then an event option
234 if (!propRe.test(key)) {
236 // if the value is a function it must be something like click: function(){}, scope: this
237 // which means that there might be multiple event listeners with shared options
238 if (Ext.isFunction(value)) {
240 args = [element, key, value, config.scope, config];
242 // if its not a function, it must be an object like click: {fn: function(){}, scope: this}
243 args = [element, key, value.fn, value.scope, value];
246 if (isRemove === true) {
247 me.removeListener.apply(this, args);
249 me.addListener.apply(me, args);
256 <span id='Ext-EventManager-method-normalizeEvent'> /**
257 </span> * Normalize cross browser event differences
259 * @param {Object} eventName The event name
260 * @param {Object} fn The function to execute
261 * @return {Object} The new event name/function
263 normalizeEvent: function(eventName, fn){
264 if (/mouseenter|mouseleave/.test(eventName) && !Ext.supports.MouseEnterLeave) {
266 fn = Ext.Function.createInterceptor(fn, this.contains, this);
268 eventName = eventName == 'mouseenter' ? 'mouseover' : 'mouseout';
269 } else if (eventName == 'mousewheel' && !Ext.supports.MouseWheel && !Ext.isOpera){
270 eventName = 'DOMMouseScroll';
273 eventName: eventName,
278 <span id='Ext-EventManager-method-contains'> /**
279 </span> * Checks whether the event's relatedTarget is contained inside (or <b>is</b>) the element.
281 * @param {Object} event
283 contains: function(event){
284 var parent = event.browserEvent.currentTarget,
285 child = this.getRelatedTarget(event);
287 if (parent && parent.firstChild) {
289 if (child === parent) {
292 child = child.parentNode;
293 if (child && (child.nodeType != 1)) {
301 <span id='Ext-EventManager-method-addListener'> /**
302 </span> * Appends an event handler to an element. The shorthand version {@link #on} is equivalent. Typically you will
303 * use {@link Ext.core.Element#addListener} directly on an Element in favor of calling this version.
304 * @param {String/HTMLElement} el The html element or id to assign the event handler to.
305 * @param {String} eventName The name of the event to listen for.
306 * @param {Function} handler The handler function the event invokes. This function is passed
307 * the following parameters:<ul>
308 * <li>evt : EventObject<div class="sub-desc">The {@link Ext.EventObject EventObject} describing the event.</div></li>
309 * <li>t : Element<div class="sub-desc">The {@link Ext.core.Element Element} which was the target of the event.
310 * Note that this may be filtered by using the <tt>delegate</tt> option.</div></li>
311 * <li>o : Object<div class="sub-desc">The options object from the addListener call.</div></li>
313 * @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>.
314 * @param {Object} options (optional) An object containing handler configuration properties.
315 * This may contain any of the following properties:<ul>
316 * <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>
317 * <li>delegate : String<div class="sub-desc">A simple selector to filter the target or look for a descendant of the target</div></li>
318 * <li>stopEvent : Boolean<div class="sub-desc">True to stop the event. That is stop propagation, and prevent the default action.</div></li>
319 * <li>preventDefault : Boolean<div class="sub-desc">True to prevent the default action</div></li>
320 * <li>stopPropagation : Boolean<div class="sub-desc">True to prevent event propagation</div></li>
321 * <li>normalized : Boolean<div class="sub-desc">False to pass a browser event to the handler function instead of an Ext.EventObject</div></li>
322 * <li>delay : Number<div class="sub-desc">The number of milliseconds to delay the invocation of the handler after te event fires.</div></li>
323 * <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>
324 * <li>buffer : Number<div class="sub-desc">Causes the handler to be scheduled to run in an {@link Ext.util.DelayedTask} delayed
325 * by the specified number of milliseconds. If the event fires again within that time, the original
326 * handler is <em>not</em> invoked, but the new handler is scheduled in its place.</div></li>
327 * <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>
328 * </ul><br>
329 * <p>See {@link Ext.core.Element#addListener} for examples of how to use these options.</p>
331 addListener: function(element, eventName, fn, scope, options){
332 // Check if we've been passed a "config style" event.
333 if (typeof eventName !== 'string') {
334 this.prepareListenerConfig(element, eventName);
338 var dom = Ext.getDom(element),
345 sourceClass: 'Ext.EventManager',
346 sourceMethod: 'addListener',
347 targetElement: element,
348 eventName: eventName,
349 msg: 'Error adding "' + eventName + '\" listener for nonexistent element "' + element + '"'
354 sourceClass: 'Ext.EventManager',
355 sourceMethod: 'addListener',
356 targetElement: element,
357 eventName: eventName,
358 msg: 'Error adding "' + eventName + '\" listener. The handler function is undefined.'
363 // create the wrapper function
364 options = options || {};
366 bind = this.normalizeEvent(eventName, fn);
367 wrap = this.createListenerWrap(dom, eventName, bind.fn, scope, options);
370 if (dom.attachEvent) {
371 dom.attachEvent('on' + bind.eventName, wrap);
373 dom.addEventListener(bind.eventName, wrap, options.capture || false);
376 if (dom == document && eventName == 'mousedown') {
377 this.stoppedMouseDownEvent.addListener(wrap);
380 // add all required data into the event cache
381 this.getEventListenerCache(dom, eventName).push({
388 <span id='Ext-EventManager-method-removeListener'> /**
389 </span> * Removes an event handler from an element. The shorthand version {@link #un} is equivalent. Typically
390 * you will use {@link Ext.core.Element#removeListener} directly on an Element in favor of calling this version.
391 * @param {String/HTMLElement} el The id or html element from which to remove the listener.
392 * @param {String} eventName The name of the event.
393 * @param {Function} fn The handler function to remove. <b>This must be a reference to the function passed into the {@link #addListener} call.</b>
394 * @param {Object} scope If a scope (<b><code>this</code></b> reference) was specified when the listener was added,
395 * then this must refer to the same object.
397 removeListener : function(element, eventName, fn, scope) {
398 // handle our listener config object syntax
399 if (typeof eventName !== 'string') {
400 this.prepareListenerConfig(element, eventName, true);
404 var dom = Ext.getDom(element),
405 cache = this.getEventListenerCache(dom, eventName),
406 bindName = this.normalizeEvent(eventName).eventName,
408 listener, wrap, tasks;
414 if (listener && (!fn || listener.fn == fn) && (!scope || listener.scope === scope)) {
415 wrap = listener.wrap;
417 // clear buffered calls
419 clearTimeout(wrap.task);
423 // clear delayed calls
424 j = wrap.tasks && wrap.tasks.length;
427 clearTimeout(wrap.tasks[j]);
432 if (dom.detachEvent) {
433 dom.detachEvent('on' + bindName, wrap);
435 dom.removeEventListener(bindName, wrap, false);
438 if (wrap && dom == document && eventName == 'mousedown') {
439 this.stoppedMouseDownEvent.removeListener(wrap);
442 // remove listener from cache
443 Ext.Array.erase(cache, i, 1);
448 <span id='Ext-EventManager-method-removeAll'> /**
449 </span> * Removes all event handers from an element. Typically you will use {@link Ext.core.Element#removeAllListeners}
450 * directly on an Element in favor of calling this version.
451 * @param {String/HTMLElement} el The id or html element from which to remove all event handlers.
453 removeAll : function(element){
454 var dom = Ext.getDom(element),
459 cache = this.getElementEventCache(dom);
462 if (cache.hasOwnProperty(ev)) {
463 this.removeListener(dom, ev);
466 Ext.cache[dom.id].events = {};
469 <span id='Ext-EventManager-method-purgeElement'> /**
470 </span> * Recursively removes all previous added listeners from an element and its children. Typically you will use {@link Ext.core.Element#purgeAllListeners}
471 * directly on an Element in favor of calling this version.
472 * @param {String/HTMLElement} el The id or html element from which to remove all event handlers.
473 * @param {String} eventName (optional) The name of the event.
475 purgeElement : function(element, eventName) {
476 var dom = Ext.getDom(element),
480 this.removeListener(dom, eventName);
486 if(dom && dom.childNodes) {
487 for(len = element.childNodes.length; i < len; i++) {
488 this.purgeElement(element.childNodes[i], eventName);
493 <span id='Ext-EventManager-method-createListenerWrap'> /**
494 </span> * Create the wrapper function for the event
496 * @param {HTMLElement} dom The dom element
497 * @param {String} ename The event name
498 * @param {Function} fn The function to execute
499 * @param {Object} scope The scope to execute callback in
500 * @param {Object} options The options
501 * @return {Function} the wrapper function
503 createListenerWrap : function(dom, ename, fn, scope, options) {
504 options = options || {};
508 return function wrap(e, args) {
509 // Compile the implementation upon first firing
511 f = ['if(!Ext) {return;}'];
513 if(options.buffer || options.delay || options.freezeEvent) {
514 f.push('e = new Ext.EventObjectImpl(e, ' + (options.freezeEvent ? 'true' : 'false' ) + ');');
516 f.push('e = Ext.EventObject.setEvent(e);');
519 if (options.delegate) {
520 f.push('var t = e.getTarget("' + options.delegate + '", this);');
521 f.push('if(!t) {return;}');
523 f.push('var t = e.target;');
526 if (options.target) {
527 f.push('if(e.target !== options.target) {return;}');
530 if(options.stopEvent) {
531 f.push('e.stopEvent();');
533 if(options.preventDefault) {
534 f.push('e.preventDefault();');
536 if(options.stopPropagation) {
537 f.push('e.stopPropagation();');
541 if(options.normalized === false) {
542 f.push('e = e.browserEvent;');
546 f.push('(wrap.task && clearTimeout(wrap.task));');
547 f.push('wrap.task = setTimeout(function(){');
551 f.push('wrap.tasks = wrap.tasks || [];');
552 f.push('wrap.tasks.push(setTimeout(function(){');
555 // finally call the actual handler fn
556 f.push('fn.call(scope || dom, e, t, options);');
559 f.push('Ext.EventManager.removeListener(dom, ename, fn, scope);');
563 f.push('}, ' + options.delay + '));');
567 f.push('}, ' + options.buffer + ');');
570 gen = Ext.functionFactory('e', 'options', 'fn', 'scope', 'ename', 'dom', 'wrap', 'args', f.join('\n'));
573 gen.call(dom, e, options, fn, scope, ename, dom, wrap, args);
577 <span id='Ext-EventManager-method-getEventListenerCache'> /**
578 </span> * Get the event cache for a particular element for a particular event
580 * @param {HTMLElement} element The element
581 * @param {Object} eventName The event name
582 * @return {Array} The events for the element
584 getEventListenerCache : function(element, eventName) {
589 var eventCache = this.getElementEventCache(element);
590 return eventCache[eventName] || (eventCache[eventName] = []);
593 <span id='Ext-EventManager-method-getElementEventCache'> /**
594 </span> * Gets the event cache for the object
596 * @param {HTMLElement} element The element
597 * @return {Object} The event cache for the object
599 getElementEventCache : function(element) {
603 var elementCache = Ext.cache[this.getId(element)];
604 return elementCache.events || (elementCache.events = {});
607 // --------------------- utility methods ---------------------
608 mouseLeaveRe: /(mouseout|mouseleave)/,
609 mouseEnterRe: /(mouseover|mouseenter)/,
611 <span id='Ext-EventManager-method-stopEvent'> /**
612 </span> * Stop the event (preventDefault and stopPropagation)
613 * @param {Event} The event to stop
615 stopEvent: function(event) {
616 this.stopPropagation(event);
617 this.preventDefault(event);
620 <span id='Ext-EventManager-method-stopPropagation'> /**
621 </span> * Cancels bubbling of the event.
622 * @param {Event} The event to stop bubbling.
624 stopPropagation: function(event) {
625 event = event.browserEvent || event;
626 if (event.stopPropagation) {
627 event.stopPropagation();
629 event.cancelBubble = true;
633 <span id='Ext-EventManager-method-preventDefault'> /**
634 </span> * Prevents the browsers default handling of the event.
635 * @param {Event} The event to prevent the default
637 preventDefault: function(event) {
638 event = event.browserEvent || event;
639 if (event.preventDefault) {
640 event.preventDefault();
642 event.returnValue = false;
643 // Some keys events require setting the keyCode to -1 to be prevented
645 // all ctrl + X and F1 -> F12
646 if (event.ctrlKey || event.keyCode > 111 && event.keyCode < 124) {
650 // see this outdated document http://support.microsoft.com/kb/934364/en-us for more info
655 <span id='Ext-EventManager-method-getRelatedTarget'> /**
656 </span> * Gets the related target from the event.
657 * @param {Object} event The event
658 * @return {HTMLElement} The related target.
660 getRelatedTarget: function(event) {
661 event = event.browserEvent || event;
662 var target = event.relatedTarget;
664 if (this.mouseLeaveRe.test(event.type)) {
665 target = event.toElement;
666 } else if (this.mouseEnterRe.test(event.type)) {
667 target = event.fromElement;
670 return this.resolveTextNode(target);
673 <span id='Ext-EventManager-method-getPageX'> /**
674 </span> * Gets the x coordinate from the event
675 * @param {Object} event The event
676 * @return {Number} The x coordinate
678 getPageX: function(event) {
679 return this.getXY(event)[0];
682 <span id='Ext-EventManager-method-getPageY'> /**
683 </span> * Gets the y coordinate from the event
684 * @param {Object} event The event
685 * @return {Number} The y coordinate
687 getPageY: function(event) {
688 return this.getXY(event)[1];
691 <span id='Ext-EventManager-method-getPageXY'> /**
692 </span> * Gets the x & ycoordinate from the event
693 * @param {Object} event The event
694 * @return {Array} The x/y coordinate
696 getPageXY: function(event) {
697 event = event.browserEvent || event;
700 doc = document.documentElement,
701 body = document.body;
703 // pageX/pageY not available (undefined, not null), use clientX/clientY instead
704 if (!x && x !== 0) {
705 x = event.clientX + (doc && doc.scrollLeft || body && body.scrollLeft || 0) - (doc && doc.clientLeft || body && body.clientLeft || 0);
706 y = event.clientY + (doc && doc.scrollTop || body && body.scrollTop || 0) - (doc && doc.clientTop || body && body.clientTop || 0);
711 <span id='Ext-EventManager-method-getTarget'> /**
712 </span> * Gets the target of the event.
713 * @param {Object} event The event
714 * @return {HTMLElement} target
716 getTarget: function(event) {
717 event = event.browserEvent || event;
718 return this.resolveTextNode(event.target || event.srcElement);
721 <span id='Ext-EventManager-property-resolveTextNode'> /**
722 </span> * Resolve any text nodes accounting for browser differences.
724 * @param {HTMLElement} node The node
725 * @return {HTMLElement} The resolved node
727 // 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.
728 resolveTextNode: Ext.isGecko ?
733 // work around firefox bug, https://bugzilla.mozilla.org/show_bug.cgi?id=101197
734 var s = HTMLElement.prototype.toString.call(node);
735 if (s == '[xpconnect wrapped native prototype]' || s == '[object XULElement]') {
738 return node.nodeType == 3 ? node.parentNode: node;
740 return node && node.nodeType == 3 ? node.parentNode: node;
743 // --------------------- custom event binding ---------------------
745 // Keep track of the current width/height
749 <span id='Ext-EventManager-method-onWindowResize'> /**
750 </span> * Adds a listener to be notified when the browser window is resized and provides resize event buffering (100 milliseconds),
751 * passes new viewport width and height to handlers.
752 * @param {Function} fn The handler function the window resize event invokes.
753 * @param {Object} scope The scope (<code>this</code> reference) in which the handler function executes. Defaults to the browser window.
754 * @param {boolean} options Options object as passed to {@link Ext.core.Element#addListener}
756 onWindowResize: function(fn, scope, options){
757 var resize = this.resizeEvent;
759 this.resizeEvent = resize = new Ext.util.Event();
760 this.on(window, 'resize', this.fireResize, this, {buffer: 100});
762 resize.addListener(fn, scope, options);
765 <span id='Ext-EventManager-method-fireResize'> /**
766 </span> * Fire the resize event.
769 fireResize: function(){
771 w = Ext.core.Element.getViewWidth(),
772 h = Ext.core.Element.getViewHeight();
774 //whacky problem in IE where the resize event will sometimes fire even though the w/h are the same.
775 if(me.curHeight != h || me.curWidth != w){
778 me.resizeEvent.fire(w, h);
782 <span id='Ext-EventManager-method-removeResizeListener'> /**
783 </span> * Removes the passed window resize listener.
784 * @param {Function} fn The method the event invokes
785 * @param {Object} scope The scope of handler
787 removeResizeListener: function(fn, scope){
788 if (this.resizeEvent) {
789 this.resizeEvent.removeListener(fn, scope);
793 onWindowUnload: function() {
794 var unload = this.unloadEvent;
796 this.unloadEvent = unload = new Ext.util.Event();
797 this.addListener(window, 'unload', this.fireUnload, this);
801 <span id='Ext-EventManager-method-fireUnload'> /**
802 </span> * Fires the unload event for items bound with onWindowUnload
805 fireUnload: function() {
806 // wrap in a try catch, could have some problems during unload
808 this.removeUnloadListener();
809 // Work around FF3 remembering the last scroll position when refreshing the grid and then losing grid view
811 var gridviews = Ext.ComponentQuery.query('gridview'),
813 ln = gridviews.length;
814 for (; i < ln; i++) {
815 gridviews[i].scrollToTop();
818 // Purge all elements in the cache
822 if (cache.hasOwnProperty(el)) {
823 Ext.EventManager.removeAll(el);
830 <span id='Ext-EventManager-method-removeUnloadListener'> /**
831 </span> * Removes the passed window unload listener.
832 * @param {Function} fn The method the event invokes
833 * @param {Object} scope The scope of handler
835 removeUnloadListener: function(){
836 if (this.unloadEvent) {
837 this.removeListener(window, 'unload', this.fireUnload);
841 <span id='Ext-EventManager-property-useKeyDown'> /**
842 </span> * note 1: IE fires ONLY the keydown event on specialkey autorepeat
843 * note 2: Safari < 3.1, Gecko (Mac/Linux) & Opera fire only the keypress event on specialkey autorepeat
844 * (research done by @Jan Wolter at http://unixpapa.com/js/key.html)
847 useKeyDown: Ext.isWebKit ?
848 parseInt(navigator.userAgent.match(/AppleWebKit\/(\d+)/)[1], 10) >= 525 :
849 !((Ext.isGecko && !Ext.isWindows) || Ext.isOpera),
851 <span id='Ext-EventManager-method-getKeyEvent'> /**
852 </span> * Indicates which event to use for getting key presses.
853 * @return {String} The appropriate event name.
855 getKeyEvent: function(){
856 return this.useKeyDown ? 'keydown' : 'keypress';
860 <span id='Ext-method-onReady'>/**
861 </span> * Alias for {@link Ext.Loader#onReady Ext.Loader.onReady} with withDomReady set to true
865 Ext.onReady = function(fn, scope, options) {
866 Ext.Loader.onReady(fn, scope, true, options);
869 <span id='Ext-method-onDocumentReady'>/**
870 </span> * Alias for {@link Ext.EventManager#onDocumentReady Ext.EventManager.onDocumentReady}
872 * @method onDocumentReady
874 Ext.onDocumentReady = Ext.EventManager.onDocumentReady;
876 <span id='Ext-EventManager-method-on'>/**
877 </span> * Alias for {@link Ext.EventManager#addListener Ext.EventManager.addListener}
878 * @member Ext.EventManager
881 Ext.EventManager.on = Ext.EventManager.addListener;
883 <span id='Ext-EventManager-method-un'>/**
884 </span> * Alias for {@link Ext.EventManager#removeListener Ext.EventManager.removeListener}
885 * @member Ext.EventManager
888 Ext.EventManager.un = Ext.EventManager.removeListener;
891 var initExtCss = function() {
892 // find the body element
893 var bd = document.body || document.getElementsByTagName('body')[0],
894 baseCSSPrefix = Ext.baseCSSPrefix,
895 cls = [baseCSSPrefix + 'body'],
903 html = bd.parentNode;
905 //Let's keep this human readable!
907 cls.push(baseCSSPrefix + 'ie');
910 cls.push(baseCSSPrefix + 'ie6');
913 cls.push(baseCSSPrefix + 'ie7');
916 cls.push(baseCSSPrefix + 'ie8');
919 cls.push(baseCSSPrefix + 'ie9');
922 cls.push(baseCSSPrefix + 'gecko');
925 cls.push(baseCSSPrefix + 'gecko3');
928 cls.push(baseCSSPrefix + 'gecko4');
931 cls.push(baseCSSPrefix + 'opera');
934 cls.push(baseCSSPrefix + 'webkit');
937 cls.push(baseCSSPrefix + 'safari');
940 cls.push(baseCSSPrefix + 'safari2');
943 cls.push(baseCSSPrefix + 'safari3');
946 cls.push(baseCSSPrefix + 'safari4');
949 cls.push(baseCSSPrefix + 'chrome');
952 cls.push(baseCSSPrefix + 'mac');
955 cls.push(baseCSSPrefix + 'linux');
957 if (!Ext.supports.CSS3BorderRadius) {
958 cls.push(baseCSSPrefix + 'nbr');
960 if (!Ext.supports.CSS3LinearGradient) {
961 cls.push(baseCSSPrefix + 'nlg');
963 if (!Ext.scopeResetCSS) {
964 cls.push(baseCSSPrefix + 'reset');
967 // add to the parent to allow for selectors x-strict x-border-box, also set the isBorderBox property correctly
969 if (Ext.isStrict && (Ext.isIE6 || Ext.isIE7)) {
970 Ext.isBorderBox = false;
973 Ext.isBorderBox = true;
976 htmlCls.push(baseCSSPrefix + (Ext.isBorderBox ? 'border-box' : 'strict'));
978 htmlCls.push(baseCSSPrefix + 'quirks');
979 if (Ext.isIE && !Ext.isStrict) {
980 Ext.isIEQuirks = true;
983 Ext.fly(html, '_internal').addCls(htmlCls);
986 Ext.fly(bd, '_internal').addCls(cls);
990 Ext.onReady(initExtCss);