4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
5 <title>The source code</title>
6 <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
7 <script type="text/javascript" src="../resources/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/
69 // licensed courtesy of http://developer.yahoo.com/yui/license.html
74 document.documentElement.doScroll('left');
81 if (document.readyState == 'complete') {
85 me.readyTimeout = setTimeout(arguments.callee, 2);
89 <span id='Ext-EventManager-method-bindReadyEvent'> /**
90 </span> * Binds the appropriate browser event for checking if the DOM has loaded.
93 bindReadyEvent: function(){
94 var me = Ext.EventManager;
95 if (me.hasBoundOnReady) {
99 if (document.addEventListener) {
100 document.addEventListener('DOMContentLoaded', me.fireDocReady, false);
101 // fallback, load will ~always~ fire
102 window.addEventListener('load', me.fireDocReady, false);
104 // check if the document is ready, this will also kick off the scroll checking timer
105 if (!me.checkReadyState()) {
106 document.attachEvent('onreadystatechange', me.checkReadyState);
107 me.hasOnReadyStateChange = true;
109 // fallback, onload will ~always~ fire
110 window.attachEvent('onload', me.fireDocReady, false);
112 me.hasBoundOnReady = true;
115 <span id='Ext-EventManager-method-fireDocReady'> /**
116 </span> * We know the document is loaded, so trigger any onReady events.
119 fireDocReady: function(){
120 var me = Ext.EventManager;
122 // only unbind these events once
123 if (!me.hasFiredReady) {
124 me.hasFiredReady = true;
126 if (document.addEventListener) {
127 document.removeEventListener('DOMContentLoaded', me.fireDocReady, false);
128 window.removeEventListener('load', me.fireDocReady, false);
130 if (me.readyTimeout !== null) {
131 clearTimeout(me.readyTimeout);
133 if (me.hasOnReadyStateChange) {
134 document.detachEvent('onreadystatechange', me.checkReadyState);
136 window.detachEvent('onload', me.fireDocReady);
143 me.readyEvent.fire();
147 <span id='Ext-EventManager-method-onDocumentReady'> /**
148 </span> * Adds a listener to be notified when the document is ready (before onload and before images are loaded). Can be
149 * accessed shorthanded as Ext.onReady().
150 * @param {Function} fn The method the event invokes.
151 * @param {Object} scope (optional) The scope (<code>this</code> reference) in which the handler function executes. Defaults to the browser window.
152 * @param {Boolean} options (optional) Options object as passed to {@link Ext.Element#addListener}.
154 onDocumentReady: function(fn, scope, options){
155 options = options || {};
156 var me = Ext.EventManager,
157 readyEvent = me.readyEvent;
159 // force single to be true so our event is only ever fired once.
160 options.single = true;
162 // Document already loaded, let's just fire it
164 readyEvent.addListener(fn, scope, options);
167 options.delay = options.delay || 1;
168 readyEvent.addListener(fn, scope, options);
174 // --------------------- event binding ---------------------
176 <span id='Ext-EventManager-property-stoppedMouseDownEvent'> /**
177 </span> * Contains a list of all document mouse downs, so we can ensure they fire even when stopEvent is called.
180 stoppedMouseDownEvent: new Ext.util.Event(),
182 <span id='Ext-EventManager-property-propRe'> /**
183 </span> * Options to parse for the 4th argument to addListener.
186 propRe: /^(?:scope|delay|buffer|single|stopEvent|preventDefault|stopPropagation|normalized|args|delegate|freezeEvent)$/,
188 <span id='Ext-EventManager-method-getId'> /**
189 </span> * Get the id of the element. If one has not been assigned, automatically assign it.
190 * @param {HTMLElement/Ext.Element} element The element to get the id for.
191 * @return {String} id
193 getId : function(element) {
194 var skipGarbageCollection = false,
197 element = Ext.getDom(element);
199 if (element === document || element === window) {
200 id = element === document ? Ext.documentId : Ext.windowId;
203 id = Ext.id(element);
205 // skip garbage collection for special elements (window, document, iframes)
206 if (element && (element.getElementById || element.navigator)) {
207 skipGarbageCollection = true;
211 Ext.Element.addToCache(new Ext.Element(element), id);
212 if (skipGarbageCollection) {
213 Ext.cache[id].skipGarbageCollection = true;
219 <span id='Ext-EventManager-method-prepareListenerConfig'> /**
220 </span> * Convert a "config style" listener into a set of flat arguments so they can be passed to addListener
222 * @param {Object} element The element the event is for
223 * @param {Object} event The event configuration
224 * @param {Object} isRemove True if a removal should be performed, otherwise an add will be done.
226 prepareListenerConfig: function(element, config, isRemove){
231 // loop over all the keys in the object
232 for (key in config) {
233 if (config.hasOwnProperty(key)) {
234 // if the key is something else then an event option
235 if (!propRe.test(key)) {
237 // if the value is a function it must be something like click: function(){}, scope: this
238 // which means that there might be multiple event listeners with shared options
239 if (Ext.isFunction(value)) {
241 args = [element, key, value, config.scope, config];
243 // if its not a function, it must be an object like click: {fn: function(){}, scope: this}
244 args = [element, key, value.fn, value.scope, value];
247 if (isRemove === true) {
248 me.removeListener.apply(this, args);
250 me.addListener.apply(me, args);
257 <span id='Ext-EventManager-method-normalizeEvent'> /**
258 </span> * Normalize cross browser event differences
260 * @param {Object} eventName The event name
261 * @param {Object} fn The function to execute
262 * @return {Object} The new event name/function
264 normalizeEvent: function(eventName, fn){
265 if (/mouseenter|mouseleave/.test(eventName) && !Ext.supports.MouseEnterLeave) {
267 fn = Ext.Function.createInterceptor(fn, this.contains, this);
269 eventName = eventName == 'mouseenter' ? 'mouseover' : 'mouseout';
270 } else if (eventName == 'mousewheel' && !Ext.supports.MouseWheel && !Ext.isOpera){
271 eventName = 'DOMMouseScroll';
274 eventName: eventName,
279 <span id='Ext-EventManager-method-contains'> /**
280 </span> * Checks whether the event's relatedTarget is contained inside (or <b>is</b>) the element.
282 * @param {Object} event
284 contains: function(event){
285 var parent = event.browserEvent.currentTarget,
286 child = this.getRelatedTarget(event);
288 if (parent && parent.firstChild) {
290 if (child === parent) {
293 child = child.parentNode;
294 if (child && (child.nodeType != 1)) {
302 <span id='Ext-EventManager-method-addListener'> /**
303 </span> * Appends an event handler to an element. The shorthand version {@link #on} is equivalent. Typically you will
304 * use {@link Ext.Element#addListener} directly on an Element in favor of calling this version.
305 * @param {String/HTMLElement} el The html element or id to assign the event handler to.
306 * @param {String} eventName The name of the event to listen for.
307 * @param {Function} handler The handler function the event invokes. This function is passed
308 * the following parameters:<ul>
309 * <li>evt : EventObject<div class="sub-desc">The {@link Ext.EventObject EventObject} describing the event.</div></li>
310 * <li>t : Element<div class="sub-desc">The {@link Ext.Element Element} which was the target of the event.
311 * Note that this may be filtered by using the <tt>delegate</tt> option.</div></li>
312 * <li>o : Object<div class="sub-desc">The options object from the addListener call.</div></li>
314 * @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>.
315 * @param {Object} options (optional) An object containing handler configuration properties.
316 * This may contain any of the following properties:<ul>
317 * <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>
318 * <li>delegate : String<div class="sub-desc">A simple selector to filter the target or look for a descendant of the target</div></li>
319 * <li>stopEvent : Boolean<div class="sub-desc">True to stop the event. That is stop propagation, and prevent the default action.</div></li>
320 * <li>preventDefault : Boolean<div class="sub-desc">True to prevent the default action</div></li>
321 * <li>stopPropagation : Boolean<div class="sub-desc">True to prevent event propagation</div></li>
322 * <li>normalized : Boolean<div class="sub-desc">False to pass a browser event to the handler function instead of an Ext.EventObject</div></li>
323 * <li>delay : Number<div class="sub-desc">The number of milliseconds to delay the invocation of the handler after te event fires.</div></li>
324 * <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>
325 * <li>buffer : Number<div class="sub-desc">Causes the handler to be scheduled to run in an {@link Ext.util.DelayedTask} delayed
326 * by the specified number of milliseconds. If the event fires again within that time, the original
327 * handler is <em>not</em> invoked, but the new handler is scheduled in its place.</div></li>
328 * <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>
329 * </ul><br>
330 * <p>See {@link Ext.Element#addListener} for examples of how to use these options.</p>
332 addListener: function(element, eventName, fn, scope, options){
333 // Check if we've been passed a "config style" event.
334 if (typeof eventName !== 'string') {
335 this.prepareListenerConfig(element, eventName);
339 var dom = Ext.getDom(element),
346 sourceClass: 'Ext.EventManager',
347 sourceMethod: 'addListener',
348 targetElement: element,
349 eventName: eventName,
350 msg: 'Error adding "' + eventName + '\" listener for nonexistent element "' + element + '"'
355 sourceClass: 'Ext.EventManager',
356 sourceMethod: 'addListener',
357 targetElement: element,
358 eventName: eventName,
359 msg: 'Error adding "' + eventName + '\" listener. The handler function is undefined.'
364 // create the wrapper function
365 options = options || {};
367 bind = this.normalizeEvent(eventName, fn);
368 wrap = this.createListenerWrap(dom, eventName, bind.fn, scope, options);
371 if (dom.attachEvent) {
372 dom.attachEvent('on' + bind.eventName, wrap);
374 dom.addEventListener(bind.eventName, wrap, options.capture || false);
377 if (dom == document && eventName == 'mousedown') {
378 this.stoppedMouseDownEvent.addListener(wrap);
381 // add all required data into the event cache
382 this.getEventListenerCache(dom, eventName).push({
389 <span id='Ext-EventManager-method-removeListener'> /**
390 </span> * Removes an event handler from an element. The shorthand version {@link #un} is equivalent. Typically
391 * you will use {@link Ext.Element#removeListener} directly on an Element in favor of calling this version.
392 * @param {String/HTMLElement} el The id or html element from which to remove the listener.
393 * @param {String} eventName The name of the event.
394 * @param {Function} fn The handler function to remove. <b>This must be a reference to the function passed into the {@link #addListener} call.</b>
395 * @param {Object} scope If a scope (<b><code>this</code></b> reference) was specified when the listener was added,
396 * then this must refer to the same object.
398 removeListener : function(element, eventName, fn, scope) {
399 // handle our listener config object syntax
400 if (typeof eventName !== 'string') {
401 this.prepareListenerConfig(element, eventName, true);
405 var dom = Ext.getDom(element),
406 cache = this.getEventListenerCache(dom, eventName),
407 bindName = this.normalizeEvent(eventName).eventName,
409 listener, wrap, tasks;
415 if (listener && (!fn || listener.fn == fn) && (!scope || listener.scope === scope)) {
416 wrap = listener.wrap;
418 // clear buffered calls
420 clearTimeout(wrap.task);
424 // clear delayed calls
425 j = wrap.tasks && wrap.tasks.length;
428 clearTimeout(wrap.tasks[j]);
433 if (dom.detachEvent) {
434 dom.detachEvent('on' + bindName, wrap);
436 dom.removeEventListener(bindName, wrap, false);
439 if (wrap && dom == document && eventName == 'mousedown') {
440 this.stoppedMouseDownEvent.removeListener(wrap);
443 // remove listener from cache
444 Ext.Array.erase(cache, i, 1);
449 <span id='Ext-EventManager-method-removeAll'> /**
450 </span> * Removes all event handers from an element. Typically you will use {@link Ext.Element#removeAllListeners}
451 * directly on an Element in favor of calling this version.
452 * @param {String/HTMLElement} el The id or html element from which to remove all event handlers.
454 removeAll : function(element){
455 var dom = Ext.getDom(element),
460 cache = this.getElementEventCache(dom);
463 if (cache.hasOwnProperty(ev)) {
464 this.removeListener(dom, ev);
467 Ext.cache[dom.id].events = {};
470 <span id='Ext-EventManager-method-purgeElement'> /**
471 </span> * Recursively removes all previous added listeners from an element and its children. Typically you will use {@link Ext.Element#purgeAllListeners}
472 * directly on an Element in favor of calling this version.
473 * @param {String/HTMLElement} el The id or html element from which to remove all event handlers.
474 * @param {String} eventName (optional) The name of the event.
476 purgeElement : function(element, eventName) {
477 var dom = Ext.getDom(element),
481 this.removeListener(dom, eventName);
487 if(dom && dom.childNodes) {
488 for(len = element.childNodes.length; i < len; i++) {
489 this.purgeElement(element.childNodes[i], eventName);
494 <span id='Ext-EventManager-method-createListenerWrap'> /**
495 </span> * Create the wrapper function for the event
497 * @param {HTMLElement} dom The dom element
498 * @param {String} ename The event name
499 * @param {Function} fn The function to execute
500 * @param {Object} scope The scope to execute callback in
501 * @param {Object} options The options
502 * @return {Function} the wrapper function
504 createListenerWrap : function(dom, ename, fn, scope, options) {
505 options = options || {};
509 return function wrap(e, args) {
510 // Compile the implementation upon first firing
512 f = ['if(!Ext) {return;}'];
514 if(options.buffer || options.delay || options.freezeEvent) {
515 f.push('e = new Ext.EventObjectImpl(e, ' + (options.freezeEvent ? 'true' : 'false' ) + ');');
517 f.push('e = Ext.EventObject.setEvent(e);');
520 if (options.delegate) {
521 f.push('var t = e.getTarget("' + options.delegate + '", this);');
522 f.push('if(!t) {return;}');
524 f.push('var t = e.target;');
527 if (options.target) {
528 f.push('if(e.target !== options.target) {return;}');
531 if(options.stopEvent) {
532 f.push('e.stopEvent();');
534 if(options.preventDefault) {
535 f.push('e.preventDefault();');
537 if(options.stopPropagation) {
538 f.push('e.stopPropagation();');
542 if(options.normalized === false) {
543 f.push('e = e.browserEvent;');
547 f.push('(wrap.task && clearTimeout(wrap.task));');
548 f.push('wrap.task = setTimeout(function(){');
552 f.push('wrap.tasks = wrap.tasks || [];');
553 f.push('wrap.tasks.push(setTimeout(function(){');
556 // finally call the actual handler fn
557 f.push('fn.call(scope || dom, e, t, options);');
560 f.push('Ext.EventManager.removeListener(dom, ename, fn, scope);');
564 f.push('}, ' + options.delay + '));');
568 f.push('}, ' + options.buffer + ');');
571 gen = Ext.functionFactory('e', 'options', 'fn', 'scope', 'ename', 'dom', 'wrap', 'args', f.join('\n'));
574 gen.call(dom, e, options, fn, scope, ename, dom, wrap, args);
578 <span id='Ext-EventManager-method-getEventListenerCache'> /**
579 </span> * Get the event cache for a particular element for a particular event
581 * @param {HTMLElement} element The element
582 * @param {Object} eventName The event name
583 * @return {Array} The events for the element
585 getEventListenerCache : function(element, eventName) {
590 var eventCache = this.getElementEventCache(element);
591 return eventCache[eventName] || (eventCache[eventName] = []);
594 <span id='Ext-EventManager-method-getElementEventCache'> /**
595 </span> * Gets the event cache for the object
597 * @param {HTMLElement} element The element
598 * @return {Object} The event cache for the object
600 getElementEventCache : function(element) {
604 var elementCache = Ext.cache[this.getId(element)];
605 return elementCache.events || (elementCache.events = {});
608 // --------------------- utility methods ---------------------
609 mouseLeaveRe: /(mouseout|mouseleave)/,
610 mouseEnterRe: /(mouseover|mouseenter)/,
612 <span id='Ext-EventManager-method-stopEvent'> /**
613 </span> * Stop the event (preventDefault and stopPropagation)
614 * @param {Event} The event to stop
616 stopEvent: function(event) {
617 this.stopPropagation(event);
618 this.preventDefault(event);
621 <span id='Ext-EventManager-method-stopPropagation'> /**
622 </span> * Cancels bubbling of the event.
623 * @param {Event} The event to stop bubbling.
625 stopPropagation: function(event) {
626 event = event.browserEvent || event;
627 if (event.stopPropagation) {
628 event.stopPropagation();
630 event.cancelBubble = true;
634 <span id='Ext-EventManager-method-preventDefault'> /**
635 </span> * Prevents the browsers default handling of the event.
636 * @param {Event} The event to prevent the default
638 preventDefault: function(event) {
639 event = event.browserEvent || event;
640 if (event.preventDefault) {
641 event.preventDefault();
643 event.returnValue = false;
644 // Some keys events require setting the keyCode to -1 to be prevented
646 // all ctrl + X and F1 -> F12
647 if (event.ctrlKey || event.keyCode > 111 && event.keyCode < 124) {
651 // see this outdated document http://support.microsoft.com/kb/934364/en-us for more info
656 <span id='Ext-EventManager-method-getRelatedTarget'> /**
657 </span> * Gets the related target from the event.
658 * @param {Object} event The event
659 * @return {HTMLElement} The related target.
661 getRelatedTarget: function(event) {
662 event = event.browserEvent || event;
663 var target = event.relatedTarget;
665 if (this.mouseLeaveRe.test(event.type)) {
666 target = event.toElement;
667 } else if (this.mouseEnterRe.test(event.type)) {
668 target = event.fromElement;
671 return this.resolveTextNode(target);
674 <span id='Ext-EventManager-method-getPageX'> /**
675 </span> * Gets the x coordinate from the event
676 * @param {Object} event The event
677 * @return {Number} The x coordinate
679 getPageX: function(event) {
680 return this.getXY(event)[0];
683 <span id='Ext-EventManager-method-getPageY'> /**
684 </span> * Gets the y coordinate from the event
685 * @param {Object} event The event
686 * @return {Number} The y coordinate
688 getPageY: function(event) {
689 return this.getXY(event)[1];
692 <span id='Ext-EventManager-method-getPageXY'> /**
693 </span> * Gets the x & y coordinate from the event
694 * @param {Object} event The event
695 * @return {Number[]} The x/y coordinate
697 getPageXY: function(event) {
698 event = event.browserEvent || event;
701 doc = document.documentElement,
702 body = document.body;
704 // pageX/pageY not available (undefined, not null), use clientX/clientY instead
705 if (!x && x !== 0) {
706 x = event.clientX + (doc && doc.scrollLeft || body && body.scrollLeft || 0) - (doc && doc.clientLeft || body && body.clientLeft || 0);
707 y = event.clientY + (doc && doc.scrollTop || body && body.scrollTop || 0) - (doc && doc.clientTop || body && body.clientTop || 0);
712 <span id='Ext-EventManager-method-getTarget'> /**
713 </span> * Gets the target of the event.
714 * @param {Object} event The event
715 * @return {HTMLElement} target
717 getTarget: function(event) {
718 event = event.browserEvent || event;
719 return this.resolveTextNode(event.target || event.srcElement);
722 <span id='Ext-EventManager-property-resolveTextNode'> /**
723 </span> * Resolve any text nodes accounting for browser differences.
725 * @param {HTMLElement} node The node
726 * @return {HTMLElement} The resolved node
728 // 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.
729 resolveTextNode: Ext.isGecko ?
734 // work around firefox bug, https://bugzilla.mozilla.org/show_bug.cgi?id=101197
735 var s = HTMLElement.prototype.toString.call(node);
736 if (s == '[xpconnect wrapped native prototype]' || s == '[object XULElement]') {
739 return node.nodeType == 3 ? node.parentNode: node;
741 return node && node.nodeType == 3 ? node.parentNode: node;
744 // --------------------- custom event binding ---------------------
746 // Keep track of the current width/height
750 <span id='Ext-EventManager-method-onWindowResize'> /**
751 </span> * Adds a listener to be notified when the browser window is resized and provides resize event buffering (100 milliseconds),
752 * passes new viewport width and height to handlers.
753 * @param {Function} fn The handler function the window resize event invokes.
754 * @param {Object} scope The scope (<code>this</code> reference) in which the handler function executes. Defaults to the browser window.
755 * @param {Boolean} options Options object as passed to {@link Ext.Element#addListener}
757 onWindowResize: function(fn, scope, options){
758 var resize = this.resizeEvent;
760 this.resizeEvent = resize = new Ext.util.Event();
761 this.on(window, 'resize', this.fireResize, this, {buffer: 100});
763 resize.addListener(fn, scope, options);
766 <span id='Ext-EventManager-method-fireResize'> /**
767 </span> * Fire the resize event.
770 fireResize: function(){
772 w = Ext.Element.getViewWidth(),
773 h = Ext.Element.getViewHeight();
775 //whacky problem in IE where the resize event will sometimes fire even though the w/h are the same.
776 if(me.curHeight != h || me.curWidth != w){
779 me.resizeEvent.fire(w, h);
783 <span id='Ext-EventManager-method-removeResizeListener'> /**
784 </span> * Removes the passed window resize listener.
785 * @param {Function} fn The method the event invokes
786 * @param {Object} scope The scope of handler
788 removeResizeListener: function(fn, scope){
789 if (this.resizeEvent) {
790 this.resizeEvent.removeListener(fn, scope);
794 onWindowUnload: function() {
795 var unload = this.unloadEvent;
797 this.unloadEvent = unload = new Ext.util.Event();
798 this.addListener(window, 'unload', this.fireUnload, this);
802 <span id='Ext-EventManager-method-fireUnload'> /**
803 </span> * Fires the unload event for items bound with onWindowUnload
806 fireUnload: function() {
807 // wrap in a try catch, could have some problems during unload
809 this.removeUnloadListener();
810 // Work around FF3 remembering the last scroll position when refreshing the grid and then losing grid view
812 var gridviews = Ext.ComponentQuery.query('gridview'),
814 ln = gridviews.length;
815 for (; i < ln; i++) {
816 gridviews[i].scrollToTop();
819 // Purge all elements in the cache
823 if (cache.hasOwnProperty(el)) {
824 Ext.EventManager.removeAll(el);
831 <span id='Ext-EventManager-method-removeUnloadListener'> /**
832 </span> * Removes the passed window unload listener.
833 * @param {Function} fn The method the event invokes
834 * @param {Object} scope The scope of handler
836 removeUnloadListener: function(){
837 if (this.unloadEvent) {
838 this.removeListener(window, 'unload', this.fireUnload);
842 <span id='Ext-EventManager-property-useKeyDown'> /**
843 </span> * note 1: IE fires ONLY the keydown event on specialkey autorepeat
844 * note 2: Safari < 3.1, Gecko (Mac/Linux) & Opera fire only the keypress event on specialkey autorepeat
845 * (research done by Jan Wolter at http://unixpapa.com/js/key.html)
848 useKeyDown: Ext.isWebKit ?
849 parseInt(navigator.userAgent.match(/AppleWebKit\/(\d+)/)[1], 10) >= 525 :
850 !((Ext.isGecko && !Ext.isWindows) || Ext.isOpera),
852 <span id='Ext-EventManager-method-getKeyEvent'> /**
853 </span> * Indicates which event to use for getting key presses.
854 * @return {String} The appropriate event name.
856 getKeyEvent: function(){
857 return this.useKeyDown ? 'keydown' : 'keypress';
861 <span id='Ext-method-onReady'>/**
862 </span> * Alias for {@link Ext.Loader#onReady Ext.Loader.onReady} with withDomReady set to true
866 Ext.onReady = function(fn, scope, options) {
867 Ext.Loader.onReady(fn, scope, true, options);
870 <span id='Ext-method-onDocumentReady'>/**
871 </span> * Alias for {@link Ext.EventManager#onDocumentReady Ext.EventManager.onDocumentReady}
873 * @method onDocumentReady
875 Ext.onDocumentReady = Ext.EventManager.onDocumentReady;
877 <span id='Ext-EventManager-method-on'>/**
878 </span> * Alias for {@link Ext.EventManager#addListener Ext.EventManager.addListener}
879 * @member Ext.EventManager
882 Ext.EventManager.on = Ext.EventManager.addListener;
884 <span id='Ext-EventManager-method-un'>/**
885 </span> * Alias for {@link Ext.EventManager#removeListener Ext.EventManager.removeListener}
886 * @member Ext.EventManager
889 Ext.EventManager.un = Ext.EventManager.removeListener;
892 var initExtCss = function() {
893 // find the body element
894 var bd = document.body || document.getElementsByTagName('body')[0],
895 baseCSSPrefix = Ext.baseCSSPrefix,
896 cls = [baseCSSPrefix + 'body'],
904 html = bd.parentNode;
907 cls.push(baseCSSPrefix + c);
910 //Let's keep this human readable!
914 // very often CSS needs to do checks like "IE7+" or "IE6 or 7". To help
915 // reduce the clutter (since CSS/SCSS cannot do these tests), we add some
916 // additional classes:
918 // x-ie7p : IE7+ : 7 <= ieVer
919 // x-ie7m : IE7- : ieVer <= 7
920 // x-ie8p : IE8+ : 8 <= ieVer
921 // x-ie8m : IE8- : ieVer <= 8
922 // x-ie9p : IE9+ : 9 <= ieVer
923 // x-ie78 : IE7 or 8 : 7 <= ieVer <= 8
927 } else { // ignore pre-IE6 :)
947 if (Ext.isIE6 || Ext.isIE7) {
950 if (Ext.isIE6 || Ext.isIE7 || Ext.isIE8) {
953 if (Ext.isIE7 || Ext.isIE8) {
999 if (!Ext.supports.CSS3BorderRadius) {
1002 if (!Ext.supports.CSS3LinearGradient) {
1005 if (!Ext.scopeResetCSS) {
1009 // add to the parent to allow for selectors x-strict x-border-box, also set the isBorderBox property correctly
1011 if (Ext.isStrict && (Ext.isIE6 || Ext.isIE7)) {
1012 Ext.isBorderBox = false;
1015 Ext.isBorderBox = true;
1018 htmlCls.push(baseCSSPrefix + (Ext.isBorderBox ? 'border-box' : 'strict'));
1019 if (!Ext.isStrict) {
1020 htmlCls.push(baseCSSPrefix + 'quirks');
1022 Ext.fly(html, '_internal').addCls(htmlCls);
1025 Ext.fly(bd, '_internal').addCls(cls);
1029 Ext.onReady(initExtCss);