r20514: implement idl for DsGetNT4ChangeLog() which transferres the meta data
[ira/wip.git] / webapps / qooxdoo-0.6.3-sdk / frontend / framework / source / class / qx / dom / Style.js
1 /* ************************************************************************
2
3    qooxdoo - the new era of web development
4
5    http://qooxdoo.org
6
7    Copyright:
8      2004-2006 by 1&1 Internet AG, Germany, http://www.1and1.org
9
10    License:
11      LGPL 2.1: http://www.gnu.org/licenses/lgpl.html
12
13    Authors:
14      * Sebastian Werner (wpbasti)
15      * Andreas Ecker (ecker)
16
17 ************************************************************************ */
18
19 /* ************************************************************************
20
21 #module(ui_core)
22 #require(qx.sys.Client)
23
24 ************************************************************************ */
25
26 qx.OO.defineClass("qx.dom.Style");
27
28 if (Boolean(document.defaultView) && Boolean(document.defaultView.getComputedStyle))
29 {
30   qx.dom.Style.getStylePropertySure = function(el, prop) { return !el ? null : el.ownerDocument ? el.ownerDocument.defaultView.getComputedStyle(el, "")[prop] : el.style[prop]; }
31
32   qx.dom.Style.getStyleProperty = function(el, prop)
33   {
34     try
35     {
36       return el.ownerDocument.defaultView.getComputedStyle(el, "")[prop];
37     }
38     catch(ex)
39     {
40       throw new Error("Could not evaluate computed style: " + el + "[" + prop + "]: " + ex);
41     }
42   }
43 }
44 else if (qx.sys.Client.getInstance().isMshtml())
45 {
46   qx.dom.Style.getStyleProperty = function(el, prop)
47   {
48     try
49     {
50       return el.currentStyle[prop];
51     }
52     catch(ex)
53     {
54       throw new Error("Could not evaluate computed style: " + el + "[" + prop + "]: " + ex);
55     }
56   }
57
58   qx.dom.Style.getStylePropertySure = function(el, prop)
59   {
60     try
61     {
62       if (!el) {
63         return null;
64       }
65
66       if (el.parentNode && el.currentStyle)
67       {
68         return el.currentStyle[prop];
69       }
70       else
71       {
72         var v1 = el.runtimeStyle[prop];
73
74         if (v1 != null && typeof v1 != "undefined" && v1 != "") {
75           return v1;
76         }
77
78         return el.style[prop];
79       }
80     }
81     catch(ex)
82     {
83       throw new Error("Could not evaluate computed style: " + el + "[" + prop + "]: " + ex);
84     }
85   }
86 }
87 else
88 {
89   qx.dom.Style.getStylePropertySure = function(el, prop) { return !el ? null : el.style[prop]; }
90
91   qx.dom.Style.getStyleProperty = function(el, prop)
92   {
93     try
94     {
95       return el.style[prop];
96     }
97     catch(ex)
98     {
99       throw new Error("Could not evaluate computed style: " + el + "[" + prop + "]");
100     }
101   }
102 }
103
104
105 qx.dom.Style.getStyleSize = function(el, prop) { return parseInt(qx.dom.Style.getStyleProperty(el, prop)) || 0; }
106
107
108 // Properties
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"); }
113
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"); }
118
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"); }