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 /* ************************************************************************
22 #require(qx.sys.Client)
24 ************************************************************************ */
26 qx.OO.defineClass("qx.dom.Style");
28 if (Boolean(document.defaultView) && Boolean(document.defaultView.getComputedStyle))
30 qx.dom.Style.getStylePropertySure = function(el, prop) { return !el ? null : el.ownerDocument ? el.ownerDocument.defaultView.getComputedStyle(el, "")[prop] : el.style[prop]; }
32 qx.dom.Style.getStyleProperty = function(el, prop)
36 return el.ownerDocument.defaultView.getComputedStyle(el, "")[prop];
40 throw new Error("Could not evaluate computed style: " + el + "[" + prop + "]: " + ex);
44 else if (qx.sys.Client.getInstance().isMshtml())
46 qx.dom.Style.getStyleProperty = function(el, prop)
50 return el.currentStyle[prop];
54 throw new Error("Could not evaluate computed style: " + el + "[" + prop + "]: " + ex);
58 qx.dom.Style.getStylePropertySure = function(el, prop)
66 if (el.parentNode && el.currentStyle)
68 return el.currentStyle[prop];
72 var v1 = el.runtimeStyle[prop];
74 if (v1 != null && typeof v1 != "undefined" && v1 != "") {
78 return el.style[prop];
83 throw new Error("Could not evaluate computed style: " + el + "[" + prop + "]: " + ex);
89 qx.dom.Style.getStylePropertySure = function(el, prop) { return !el ? null : el.style[prop]; }
91 qx.dom.Style.getStyleProperty = function(el, prop)
95 return el.style[prop];
99 throw new Error("Could not evaluate computed style: " + el + "[" + prop + "]");
105 qx.dom.Style.getStyleSize = function(el, prop) { return parseInt(qx.dom.Style.getStyleProperty(el, prop)) || 0; }
109 qx.dom.Style.getMarginLeft = function(el) { return qx.dom.Style.getStyleSize(el, "marginLeft"); }
110 qx.dom.Style.getMarginTop = function(el) { return qx.dom.Style.getStyleSize(el, "marginTop"); }
111 qx.dom.Style.getMarginRight = function(el) { return qx.dom.Style.getStyleSize(el, "marginRight"); }
112 qx.dom.Style.getMarginBottom = function(el) { return qx.dom.Style.getStyleSize(el, "marginBottom"); }
114 qx.dom.Style.getPaddingLeft = function(el) { return qx.dom.Style.getStyleSize(el, "paddingLeft"); }
115 qx.dom.Style.getPaddingTop = function(el) { return qx.dom.Style.getStyleSize(el, "paddingTop"); }
116 qx.dom.Style.getPaddingRight = function(el) { return qx.dom.Style.getStyleSize(el, "paddingRight"); }
117 qx.dom.Style.getPaddingBottom = function(el) { return qx.dom.Style.getStyleSize(el, "paddingBottom"); }
119 qx.dom.Style.getBorderLeft = function(el) { return qx.dom.Style.getStyleProperty(el, "borderLeftStyle") == "none" ? 0 : qx.dom.Style.getStyleSize(el, "borderLeftWidth"); }
120 qx.dom.Style.getBorderTop = function(el) { return qx.dom.Style.getStyleProperty(el, "borderTopStyle") == "none" ? 0 : qx.dom.Style.getStyleSize(el, "borderTopWidth"); }
121 qx.dom.Style.getBorderRight = function(el) { return qx.dom.Style.getStyleProperty(el, "borderRightStyle") == "none" ? 0 : qx.dom.Style.getStyleSize(el, "borderRightWidth"); }
122 qx.dom.Style.getBorderBottom = function(el) { return qx.dom.Style.getStyleProperty(el, "borderBottomStyle") == "none" ? 0 : qx.dom.Style.getStyleSize(el, "borderBottomWidth"); }