event-facade-dom-ie.js revision aa087e251c506cac2b1ca195c53f7eb3a9ef7542
/*
* Custom event engine, DOM event listener abstraction layer, synthetic DOM
* events.
* @module event
* @submodule event-base
*/
function IEEventFacade() {
// IEEventFacade.superclass.constructor.apply(this, arguments);
}
/*
* (intentially left out of API docs)
* Alternate Facade implementation that is based on Object.defineProperty, which
* is partially supported in IE8. Properties that involve setup work are
* deferred to temporary getters using the static _define method.
*/
function IELazyFacade(e) {
// TODO: necessary?
proxy.hasOwnProperty = function () { return true; };
return proxy;
}
buttonMap = {
0: 1, // left click
4: 2, // middle click
2: 3 // right click
},
relatedTargetMap = {
mouseout: 'toElement',
mouseover: 'fromElement'
},
proto = {
init: function() {
var e = this._event,
x, y, d, b, de, t;
if (('clientX' in e) && (!x) && (0 !== x)) {
x = e.clientX;
y = e.clientY;
b = d.body;
de = d.documentElement;
this.pageX = x;
this.pageY = y;
}
if (e.type == "mouseout") {
t = e.toElement;
} else if (e.type == "mouseover") {
t = e.fromElement;
}
// fallback to t.relatedTarget to support simulated events.
// IE doesn't support setting toElement or fromElement on generic
// events, so Y.Event.simulate sets relatedTarget instead.
// which should contain the unicode key code if this is a key event.
// For click events, which is normalized for which mouse button was
// clicked.
this.which = // chained assignment
},
stopPropagation: function() {
this._event.cancelBubble = true;
this.stopped = 1;
},
stopImmediatePropagation: function() {
this.stopPropagation();
this.stopped = 2;
},
preventDefault: function(returnValue) {
this.prevented = 1;
}
};
var e = this._event,
prop;
this.keyCode = // chained assignment
this.which = // chained assignment
for (prop in lazyProperties) {
}
}
if (this._touch) {
}
};
target: function () {
},
relatedTarget: function () {
var e = this._event,
// fallback to t.relatedTarget to support simulated events.
// IE doesn't support setting toElement or fromElement on generic
// events, so Y.Event.simulate sets relatedTarget instead.
},
currentTarget: function () {
return resolve(this._currentTarget);
},
wheelDelta: function () {
var e = this._event;
return (e.detail) ?
(e.detail * -1) :
// wheelDelta between -80 and 80 result in -1 or 1
}
},
pageX: function () {
var e = this._event,
}
return val;
},
pageY: function () {
var e = this._event,
}
return val;
}
};
/**
* Wrapper function for Object.defineProperty that creates a property whose
* value will be calulated only when asked for. After calculating the value,
* the getter wll be removed, so it will behave as a normal property beyond that
* point. A setter is also assigned so assigning to the property will clear
* the getter, so foo.prop = 'a'; foo.prop; won't trigger the getter,
* overwriting value 'a'.
*
* Used only by the DOMEventFacades used by IE8 when the YUI configuration
* <code>lazyEventFacade</code> is set to true.
*
* @method _define
* @param o {DOMObject} A DOM object to add the property to
* @param prop {String} The name of the new property
* @param valueFn {Function} The function that will return the initial, default
* value for the property.
* @static
* @private
*/
function val(v) {
delete o[prop];
Object.defineProperty(o, prop, {
configurable: true,
writable: true
});
return ret;
}
Object.defineProperty(o, prop, {
configurable: true
});
};
if (useLazyFacade) {
// Make sure we can use the lazy facade logic
try {
} catch (e) {
useLazyFacade = false;
}
}
}