/usr/share/javascript/yui3/event-base-ie/event-base-ie.js is in libjs-yui3-full 3.5.1-1ubuntu3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 | /*
YUI 3.5.1 (build 22)
Copyright 2012 Yahoo! Inc. All rights reserved.
Licensed under the BSD License.
http://yuilibrary.com/license/
*/
(function() {
var stateChangeListener,
GLOBAL_ENV = YUI.Env,
config = YUI.config,
doc = config.doc,
docElement = doc && doc.documentElement,
EVENT_NAME = 'onreadystatechange',
pollInterval = config.pollInterval || 40;
if (docElement.doScroll && !GLOBAL_ENV._ieready) {
GLOBAL_ENV._ieready = function() {
GLOBAL_ENV._ready();
};
/*! DOMReady: based on work by: Dean Edwards/John Resig/Matthias Miller/Diego Perini */
// Internet Explorer: use the doScroll() method on the root element.
// This isolates what appears to be a safe moment to manipulate the
// DOM prior to when the document's readyState suggests it is safe to do so.
if (self !== self.top) {
stateChangeListener = function() {
if (doc.readyState == 'complete') {
GLOBAL_ENV.remove(doc, EVENT_NAME, stateChangeListener);
GLOBAL_ENV.ieready();
}
};
GLOBAL_ENV.add(doc, EVENT_NAME, stateChangeListener);
} else {
GLOBAL_ENV._dri = setInterval(function() {
try {
docElement.doScroll('left');
clearInterval(GLOBAL_ENV._dri);
GLOBAL_ENV._dri = null;
GLOBAL_ENV._ieready();
} catch (domNotReady) { }
}, pollInterval);
}
}
})();
YUI.add('event-base-ie', function(Y) {
/*
* Custom event engine, DOM event listener abstraction layer, synthetic DOM
* events.
* @module event
* @submodule event-base
*/
function IEEventFacade() {
// IEEventFacade.superclass.constructor.apply(this, arguments);
Y.DOM2EventFacade.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) {
var proxy = Y.config.doc.createEventObject(e),
proto = IELazyFacade.prototype;
// TODO: necessary?
proxy.hasOwnProperty = function () { return true; };
proxy.init = proto.init;
proxy.halt = proto.halt;
proxy.preventDefault = proto.preventDefault;
proxy.stopPropagation = proto.stopPropagation;
proxy.stopImmediatePropagation = proto.stopImmediatePropagation;
Y.DOM2EventFacade.apply(proxy, arguments);
return proxy;
}
var imp = Y.config.doc && Y.config.doc.implementation,
useLazyFacade = Y.config.lazyEventFacade,
buttonMap = {
0: 1, // left click
4: 2, // middle click
2: 3 // right click
},
relatedTargetMap = {
mouseout: 'toElement',
mouseover: 'fromElement'
},
resolve = Y.DOM2EventFacade.resolve,
proto = {
init: function() {
IEEventFacade.superclass.init.apply(this, arguments);
var e = this._event,
x, y, d, b, de, t;
this.target = resolve(e.srcElement);
if (('clientX' in e) && (!x) && (0 !== x)) {
x = e.clientX;
y = e.clientY;
d = Y.config.doc;
b = d.body;
de = d.documentElement;
x += (de.scrollLeft || (b && b.scrollLeft) || 0);
y += (de.scrollTop || (b && b.scrollTop) || 0);
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.
this.relatedTarget = resolve(t || e.relatedTarget);
// 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
this.button = e.keyCode || buttonMap[e.button] || e.button;
},
stopPropagation: function() {
this._event.cancelBubble = true;
this._wrapper.stopped = 1;
this.stopped = 1;
},
stopImmediatePropagation: function() {
this.stopPropagation();
this._wrapper.stopped = 2;
this.stopped = 2;
},
preventDefault: function(returnValue) {
this._event.returnValue = returnValue || false;
this._wrapper.prevented = 1;
this.prevented = 1;
}
};
Y.extend(IEEventFacade, Y.DOM2EventFacade, proto);
Y.extend(IELazyFacade, Y.DOM2EventFacade, proto);
IELazyFacade.prototype.init = function () {
var e = this._event,
overrides = this._wrapper.overrides,
define = IELazyFacade._define,
lazyProperties = IELazyFacade._lazyProperties,
prop;
this.altKey = e.altKey;
this.ctrlKey = e.ctrlKey;
this.metaKey = e.metaKey;
this.shiftKey = e.shiftKey;
this.type = (overrides && overrides.type) || e.type;
this.clientX = e.clientX;
this.clientY = e.clientY;
this.keyCode = // chained assignment
this.charCode = e.keyCode;
this.which = // chained assignment
this.button = e.keyCode || buttonMap[e.button] || e.button;
for (prop in lazyProperties) {
if (lazyProperties.hasOwnProperty(prop)) {
define(this, prop, lazyProperties[prop]);
}
}
if (this._touch) {
this._touch(e, this._currentTarget, this._wrapper);
}
};
IELazyFacade._lazyProperties = {
target: function () {
return resolve(this._event.srcElement);
},
relatedTarget: function () {
var e = this._event,
targetProp = relatedTargetMap[e.type] || 'relatedTarget';
// 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.
return resolve(e[targetProp] || e.relatedTarget);
},
currentTarget: function () {
return resolve(this._currentTarget);
},
wheelDelta: function () {
var e = this._event;
if (e.type === "mousewheel" || e.type === "DOMMouseScroll") {
return (e.detail) ?
(e.detail * -1) :
// wheelDelta between -80 and 80 result in -1 or 1
Math.round(e.wheelDelta / 80) || ((e.wheelDelta < 0) ? -1 : 1);
}
},
pageX: function () {
var e = this._event,
val = e.pageX,
doc, bodyScroll, docScroll;
if (val === undefined) {
doc = Y.config.doc;
bodyScroll = doc.body && doc.body.scrollLeft;
docScroll = doc.documentElement.scrollLeft;
val = e.clientX + (docScroll || bodyScroll || 0);
}
return val;
},
pageY: function () {
var e = this._event,
val = e.pageY,
doc, bodyScroll, docScroll;
if (val === undefined) {
doc = Y.config.doc;
bodyScroll = doc.body && doc.body.scrollTop;
docScroll = doc.documentElement.scrollTop;
val = e.clientY + (docScroll || bodyScroll || 0);
}
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
*/
IELazyFacade._define = function (o, prop, valueFn) {
function val(v) {
var ret = (arguments.length) ? v : valueFn.call(this);
delete o[prop];
Object.defineProperty(o, prop, {
value: ret,
configurable: true,
writable: true
});
return ret;
}
Object.defineProperty(o, prop, {
get: val,
set: val,
configurable: true
});
};
if (imp && (!imp.hasFeature('Events', '2.0'))) {
if (useLazyFacade) {
// Make sure we can use the lazy facade logic
try {
Object.defineProperty(Y.config.doc.createEventObject(), 'z', {});
} catch (e) {
useLazyFacade = false;
}
}
Y.DOMEventFacade = (useLazyFacade) ? IELazyFacade : IEEventFacade;
}
}, '3.5.1' ,{after:['event-base'], requires:['node-base']});
|