1 /* ************************************************************************
3 qooxdoo - the new era of web development
8 2004-2006 by 1&1 Internet AG, Germany, http://www.1and1.org
11 LGPL 2.1: http://www.gnu.org/licenses/lgpl.html
14 * Sebastian Werner (wpbasti)
15 * Andreas Ecker (ecker)
17 ************************************************************************ */
19 /* ************************************************************************
21 #require(qx.sys.Client)
23 ************************************************************************ */
25 qx.OO.defineClass("qx.lang.MshtmlEmu");
29 moz-behaviors.xml - version 1.1.1 (2005-08-19)
30 Copyright 2004-2005, Dean Edwards
31 License: http://creativecommons.org/licenses/LGPL/2.1/
32 Thanks to Erik Arvidsson (http://webfx.eae.net/dhtml/ieemu/)
36 We're going to mess about with some of mozilla's interfaces to
37 make them more explorer-like
42 In my comments where i say support/mimic a property:
44 * support = exactly the same as explorer
45 * mimic = close enough
48 if (qx.sys.Client.getInstance().isGecko())
51 --------------------------------------------------------------------------------
53 --------------------------------------------------------------------------------
57 Support microsoft's styleFloat
60 CSSStyleDeclaration.prototype.__defineGetter__("styleFloat", function() {
64 CSSStyleDeclaration.prototype.__defineSetter__("styleFloat", function(vValue) {
65 this.cssFloat = vValue;
73 --------------------------------------------------------------------------------
74 CSS STYLES: DIMENSIONS
75 --------------------------------------------------------------------------------
79 Mimic microsoft's pixel representations of left/top/width/height
80 the getters only work for values that are already pixels
83 CSSStyleDeclaration.prototype.__defineGetter__("pixelLeft", function() {
84 return parseInt(this.left) || 0;
87 CSSStyleDeclaration.prototype.__defineSetter__("pixelLeft", function(vValue) {
88 this.left = vValue + "px";
91 CSSStyleDeclaration.prototype.__defineGetter__("pixelTop", function() {
92 return parseInt(this.top) || 0;
95 CSSStyleDeclaration.prototype.__defineSetter__("pixelTop", function(vValue) {
96 this.top = vValue + "px";
99 CSSStyleDeclaration.prototype.__defineGetter__("pixelWidth", function() {
100 return parseInt(this.width) || 0;
103 CSSStyleDeclaration.prototype.__defineSetter__("pixelWidth", function(vValue) {
104 this.width = vValue + "px";
107 CSSStyleDeclaration.prototype.__defineGetter__("pixelHeight", function() {
108 return parseInt(this.height) || 0;
111 CSSStyleDeclaration.prototype.__defineSetter__("pixelHeight", function(vValue) {
112 this.height = vValue + "px";
120 --------------------------------------------------------------------------------
121 HTML DOCUMENT EXTENSIONS
122 --------------------------------------------------------------------------------
126 Support Microsoft's "all" property
128 HTMLDocument.prototype.__defineGetter__("all", function() {
129 return this.getElementsByTagName("*");
133 Mimic the "createEventObject" method for the document object
135 HTMLDocument.prototype.createEventObject = function() {
136 return document.createEvent("Events");
145 --------------------------------------------------------------------------------
146 HTML ELEMENT EXTENSIONS
147 --------------------------------------------------------------------------------
151 Mimic Microsoft's "all" property
153 HTMLElement.prototype.__defineGetter__("all", function() {
154 return this.getElementsByTagName("*");
158 Support "parentElement"
160 HTMLElement.prototype.__defineGetter__("parentElement", function() {
161 return (this.parentNode == this.ownerDocument) ? null : this.parentNode;
167 HTMLElement.prototype.__defineGetter__("uniqueID", function()
169 // a global counter is stored privately as a property of this getter function.
170 // initialise the counter
171 if (!arguments.callee.count) {
172 arguments.callee.count = 0;
175 // create the id and increment the counter
176 var vUniqueID = "moz_id" + arguments.callee.count++;
178 // creating a unique id, creates a global reference
179 window[vUniqueID] = this;
181 // we don't want to increment next time, so redefine the getter
182 this.__defineGetter__("uniqueID", function(){return vUniqueID;});
188 Mimic Microsoft's "currentStyle"
190 HTMLElement.prototype.__defineGetter__("currentStyle", function() {
191 return getComputedStyle(this, null);
195 Mimic Microsoft's "runtimeStyle"
197 HTMLElement.prototype.__defineGetter__("runtimeStyle", function()
200 this doesn't work yet (https://bugzilla.mozilla.org/show_bug.cgi?id=45424)
201 return this.ownerDocument.defaultView.getOverrideStyle(this, null);
210 HTMLElement.prototype.__defineGetter__("innerText", function() {
211 return this.textContent;
214 HTMLElement.prototype.__defineSetter__("innerText", function(vValue) {
215 this.textContent = vValue;
219 Mimic the "attachEvent" method
221 HTMLElement.prototype.attachEvent = function(vName, vHandler) {
222 this.addEventListener(vName.slice(2), vHandler, false);
226 Mimic the "removeEvent" method
228 HTMLElement.prototype.removeEvent = function(vName, vHandler) {
229 this.removeEventListener(vName.slice(2), vHandler, false);
233 Mimic the "createEventObject" method
235 HTMLElement.prototype.createEventObject = function() {
236 return this.ownerDocument.createEventObject();
240 Mimic the "fireEvent" method
242 HTMLElement.prototype.fireEvent = function(vName, vEvent)
245 vEvent = this.ownerDocument.createEventObject();
248 vEvent.initEvent(vName.slice(2), false, false);
250 this.dispatchEvent(vEvent);
252 // not sure that this should be here??
253 if (typeof this[vName] === "function")
257 else if (this.getAttribute(vName))
259 eval(this.getAttribute(vName));
264 Support the "contains" method
266 HTMLElement.prototype.contains = function(vElement) {
267 return Boolean(vElement == this || (vElement && this.contains(vElement.parentElement)));
275 --------------------------------------------------------------------------------
277 --------------------------------------------------------------------------------
281 Support Microsoft's proprietary event properties
283 Event.prototype.__defineGetter__("srcElement", function() {
284 return (this.target.nodeType == Node.ELEMENT_NODE) ? this.target : this.target.parentNode;
287 Event.prototype.__defineGetter__("fromElement",function() {
288 return (this.type == "mouseover") ? this.relatedTarget : (this.type == "mouseout") ? this.srcElement : null;
291 Event.prototype.__defineGetter__("toElement", function() {
292 return (this.type == "mouseout") ? this.relatedTarget : (this.type == "mouseover") ? this.srcElement : null;
296 Convert w3c button id's to Microsoft's
297 Breaks with qooxdoo's internal event handling!!!
300 Event.prototype.__defineGetter__("button", function() {
301 return (this.which == 1) ? 1 : (this.which == 2) ? 4 : 2;
307 Mimic "returnValue" (default is "true")
308 Breaks with qooxdoo's internal event handling!!!
311 Event.prototype.__defineGetter__("returnValue", function() {
315 Event.prototype.__defineSetter__("returnValue", function(vValue)
317 if (this.cancelable && !vValue)
319 // this can't be undone!
320 this.preventDefault();
322 this.__defineGetter__("returnValue", function() {
330 Mozilla already supports the read-only "cancelBubble"
331 so we only need to define the setter
333 Event.prototype.__defineSetter__("cancelBubble", function(vValue)
335 // this can't be undone!
337 this.stopPropagation();
341 Event.prototype.__defineGetter__("offsetX", function() {
345 Event.prototype.__defineGetter__("offsetY", function() {