2 Copyright (c) 2010, Yahoo! Inc. All rights reserved.
3 Code licensed under the BSD License:
4 http://developer.yahoo.com/yui/license.html
10 var stateChangeListener,
14 docElement = doc && doc.documentElement,
15 EVENT_NAME = 'onreadystatechange',
16 pollInterval = config.pollInterval || 40;
18 if (docElement.doScroll && !GLOBAL_ENV._ieready) {
19 GLOBAL_ENV._ieready = function() {
23 /*! DOMReady: based on work by: Dean Edwards/John Resig/Matthias Miller/Diego Perini */
24 // Internet Explorer: use the doScroll() method on the root element.
25 // This isolates what appears to be a safe moment to manipulate the
26 // DOM prior to when the document's readyState suggests it is safe to do so.
27 if (self !== self.top) {
28 stateChangeListener = function() {
29 if (doc.readyState == 'complete') {
30 GLOBAL_ENV.remove(doc, EVENT_NAME, stateChangeListener);
34 GLOBAL_ENV.add(doc, EVENT_NAME, stateChangeListener);
36 GLOBAL_ENV._dri = setInterval(function() {
38 docElement.doScroll('left');
39 clearInterval(GLOBAL_ENV._dri);
40 GLOBAL_ENV._dri = null;
41 GLOBAL_ENV._ieready();
42 } catch (domNotReady) { }
48 YUI.add('event-base-ie', function(Y) {
51 * Custom event engine, DOM event listener abstraction layer, synthetic DOM
54 * @submodule event-base
57 var IEEventFacade = function() {
58 // IEEventFacade.superclass.constructor.apply(this, arguments);
59 Y.DOM2EventFacade.apply(this, arguments);
62 Y.extend(IEEventFacade, Y.DOM2EventFacade, {
66 IEEventFacade.superclass.init.apply(this, arguments);
69 resolve = Y.DOM2EventFacade.resolve,
72 this.target = resolve(e.srcElement);
74 if (('clientX' in e) && (!x) && (0 !== x)) {
80 de = d.documentElement;
82 x += (de.scrollLeft || (b && b.scrollLeft) || 0);
83 y += (de.scrollTop || (b && b.scrollTop) || 0);
89 if (e.type == "mouseout") {
91 } else if (e.type == "mouseover") {
95 this.relatedTarget = resolve(t);
97 // which should contain the unicode key code if this is a key event
99 // this.which = e.charCode;
102 // for click events, which is normalized for which mouse button was
113 this.which = e.button;
116 this.button = this.which;
121 stopPropagation: function() {
123 e.cancelBubble = true;
124 this._wrapper.stopped = 1;
128 stopImmediatePropagation: function() {
129 this.stopPropagation();
130 this._wrapper.stopped = 2;
134 preventDefault: function(returnValue) {
135 this._event.returnValue = returnValue || false;
136 this._wrapper.prevented = 1;
142 var imp = Y.config.doc && Y.config.doc.implementation;
144 if (imp && (!imp.hasFeature('Events', '2.0'))) {
145 Y.DOMEventFacade = IEEventFacade;