diff options
author | Derrell Lipman <derrell@samba.org> | 2006-12-30 05:09:59 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 14:30:29 -0500 |
commit | 1170417ceeb8c49a46cda522a38eaa71c9cae30c (patch) | |
tree | dbf4c3fdcdb1af928dbd55f642ea40f00d09283a /webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/dom | |
parent | 23ccdca41670085da4486841b0d4900b4c8b02f3 (diff) | |
download | samba-1170417ceeb8c49a46cda522a38eaa71c9cae30c.tar.gz samba-1170417ceeb8c49a46cda522a38eaa71c9cae30c.tar.bz2 samba-1170417ceeb8c49a46cda522a38eaa71c9cae30c.zip |
r20414: Start to make SWAT usable by others. This is just a start...
(This used to be commit 26a34037a7ca6fbd05c5a6f7c2d5973e34bc6918)
Diffstat (limited to 'webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/dom')
13 files changed, 1728 insertions, 0 deletions
diff --git a/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/dom/Dimension.js b/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/dom/Dimension.js new file mode 100644 index 0000000000..7b6b6c7daf --- /dev/null +++ b/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/dom/Dimension.js @@ -0,0 +1,222 @@ +/* ************************************************************************ + + qooxdoo - the new era of web development + + http://qooxdoo.org + + Copyright: + 2004-2006 by 1&1 Internet AG, Germany, http://www.1and1.org + + License: + LGPL 2.1: http://www.gnu.org/licenses/lgpl.html + + Authors: + * Sebastian Werner (wpbasti) + * Andreas Ecker (ecker) + +************************************************************************ */ + +/* ************************************************************************ + +#module(ui_core) + +************************************************************************ */ + +qx.OO.defineClass("qx.dom.Dimension"); + +/* ++-Outer----------------------------------------+ +| Margin | +| +-Box------------------------------+ | +| | Border (+ Scrollbar) | | +| | +-Area--------------------+ | | +| | | Padding | | | +| | | +-Inner----------+ | | | +| | | | | | | | +| | | +----------------+ | | | +| | +-------------------------+ | | +| +----------------------------------+ | ++----------------------------------------------+ +*/ + +// Dimensions +qx.dom.Dimension.getOuterWidth = function(el) { return qx.dom.Dimension.getBoxWidth(el) + qx.dom.Style.getMarginLeft(el) + qx.dom.Style.getMarginRight(el); } +qx.dom.Dimension.getOuterHeight = function(el) { return qx.dom.Dimension.getBoxHeight(el) + qx.dom.Style.getMarginTop(el) + qx.dom.Style.getMarginBottom(el); } + +qx.dom.Dimension.getBoxWidthForZeroHeight = function(el) +{ + var h = el.offsetHeight; + if (h == 0) { + var o = el.style.height; + el.style.height = "1px"; + } + + var v = el.offsetWidth; + + if (h == 0) { + el.style.height = o; + } + + return v; +} + +qx.dom.Dimension.getBoxHeightForZeroWidth = function(el) +{ + var w = el.offsetWidth; + if (w == 0) { + var o = el.style.width; + el.style.width = "1px"; + } + + var v = el.offsetHeight; + + if (w == 0) { + el.style.width = o; + } + + return v; +} + +qx.dom.Dimension.getBoxWidth = function(el) { + return el.offsetWidth; +} + +qx.dom.Dimension.getBoxHeight = function(el) { + return el.offsetHeight; +} + +if (qx.sys.Client.getInstance().isGecko()) +{ + qx.dom.Dimension.getAreaWidth = function(el) + { + // 0 in clientWidth could mean both: That it is really 0 or + // that the element is not rendered by the browser and + // therefore it is 0, too + + // In Gecko based browsers there is sometimes another + // behaviour: The clientHeight is equal to the border + // sum. This is normally not correct and so we + // fix this value with a more complex calculation. + + // (Mozilla/5.0 (Windows; U; Windows NT 5.1; de-DE; rv:1.7.6) Gecko/20050223 Firefox/1.0.1) + + if (el.clientWidth != 0 && el.clientWidth != (qx.dom.Style.getBorderLeft(el) + qx.dom.Style.getBorderRight(el))) + { + return el.clientWidth; + } + else + { + return qx.dom.Dimension.getBoxWidth(el) - qx.dom.Dimension.getInsetLeft(el) - qx.dom.Dimension.getInsetRight(el); + } + } + + qx.dom.Dimension.getAreaHeight = function(el) + { + // 0 in clientHeight could mean both: That it is really 0 or + // that the element is not rendered by the browser and + // therefore it is 0, too + + // In Gecko based browsers there is sometimes another + // behaviour: The clientHeight is equal to the border + // sum. This is normally not correct and so we + // fix this value with a more complex calculation. + + // (Mozilla/5.0 (Windows; U; Windows NT 5.1; de-DE; rv:1.7.6) Gecko/20050223 Firefox/1.0.1) + + if (el.clientHeight != 0 && el.clientHeight != (qx.dom.Style.getBorderTop(el) + qx.dom.Style.getBorderBottom(el))) + { + return el.clientHeight; + } + else + { + return qx.dom.Dimension.getBoxHeight(el) - qx.dom.Dimension.getInsetTop(el) - qx.dom.Dimension.getInsetBottom(el); + } + } +} +else +{ + qx.dom.Dimension.getAreaWidth = function(el) + { + // 0 in clientWidth could mean both: That it is really 0 or + // that the element is not rendered by the browser and + // therefore it is 0, too + + return el.clientWidth != 0 ? el.clientWidth : (qx.dom.Dimension.getBoxWidth(el) - qx.dom.Dimension.getInsetLeft(el) - qx.dom.Dimension.getInsetRight(el)); + } + + qx.dom.Dimension.getAreaHeight = function(el) + { + // 0 in clientHeight could mean both: That it is really 0 or + // that the element is not rendered by the browser and + // therefore it is 0, too + + return el.clientHeight != 0 ? el.clientHeight : (qx.dom.Dimension.getBoxHeight(el) - qx.dom.Dimension.getInsetTop(el) - qx.dom.Dimension.getInsetBottom(el)); + } +} + +qx.dom.Dimension.getInnerWidth = function(el) { return qx.dom.Dimension.getAreaWidth(el) - qx.dom.Style.getPaddingLeft(el) - qx.dom.Style.getPaddingRight(el); } +qx.dom.Dimension.getInnerHeight = function(el) { return qx.dom.Dimension.getAreaHeight(el) - qx.dom.Style.getPaddingTop(el) - qx.dom.Style.getPaddingBottom(el); } + + + + +// Insets +if (qx.sys.Client.getInstance().isMshtml()) +{ + qx.dom.Dimension.getInsetLeft = function(el) { return el.clientLeft; } + qx.dom.Dimension.getInsetTop = function(el) { return el.clientTop; } + qx.dom.Dimension.getInsetRight = function(el) { + if(qx.dom.Style.getStyleProperty(el, "overflowY") == "hidden" || el.clientWidth == 0) { + return qx.dom.Style.getBorderRight(el); + } + + return Math.max(0, el.offsetWidth - el.clientLeft - el.clientWidth); + } + + qx.dom.Dimension.getInsetBottom = function(el) { + if(qx.dom.Style.getStyleProperty(el, "overflowX") == "hidden" || el.clientHeight == 0) { + return qx.dom.Style.getBorderBottom(el); + } + + return Math.max(0, el.offsetHeight - el.clientTop - el.clientHeight); + } +} +else +{ + qx.dom.Dimension.getInsetLeft = function(el) { return qx.dom.Style.getBorderLeft(el); } + qx.dom.Dimension.getInsetTop = function(el) { return qx.dom.Style.getBorderTop(el); } + + qx.dom.Dimension.getInsetRight = function(el) { + // Alternative method if clientWidth is unavailable + // clientWidth == 0 could mean both: unavailable or really 0 + if (el.clientWidth == 0) { + var ov = qx.dom.Style.getStyleProperty(el, "overflow"); + var sbv = ov == "scroll" || ov == "-moz-scrollbars-vertical" ? 16 : 0; + return Math.max(0, qx.dom.Style.getBorderRight(el) + sbv); + } + + return Math.max(0, el.offsetWidth - el.clientWidth - qx.dom.Style.getBorderLeft(el)); + } + + qx.dom.Dimension.getInsetBottom = function(el) { + // Alternative method if clientHeight is unavailable + // clientHeight == 0 could mean both: unavailable or really 0 + if (el.clientHeight == 0) { + var ov = qx.dom.Style.getStyleProperty(el, "overflow"); + var sbv = ov == "scroll" || ov == "-moz-scrollbars-horizontal" ? 16 : 0; + return Math.max(0, qx.dom.Style.getBorderBottom(el) + sbv); + } + + return Math.max(0, el.offsetHeight - el.clientHeight - qx.dom.Style.getBorderTop(el)); + } +} + + +// Scrollbar +qx.dom.Dimension.getScrollBarSizeLeft = function(el) { return 0; } +qx.dom.Dimension.getScrollBarSizeTop = function(el) { return 0; } +qx.dom.Dimension.getScrollBarSizeRight = function(el) { return qx.dom.Dimension.getInsetRight(el) - qx.dom.Style.getBorderRight(el); } +qx.dom.Dimension.getScrollBarSizeBottom = function(el) { return qx.dom.Dimension.getInsetBottom(el) - qx.dom.Style.getBorderBottom(el); } + +qx.dom.Dimension.getScrollBarVisibleX = function(el) { return qx.dom.Dimension.getScrollBarSizeRight(el) > 0; } +qx.dom.Dimension.getScrollBarVisibleY = function(el) { return qx.dom.Dimension.getScrollBarSizeBottom(el) > 0; } diff --git a/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/dom/Element.js b/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/dom/Element.js new file mode 100644 index 0000000000..fa851e1434 --- /dev/null +++ b/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/dom/Element.js @@ -0,0 +1,74 @@ +/* ************************************************************************ + + qooxdoo - the new era of web development + + http://qooxdoo.org + + Copyright: + 2004-2006 by 1&1 Internet AG, Germany, http://www.1and1.org + + License: + LGPL 2.1: http://www.gnu.org/licenses/lgpl.html + + Authors: + * Sebastian Werner (wpbasti) + * Andreas Ecker (ecker) + +************************************************************************ */ + +/** + * Crossbrowser operations on DOM Nodes + */ +qx.OO.defineClass("qx.dom.Element"); + + +/** + * Removes whitespace-only text node children + * + * @param vElement {Element} DOM element + */ +qx.dom.Element.cleanWhitespace = function(vElement) +{ + for (var i=0; i<vElement.childNodes.length; i++) + { + var node = vElement.childNodes[i]; + + if (node.nodeType == 3 && !/\S/.test(node.nodeValue)) { + vElement.removeChild(node); + } + } +} + + +/** + * Checks if a element has no content + * + * @param vElement {Element} DOM element + */ +qx.dom.Element.isEmpty = function(vElement) { + return vElement.innerHTML.match(/^\s*$/); +} + + +/** + * Sets the textValue of the given DOM element. + * Wrapper for element.innerText and element.textContent. + * + * @param vElement {Element} DOM node + * @param sValue {string} + */ +qx.dom.Element.setTextContent = function(vElement, sValue) {}; + +if (qx.sys.Client.getInstance().supportsTextContent()) { + qx.dom.Element.setTextContent = function(vElement, sValue) { + vElement.textContent = sValue; + }; +} else if (qx.sys.Client.getInstance().supportsInnerText()) { + qx.dom.Element.setTextContent = function(vElement, sValue) { + vElement.innerText = sValue; + }; +} else { + qx.dom.Element.setTextContent = function(vElement, sValue) { + vElement.innerHTML = sValue; + }; +} diff --git a/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/dom/ElementFromPoint.js b/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/dom/ElementFromPoint.js new file mode 100644 index 0000000000..8d8e4c0fd3 --- /dev/null +++ b/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/dom/ElementFromPoint.js @@ -0,0 +1,122 @@ +/* ************************************************************************ + + qooxdoo - the new era of web development + + http://qooxdoo.org + + Copyright: + 2004-2006 by 1&1 Internet AG, Germany, http://www.1and1.org + + License: + LGPL 2.1: http://www.gnu.org/licenses/lgpl.html + + Authors: + * Sebastian Werner (wpbasti) + * Andreas Ecker (ecker) + +************************************************************************ */ + +/* ************************************************************************ + + +************************************************************************ */ + +qx.OO.defineClass("qx.dom.ElementFromPoint"); + +qx.dom.ElementFromPoint.getElementFromPoint = function(x, y) { + return qx.dom.ElementFromPoint.getElementFromPointHandler(document.body, x, y); +} + +qx.dom.ElementFromPoint.getElementFromPointHandler = function(node, x, y, recursive) +{ + var ch = node.childNodes; + var chl = ch.length-1; + + if (chl < 0) { + return null; + } + + var chc, subres, ret; + + do + { + chc = ch[chl]; + ret = qx.dom.ElementFromPoint.getElementFromPointChecker(chc, x, y); + + if (ret) + { + if (typeof recursive === "boolean" && recursive == false) + { + return chc; + } + else + { + subres = qx.dom.ElementFromPoint.getElementFromPointHandler(chc, x-ret[0]-qx.dom.Style.getBorderLeft(chc), y-ret[2]-qx.dom.Style.getBorderTop(chc)); + return subres ? subres : chc; + } + } + } + while(chl--); + + return null; +} + +qx.dom.ElementFromPoint.getElementFromPointChecker = function(chc, x, y) +{ + var xstart, ystart, xstop, ystop; + + if (chc.nodeType != 1) { + return false; + } + + xstart = qx.dom.Offset.getLeft(chc); + if (x > xstart) + { + ystart = qx.dom.Offset.getTop(chc); + if (y > ystart) + { + xstop = xstart + chc.offsetWidth; + + if (x < xstop) + { + ystop = ystart + chc.offsetHeight; + if (y < ystop) + { + return [ xstart, xstop, ystart, ystop ]; + } + } + } + } + + return false; +} + +qx.dom.ElementFromPoint.getElementAbsolutePointChecker = function(chc, x, y) +{ + var xstart, ystart, xstop, ystop; + + if (!chc || chc.nodeType != 1) { + return false; + } + + xstart = qx.dom.Location.getPageBoxLeft(chc); + if (x > xstart) + { + ystart = qx.dom.Location.getPageBoxTop(chc); + if (y > ystart) + { + xstop = xstart + chc.offsetWidth; + + if (x < xstop) + { + ystop = ystart + chc.offsetHeight; + if (y < ystop) + { + return [ xstart, xstop, ystart, ystop ]; + } + } + } + } + + return false; +} diff --git a/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/dom/EventRegistration.js b/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/dom/EventRegistration.js new file mode 100644 index 0000000000..9f42b2e1b6 --- /dev/null +++ b/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/dom/EventRegistration.js @@ -0,0 +1,47 @@ +/* ************************************************************************ + + qooxdoo - the new era of web development + + http://qooxdoo.org + + Copyright: + 2004-2006 by 1&1 Internet AG, Germany, http://www.1and1.org + + License: + LGPL 2.1: http://www.gnu.org/licenses/lgpl.html + + Authors: + * Sebastian Werner (wpbasti) + * Andreas Ecker (ecker) + +************************************************************************ */ + +/* ************************************************************************ + +#module(core) +#require(qx.sys.Client) + +************************************************************************ */ + +qx.OO.defineClass("qx.dom.EventRegistration"); + +if (qx.sys.Client.getInstance().isMshtml()) +{ + qx.dom.EventRegistration.addEventListener = function(vElement, vType, vFunction) { + vElement.attachEvent("on" + vType, vFunction); + } + + qx.dom.EventRegistration.removeEventListener = function(vElement, vType, vFunction) { + vElement.detachEvent("on" + vType, vFunction); + } +} +else +{ + qx.dom.EventRegistration.addEventListener = function(vElement, vType, vFunction) { + vElement.addEventListener(vType, vFunction, false); + } + + qx.dom.EventRegistration.removeEventListener = function(vElement, vType, vFunction) { + vElement.removeEventListener(vType, vFunction, false); + } +} diff --git a/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/dom/Iframe.js b/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/dom/Iframe.js new file mode 100644 index 0000000000..51cd67346a --- /dev/null +++ b/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/dom/Iframe.js @@ -0,0 +1,87 @@ +/* ************************************************************************ + + qooxdoo - the new era of web development + + http://qooxdoo.org + + Copyright: + 2004-2006 by 1&1 Internet AG, Germany, http://www.1and1.org + + License: + LGPL 2.1: http://www.gnu.org/licenses/lgpl.html + + Authors: + * Sebastian Werner (wpbasti) + * Andreas Ecker (ecker) + +************************************************************************ */ + +/* ************************************************************************ + +#module(io_remote) +#require(qx.sys.Client) + +************************************************************************ */ + +qx.OO.defineClass("qx.dom.Iframe"); + +if (qx.sys.Client.getInstance().isMshtml()) +{ + qx.dom.Iframe.getWindow = function(vIframe) + { + try + { + return vIframe.contentWindow; + } + catch(ex) + { + return null; + } + } + + qx.dom.Iframe.getDocument = function(vIframe) + { + try + { + var vWin = qx.dom.Iframe.getWindow(vIframe); + return vWin ? vWin.document : null; + } + catch(ex) + { + return null; + } + } +} +else +{ + qx.dom.Iframe.getWindow = function(vIframe) + { + try + { + var vDoc = qx.dom.Iframe.getDocument(vIframe); + return vDoc ? vDoc.defaultView : null; + } + catch(ex) + { + return null; + } + } + + qx.dom.Iframe.getDocument = function(vIframe) + { + try + { + return vIframe.contentDocument; + } + catch(ex) + { + return null; + } + } +} + +qx.dom.Iframe.getBody = function(vIframe) +{ + var vDoc = qx.dom.Iframe.getDocument(vIframe); + return vDoc ? vDoc.getElementsByTagName("body")[0] : null; +} diff --git a/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/dom/Location.js b/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/dom/Location.js new file mode 100644 index 0000000000..479a3aaba8 --- /dev/null +++ b/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/dom/Location.js @@ -0,0 +1,259 @@ +/* ************************************************************************ + + qooxdoo - the new era of web development + + http://qooxdoo.org + + Copyright: + 2004-2006 by 1&1 Internet AG, Germany, http://www.1and1.org + + License: + LGPL 2.1: http://www.gnu.org/licenses/lgpl.html + + Authors: + * Sebastian Werner (wpbasti) + * Andreas Ecker (ecker) + +************************************************************************ */ + +/* ************************************************************************ + +#module(ui_core) +#require(qx.sys.Client) + +************************************************************************ */ + +qx.OO.defineClass("qx.dom.Location"); + +qx.dom.Location.getPageOuterLeft = function(el) { return qx.dom.Location.getPageBoxLeft(el) - qx.dom.Style.getMarginLeft(el); } +qx.dom.Location.getPageOuterTop = function(el) { return qx.dom.Location.getPageBoxTop(el) - qx.dom.Style.getMarginTop(el); } +qx.dom.Location.getPageOuterRight = function(el) { return qx.dom.Location.getPageBoxRight(el) + qx.dom.Style.getMarginRight(el); } +qx.dom.Location.getPageOuterBottom = function(el) { return qx.dom.Location.getPageBoxBottom(el) + qx.dom.Style.getMarginBottom(el); } + +qx.dom.Location.getClientOuterLeft = function(el) { return qx.dom.Location.getClientBoxLeft(el) - qx.dom.Style.getMarginLeft(el); } +qx.dom.Location.getClientOuterTop = function(el) { return qx.dom.Location.getClientBoxTop(el) - qx.dom.Style.getMarginTop(el); } +qx.dom.Location.getClientOuterRight = function(el) { return qx.dom.Location.getClientBoxRight(el) + qx.dom.Style.getMarginRight(el); } +qx.dom.Location.getClientOuterBottom = function(el) { return qx.dom.Location.getClientBoxBottom(el) + qx.dom.Style.getMarginBottom(el); } + + +if (qx.sys.Client.getInstance().isMshtml()) +{ + qx.dom.Location.getClientBoxLeft = function(el) { return el.getBoundingClientRect().left; } + qx.dom.Location.getClientBoxTop = function(el) { return el.getBoundingClientRect().top; } + + qx.dom.Location.getPageBoxLeft = function(el) { return qx.dom.Location.getClientBoxLeft(el) + qx.dom.Scroll.getLeftSum(el); } + qx.dom.Location.getPageBoxTop = function(el) { return qx.dom.Location.getClientBoxTop(el) + qx.dom.Scroll.getTopSum(el); } +} +else if (qx.sys.Client.getInstance().isGecko()) +{ + qx.dom.Location.getClientBoxLeft = function(el) { return qx.dom.Location.getClientAreaLeft(el) - qx.dom.Style.getBorderLeft(el); } + qx.dom.Location.getClientBoxTop = function(el) { return qx.dom.Location.getClientAreaTop(el) - qx.dom.Style.getBorderTop(el); } + + qx.dom.Location.getPageBoxLeft = function(el) { return qx.dom.Location.getPageAreaLeft(el) - qx.dom.Style.getBorderLeft(el); } + qx.dom.Location.getPageBoxTop = function(el) { return qx.dom.Location.getPageAreaTop(el) - qx.dom.Style.getBorderTop(el); } +} +else +{ + qx.dom.Location.getPageBoxLeft = function(el) + { + var sum = el.offsetLeft; + while (el.tagName.toLowerCase() != "body") + { + el = el.offsetParent; + sum += el.offsetLeft; + } + + return sum; + } + + qx.dom.Location.getPageBoxTop = function(el) + { + var sum = el.offsetTop; + while (el.tagName.toLowerCase() != "body") + { + el = el.offsetParent; + sum += el.offsetTop; + } + + return sum; + } + + qx.dom.Location.getClientBoxLeft = function(el) + { + var sum = el.offsetLeft; + while (el.tagName.toLowerCase() != "body") + { + el = el.offsetParent; + sum += el.offsetLeft - el.scrollLeft; + } + + return sum; + } + + qx.dom.Location.getClientBoxTop = function(el) + { + var sum = el.offsetTop; + while (el.tagName.toLowerCase() != "body") + { + el = el.offsetParent; + sum += el.offsetTop - el.scrollTop; + } + + return sum; + } +} + +if (qx.sys.Client.getInstance().isMshtml()) +{ + qx.dom.Location.getClientBoxRight = function(el) { return el.getBoundingClientRect().right; } + qx.dom.Location.getClientBoxBottom = function(el) { return el.getBoundingClientRect().bottom; } + + qx.dom.Location.getPageBoxRight = function(el) { return qx.dom.Location.getClientBoxRight(el) + qx.dom.Scroll.getLeftSum(el); } + qx.dom.Location.getPageBoxBottom = function(el) { return qx.dom.Location.getClientBoxBottom(el) + qx.dom.Scroll.getTopSum(el); } +} +else +{ + qx.dom.Location.getClientBoxRight = function(el) { return qx.dom.Location.getClientBoxLeft(el) + qx.dom.Dimension.getBoxWidth(el); } + qx.dom.Location.getClientBoxBottom = function(el) { return qx.dom.Location.getClientBoxTop(el) + qx.dom.Dimension.getBoxHeight(el); } + + qx.dom.Location.getPageBoxRight = function(el) { return qx.dom.Location.getPageBoxLeft(el) + qx.dom.Dimension.getBoxWidth(el); } + qx.dom.Location.getPageBoxBottom = function(el) { return qx.dom.Location.getPageBoxTop(el) + qx.dom.Dimension.getBoxHeight(el); } +} + +if (qx.sys.Client.getInstance().isGecko()) +{ + qx.dom.Location.getPageAreaLeft = function(el) { + return el.ownerDocument.getBoxObjectFor(el).x; + } + + qx.dom.Location.getPageAreaTop = function(el) { + return el.ownerDocument.getBoxObjectFor(el).y; + } + + // We need to subtract the scroll position of all parent containers (bug #186229). + qx.dom.Location.getClientAreaLeft = function(el) { + return qx.dom.Location.getPageAreaLeft(el) - qx.dom.Scroll.getLeftSum(el); + } + + // We need to subtract the scroll position of all parent containers (bug #186229). + qx.dom.Location.getClientAreaTop = function(el) { + return qx.dom.Location.getPageAreaTop(el) - qx.dom.Scroll.getTopSum(el); + } +} +else +{ + qx.dom.Location.getClientAreaLeft = function(el) { return qx.dom.Location.getClientBoxLeft(el) + qx.dom.Style.getBorderLeft(el); } + qx.dom.Location.getClientAreaTop = function(el) { return qx.dom.Location.getClientBoxTop(el) + qx.dom.Style.getBorderTop(el); } + + qx.dom.Location.getPageAreaLeft = function(el) { return qx.dom.Location.getPageBoxLeft(el) + qx.dom.Style.getBorderLeft(el); } + qx.dom.Location.getPageAreaTop = function(el) { return qx.dom.Location.getPageBoxTop(el) + qx.dom.Style.getBorderTop(el); } +} + + + +qx.dom.Location.getClientAreaRight = function(el) { return qx.dom.Location.getClientAreaLeft(el) + qx.dom.Dimension.getAreaWidth(el); } +qx.dom.Location.getClientAreaBottom = function(el) { return qx.dom.Location.getClientAreaTop(el) + qx.dom.Dimension.getAreaHeight(el); } + +qx.dom.Location.getPageAreaRight = function(el) { return qx.dom.Location.getPageAreaLeft(el) + qx.dom.Dimension.getAreaWidth(el); } +qx.dom.Location.getPageAreaBottom = function(el) { return qx.dom.Location.getPageAreaTop(el) + qx.dom.Dimension.getAreaHeight(el); } + + + + +qx.dom.Location.getClientInnerLeft = function(el) { return qx.dom.Location.getClientAreaLeft(el) + qx.dom.Style.getPaddingLeft(el); } +qx.dom.Location.getClientInnerTop = function(el) { return qx.dom.Location.getClientAreaTop(el) + qx.dom.Style.getPaddingTop(el); } +qx.dom.Location.getClientInnerRight = function(el) { return qx.dom.Location.getClientInnerLeft(el) + qx.dom.Dimension.getInnerWidth(el); } +qx.dom.Location.getClientInnerBottom = function(el) { return qx.dom.Location.getClientInnerTop(el) + qx.dom.Dimension.getInnerHeight(el); } + +qx.dom.Location.getPageInnerLeft = function(el) { return qx.dom.Location.getPageAreaLeft(el) + qx.dom.Style.getPaddingLeft(el); } +qx.dom.Location.getPageInnerTop = function(el) { return qx.dom.Location.getPageAreaTop(el) + qx.dom.Style.getPaddingTop(el); } +qx.dom.Location.getPageInnerRight = function(el) { return qx.dom.Location.getPageInnerLeft(el) + qx.dom.Dimension.getInnerWidth(el); } +qx.dom.Location.getPageInnerBottom = function(el) { return qx.dom.Location.getPageInnerTop(el) + qx.dom.Dimension.getInnerHeight(el); } + + +// Screen +if (qx.sys.Client.getInstance().isGecko()) +{ + /* + screenX and screenY seem to return the distance to the box + and not to the area. Confusing, especially as the x and y properties + of the BoxObject return the distance to the area. + */ + + qx.dom.Location.getScreenBoxLeft = function(el) + { + // We need to subtract the scroll position of all + // parent containers (bug #186229). + var sum = 0; + var p = el.parentNode; + while (p.nodeType == 1) { + sum += p.scrollLeft; + p = p.parentNode; + } + + return el.ownerDocument.getBoxObjectFor(el).screenX - sum; + } + + qx.dom.Location.getScreenBoxTop = function(el) + { + // We need to subtract the scroll position of all + // parent containers (bug #186229). + var sum = 0; + var p = el.parentNode; + while (p.nodeType == 1) { + sum += p.scrollTop; + p = p.parentNode; + } + + return el.ownerDocument.getBoxObjectFor(el).screenY - sum; + } +} +else +{ + // Hope this works in khtml, too (opera 7.6p3 seems to be ok) + qx.dom.Location.getScreenBoxLeft = function(el) { return qx.dom.Location.getScreenDocumentLeft(el) + qx.dom.Location.getPageBoxLeft(el); } + qx.dom.Location.getScreenBoxTop = function(el) { return qx.dom.Location.getScreenDocumentTop(el) + qx.dom.Location.getPageBoxTop(el); } +} + +qx.dom.Location.getScreenBoxRight = function(el) { return qx.dom.Location.getScreenBoxLeft(el) + qx.dom.Dimension.getBoxWidth(el); } +qx.dom.Location.getScreenBoxBottom = function(el) { return qx.dom.Location.getScreenBoxTop(el) + qx.dom.Dimension.getBoxHeight(el); } + +qx.dom.Location.getScreenOuterLeft = function(el) { return qx.dom.Location.getScreenBoxLeft(el) - qx.dom.Style.getMarginLeft(el); } +qx.dom.Location.getScreenOuterTop = function(el) { return qx.dom.Location.getScreenBoxTop(el) - qx.dom.Style.getMarginTop(el); } +qx.dom.Location.getScreenOuterRight = function(el) { return qx.dom.Location.getScreenBoxRight(el) + qx.dom.Style.getMarginRight(el); } +qx.dom.Location.getScreenOuterBottom = function(el) { return qx.dom.Location.getScreenBoxBottom(el) + qx.dom.Style.getMarginBottom(el); } + +qx.dom.Location.getScreenAreaLeft = function(el) { return qx.dom.Location.getScreenBoxLeft(el) + qx.dom.Dimension.getInsetLeft(el); } +qx.dom.Location.getScreenAreaTop = function(el) { return qx.dom.Location.getScreenBoxTop(el) + qx.dom.Dimension.getInsetTop(el); } +qx.dom.Location.getScreenAreaRight = function(el) { return qx.dom.Location.getScreenBoxRight(el) - qx.dom.Dimension.getInsetRight(el); } +qx.dom.Location.getScreenAreaBottom = function(el) { return qx.dom.Location.getScreenBoxBottom(el) - qx.dom.Dimension.getInsetBottom(el); } + +qx.dom.Location.getScreenInnerLeft = function(el) { return qx.dom.Location.getScreenAreaLeft(el) + qx.dom.Style.getPaddingLeft(el); } +qx.dom.Location.getScreenInnerTop = function(el) { return qx.dom.Location.getScreenAreaTop(el) + qx.dom.Style.getPaddingTop(el); } +qx.dom.Location.getScreenInnerRight = function(el) { return qx.dom.Location.getScreenAreaRight(el) - qx.dom.Style.getPaddingRight(el); } +qx.dom.Location.getScreenInnerBottom = function(el) { return qx.dom.Location.getScreenAreaBottom(el) - qx.dom.Style.getPaddingBottom(el); } + + +if (qx.sys.Client.getInstance().isGecko()) +{ + /* + Notice: + This doesn't work like the mshtml method: + el.ownerDocument.defaultView.screenX; + */ + + // Tested in Gecko 1.7.5 + qx.dom.Location.getScreenDocumentLeft = function(el) { return qx.dom.Location.getScreenOuterLeft(el.ownerDocument.body); } + qx.dom.Location.getScreenDocumentTop = function(el) { return qx.dom.Location.getScreenOuterTop(el.ownerDocument.body); } + qx.dom.Location.getScreenDocumentRight = function(el) { return qx.dom.Location.getScreenOuterRight(el.ownerDocument.body); } + qx.dom.Location.getScreenDocumentBottom = function(el) { return qx.dom.Location.getScreenOuterBottom(el.ownerDocument.body); } +} +else +{ + // Tested in Opera 7.6b3 and Mshtml 6.0 (XP-SP2) + // What's up with khtml (Safari/Konq)? + qx.dom.Location.getScreenDocumentLeft = function(el) { return el.document.parentWindow.screenLeft; } + qx.dom.Location.getScreenDocumentTop = function(el) { return el.document.parentWindow.screenTop; } + qx.dom.Location.getScreenDocumentRight = function(el) {} + qx.dom.Location.getScreenDocumentBottom = function(el) {} +} diff --git a/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/dom/Node.js b/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/dom/Node.js new file mode 100644 index 0000000000..c4b02ea16e --- /dev/null +++ b/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/dom/Node.js @@ -0,0 +1,38 @@ +/* ************************************************************************ + + qooxdoo - the new era of web development + + http://qooxdoo.org + + Copyright: + 2004-2006 by 1&1 Internet AG, Germany, http://www.1and1.org + + License: + LGPL 2.1: http://www.gnu.org/licenses/lgpl.html + + Authors: + * Sebastian Werner (wpbasti) + * Andreas Ecker (ecker) + +************************************************************************ */ + +/* ************************************************************************ + + +************************************************************************ */ + +qx.OO.defineClass("qx.dom.Node", +{ + ELEMENT : 1, + ATTRIBUTE : 2, + TEXT : 3, + CDATA_SECTION : 4, + ENTITY_REFERENCE : 5, + ENTITY : 6, + PROCESSING_INSTRUCTION : 7, + COMMENT : 8, + DOCUMENT : 9, + DOCUMENT_TYPE : 10, + DOCUMENT_FRAGMENT : 11, + NOTATION : 12 +}); diff --git a/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/dom/Offset.js b/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/dom/Offset.js new file mode 100644 index 0000000000..74e653b279 --- /dev/null +++ b/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/dom/Offset.js @@ -0,0 +1,119 @@ +/* ************************************************************************ + + qooxdoo - the new era of web development + + http://qooxdoo.org + + Copyright: + 2004-2006 by 1&1 Internet AG, Germany, http://www.1and1.org + + License: + LGPL 2.1: http://www.gnu.org/licenses/lgpl.html + + Authors: + * Sebastian Werner (wpbasti) + * Andreas Ecker (ecker) + +************************************************************************ */ + +/* ************************************************************************ + +#module(ui_core) +#require(qx.sys.Client) + +************************************************************************ */ + +qx.OO.defineClass("qx.dom.Offset"); + +/* +Mozilla seems to be a little buggy here. +Mozilla/5.0 (Windows; U; Windows NT 5.1; de-DE; rv:1.7.5) Gecko/20041108 Firefox/1.0 + +It calculates some borders and/or paddings to the offsetProperties. +*/ +if (qx.sys.Client.getInstance().isGecko()) +{ + qx.dom.Offset.getLeft = function(el) + { + var val = el.offsetLeft; + var pa = el.parentNode; + + var pose = qx.dom.Style.getStyleProperty(el, "position"); + var posp = qx.dom.Style.getStyleProperty(pa, "position"); + + // If element is positioned non-static: Substract the border of the element + if (pose != "absolute" && pose != "fixed") { + val -= qx.dom.Style.getBorderLeft(pa); + } + + // If parent is positioned static: Substract the border of the first + // parent element which is ab positioned non-static. + if (posp != "absolute" && posp != "fixed") + { + while(pa) + { + pa = pa.parentNode; + + if (!pa || qx.util.Validation.isInvalidString(pa.tagName)) { + break; + } + + var posi = qx.dom.Style.getStyleProperty(pa, "position"); + + if (posi == "absolute" || posi == "fixed") { + val -= qx.dom.Style.getBorderLeft(pa) + qx.dom.Style.getPaddingLeft(pa); + break; + } + } + } + + return val; + } + + qx.dom.Offset.getTop = function(el) + { + var val = el.offsetTop; + var pa = el.parentNode; + + var pose = qx.dom.Style.getStyleProperty(el, "position"); + var posp = qx.dom.Style.getStyleProperty(pa, "position"); + + // If element is positioned non-static: Substract the border of the element + if (pose != "absolute" && pose != "fixed") { + val -= qx.dom.Style.getBorderTop(pa); + } + + // If parent is positioned static: Substract the border of the first + // parent element which is ab positioned non-static. + if (posp != "absolute" && posp != "fixed") + { + while(pa) + { + pa = pa.parentNode; + + if (!pa || qx.util.Validation.isInvalidString(pa.tagName)) { + break; + } + + var posi = qx.dom.Style.getStyleProperty(pa, "position"); + + if (posi == "absolute" || posi == "fixed") { + val -= qx.dom.Style.getBorderTop(pa) + qx.dom.Style.getPaddingTop(pa); + break; + } + } + } + + return val; + } +} +else +{ + qx.dom.Offset.getLeft = function(el) { + return el.offsetLeft; + } + + qx.dom.Offset.getTop = function(el) { + return el.offsetTop; + } +} diff --git a/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/dom/Scroll.js b/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/dom/Scroll.js new file mode 100644 index 0000000000..5c3808489d --- /dev/null +++ b/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/dom/Scroll.js @@ -0,0 +1,53 @@ +/* ************************************************************************ + + qooxdoo - the new era of web development + + http://qooxdoo.org + + Copyright: + 2004-2006 by 1&1 Internet AG, Germany, http://www.1and1.org + + License: + LGPL 2.1: http://www.gnu.org/licenses/lgpl.html + + Authors: + * Sebastian Werner (wpbasti) + * Andreas Ecker (ecker) + +************************************************************************ */ + +/* ************************************************************************ + +#module(ui_core) + +************************************************************************ */ + +qx.OO.defineClass("qx.dom.Scroll"); + +qx.dom.Scroll.getLeftSum = function(el) +{ + var sum = 0; + var p = el.parentNode; + + while (p.nodeType == 1) + { + sum += p.scrollLeft; + p = p.parentNode; + } + + return sum; +} + +qx.dom.Scroll.getTopSum = function(el) +{ + var sum = 0; + var p = el.parentNode; + + while (p.nodeType == 1) + { + sum += p.scrollTop; + p = p.parentNode; + } + + return sum; +} diff --git a/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/dom/ScrollIntoView.js b/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/dom/ScrollIntoView.js new file mode 100644 index 0000000000..d045524d29 --- /dev/null +++ b/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/dom/ScrollIntoView.js @@ -0,0 +1,175 @@ +/* ************************************************************************ + + qooxdoo - the new era of web development + + http://qooxdoo.org + + Copyright: + 2004-2006 by 1&1 Internet AG, Germany, http://www.1and1.org + + License: + LGPL 2.1: http://www.gnu.org/licenses/lgpl.html + + Authors: + * Sebastian Werner (wpbasti) + * Andreas Ecker (ecker) + +************************************************************************ */ + +/* ************************************************************************ + +#module(ui_core) +#require(qx.dom.Style) + +************************************************************************ */ + +qx.OO.defineClass("qx.dom.ScrollIntoView"); + +// Internet Explorer has invented scrollIntoView, but does not behave the same like in Mozilla (which would be better) +// Mozilla has a native well working method scrollIntoView +// Safari does not support scrollIntoView (but it can be found in Webkit since May 2005) +// Opera does not support scrollIntoView + +qx.dom.BODY_TAG_NAME = "body"; + +qx.dom.ScrollIntoView.scrollX = function(vElement, vAlignLeft) +{ + var vParentWidth, vParentScrollLeft, vWidth, vHasScroll; + + var vParent = vElement.parentNode; + var vOffset = vElement.offsetLeft; + var vWidth = vElement.offsetWidth; + + while(vParent) + { + switch(qx.dom.Style.getStyleProperty(vParent, "overflow")) + { + case "scroll": + case "auto": + case "-moz-scrollbars-horizontal": + vHasScroll = true; + break; + + default: + switch(qx.dom.Style.getStyleProperty(vParent, "overflowX")) + { + case "scroll": + case "auto": + vHasScroll = true; + break; + + default: + vHasScroll = false; + } + } + + if (vHasScroll) + { + vParentWidth = vParent.clientWidth; + vParentScrollLeft = vParent.scrollLeft; + + if (vAlignLeft) + { + vParent.scrollLeft = vOffset; + } + else if (vAlignLeft == false) + { + vParent.scrollLeft = vOffset + vWidth - vParentWidth; + } + else if (vWidth > vParentWidth || vOffset < vParentScrollLeft) + { + vParent.scrollLeft = vOffset; + } + else if ((vOffset + vWidth) > (vParentScrollLeft + vParentWidth)) + { + vParent.scrollLeft = vOffset + vWidth - vParentWidth; + } + + vOffset = vParent.offsetLeft; + vWidth = vParent.offsetWidth; + } + else + { + vOffset += vParent.offsetLeft; + } + + if (vParent.tagName.toLowerCase() == qx.dom.BODY_TAG_NAME) { + break; + } + + vParent = vParent.parentNode; + } + + return true; +} + +qx.dom.ScrollIntoView.scrollY = function(vElement, vAlignTop) +{ + var vParentHeight, vParentScrollTop, vHeight, vHasScroll; + + var vParent = vElement.parentNode; + var vOffset = vElement.offsetTop; + var vHeight = vElement.offsetHeight; + + while(vParent) + { + switch(qx.dom.Style.getStyleProperty(vParent, "overflow")) + { + case "scroll": + case "auto": + case "-moz-scrollbars-vertical": + vHasScroll = true; + break; + + default: + switch(qx.dom.Style.getStyleProperty(vParent, "overflowY")) + { + case "scroll": + case "auto": + vHasScroll = true; + break; + + default: + vHasScroll = false; + } + } + + if (vHasScroll) + { + vParentHeight = vParent.clientHeight; + vParentScrollTop = vParent.scrollTop; + + if (vAlignTop) + { + vParent.scrollTop = vOffset; + } + else if (vAlignTop == false) + { + vParent.scrollTop = vOffset + vHeight - vParentHeight; + } + else if (vHeight > vParentHeight || vOffset < vParentScrollTop) + { + vParent.scrollTop = vOffset; + } + else if ((vOffset + vHeight) > (vParentScrollTop + vParentHeight)) + { + vParent.scrollTop = vOffset + vHeight - vParentHeight; + } + + vOffset = vParent.offsetTop; + vHeight = vParent.offsetHeight; + } + else + { + vOffset += vParent.offsetTop; + } + + if (vParent.tagName.toLowerCase() == qx.dom.BODY_TAG_NAME) { + break; + } + + vParent = vParent.parentNode; + } + + return true; +} diff --git a/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/dom/Style.js b/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/dom/Style.js new file mode 100644 index 0000000000..b003f0e18a --- /dev/null +++ b/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/dom/Style.js @@ -0,0 +1,122 @@ +/* ************************************************************************ + + qooxdoo - the new era of web development + + http://qooxdoo.org + + Copyright: + 2004-2006 by 1&1 Internet AG, Germany, http://www.1and1.org + + License: + LGPL 2.1: http://www.gnu.org/licenses/lgpl.html + + Authors: + * Sebastian Werner (wpbasti) + * Andreas Ecker (ecker) + +************************************************************************ */ + +/* ************************************************************************ + +#module(ui_core) +#require(qx.sys.Client) + +************************************************************************ */ + +qx.OO.defineClass("qx.dom.Style"); + +if (Boolean(document.defaultView) && Boolean(document.defaultView.getComputedStyle)) +{ + qx.dom.Style.getStylePropertySure = function(el, prop) { return !el ? null : el.ownerDocument ? el.ownerDocument.defaultView.getComputedStyle(el, "")[prop] : el.style[prop]; } + + qx.dom.Style.getStyleProperty = function(el, prop) + { + try + { + return el.ownerDocument.defaultView.getComputedStyle(el, "")[prop]; + } + catch(ex) + { + throw new Error("Could not evaluate computed style: " + el + "[" + prop + "]: " + ex); + } + } +} +else if (qx.sys.Client.getInstance().isMshtml()) +{ + qx.dom.Style.getStyleProperty = function(el, prop) + { + try + { + return el.currentStyle[prop]; + } + catch(ex) + { + throw new Error("Could not evaluate computed style: " + el + "[" + prop + "]: " + ex); + } + } + + qx.dom.Style.getStylePropertySure = function(el, prop) + { + try + { + if (!el) { + return null; + } + + if (el.parentNode && el.currentStyle) + { + return el.currentStyle[prop]; + } + else + { + var v1 = el.runtimeStyle[prop]; + + if (v1 != null && typeof v1 != "undefined" && v1 != "") { + return v1; + } + + return el.style[prop]; + } + } + catch(ex) + { + throw new Error("Could not evaluate computed style: " + el + "[" + prop + "]: " + ex); + } + } +} +else +{ + qx.dom.Style.getStylePropertySure = function(el, prop) { return !el ? null : el.style[prop]; } + + qx.dom.Style.getStyleProperty = function(el, prop) + { + try + { + return el.style[prop]; + } + catch(ex) + { + throw new Error("Could not evaluate computed style: " + el + "[" + prop + "]"); + } + } +} + + +qx.dom.Style.getStyleSize = function(el, prop) { return parseInt(qx.dom.Style.getStyleProperty(el, prop)) || 0; } + + +// Properties +qx.dom.Style.getMarginLeft = function(el) { return qx.dom.Style.getStyleSize(el, "marginLeft"); } +qx.dom.Style.getMarginTop = function(el) { return qx.dom.Style.getStyleSize(el, "marginTop"); } +qx.dom.Style.getMarginRight = function(el) { return qx.dom.Style.getStyleSize(el, "marginRight"); } +qx.dom.Style.getMarginBottom = function(el) { return qx.dom.Style.getStyleSize(el, "marginBottom"); } + +qx.dom.Style.getPaddingLeft = function(el) { return qx.dom.Style.getStyleSize(el, "paddingLeft"); } +qx.dom.Style.getPaddingTop = function(el) { return qx.dom.Style.getStyleSize(el, "paddingTop"); } +qx.dom.Style.getPaddingRight = function(el) { return qx.dom.Style.getStyleSize(el, "paddingRight"); } +qx.dom.Style.getPaddingBottom = function(el) { return qx.dom.Style.getStyleSize(el, "paddingBottom"); } + +qx.dom.Style.getBorderLeft = function(el) { return qx.dom.Style.getStyleProperty(el, "borderLeftStyle") == "none" ? 0 : qx.dom.Style.getStyleSize(el, "borderLeftWidth"); } +qx.dom.Style.getBorderTop = function(el) { return qx.dom.Style.getStyleProperty(el, "borderTopStyle") == "none" ? 0 : qx.dom.Style.getStyleSize(el, "borderTopWidth"); } +qx.dom.Style.getBorderRight = function(el) { return qx.dom.Style.getStyleProperty(el, "borderRightStyle") == "none" ? 0 : qx.dom.Style.getStyleSize(el, "borderRightWidth"); } +qx.dom.Style.getBorderBottom = function(el) { return qx.dom.Style.getStyleProperty(el, "borderBottomStyle") == "none" ? 0 : qx.dom.Style.getStyleSize(el, "borderBottomWidth"); } diff --git a/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/dom/StyleSheet.js b/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/dom/StyleSheet.js new file mode 100644 index 0000000000..be51ad58be --- /dev/null +++ b/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/dom/StyleSheet.js @@ -0,0 +1,308 @@ +/* ************************************************************************ + + qooxdoo - the new era of web development + + http://qooxdoo.org + + Copyright: + 2004-2006 by 1&1 Internet AG, Germany, http://www.1and1.org + 2006 by STZ-IDA, Germany, http://www.stz-ida.de + + License: + LGPL 2.1: http://www.gnu.org/licenses/lgpl.html + + Authors: + * Sebastian Werner (wpbasti) + * Andreas Ecker (ecker) + * Andreas Junghans (lucidcake) + +************************************************************************ */ + +/* ************************************************************************ + +#module(ui_core) +#require(qx.sys.Client) + +************************************************************************ */ + +qx.OO.defineClass("qx.dom.StyleSheet"); + + +/** + * create a new Stylesheet node and append it to the document + * + * @param vCssText {string} optional string of css rules + */ +qx.dom.StyleSheet.createElement = function(vCssText) {}; +if (document.createStyleSheet) // IE 4+ +{ + qx.dom.StyleSheet.createElement = function(vCssText) + { + var vSheet = document.createStyleSheet(); + + if (vCssText) { + vSheet.cssText = vCssText; + } + + return vSheet; + } +} +else // FF, Opera, Safari +{ + qx.dom.StyleSheet.createElement = function(vCssText) + { + var vElement = document.createElement("style"); + vElement.type = "text/css"; + + // Safari 2.0 doesn't like empty stylesheets + vElement.appendChild(document.createTextNode(vCssText || "body {}")); + + document.getElementsByTagName("head")[0].appendChild(vElement); + + if (vElement.sheet) { + return vElement.sheet; + } else { + // Safari 2.0 doesn't support element.sheet so we neet a workaround + var styles = document.styleSheets; + for (var i=styles.length-1; i>=0; i--) { + if (styles[i].ownerNode == vElement) { + return styles[i]; + } + } + } + throw "Error: Could not get a reference to the sheet object"; + } +} + + +/** + * insert a new CSS rule into a given Stylesheet + * + * @param vSheet {Object} the target Stylesheet object + * @param vSelector {string} + * @param vStyle {string} + */ +qx.dom.StyleSheet.addRule = function(vSheet, vSelector, vStyle) {}; +if (document.createStyleSheet) // IE 4+ +{ + qx.dom.StyleSheet.addRule = function(vSheet, vSelector, vStyle) { + vSheet.addRule(vSelector, vStyle); + }; +} +else if (qx.sys.Client.getInstance().isSafari2()) // insertRule in Safari 2 doesn't work +{ + qx.dom.StyleSheet.addRule = function(vSheet, vSelector, vStyle) { + if (!vSheet._qxRules) { + vSheet._qxRules = {}; + } + if (!vSheet._qxRules[vSelector]) { + var ruleNode = document.createTextNode(vSelector + "{" + vStyle + "}"); + vSheet.ownerNode.appendChild(ruleNode); + vSheet._qxRules[vSelector] = ruleNode; + } + }; +} +else // FF, Opera +{ + qx.dom.StyleSheet.addRule = function(vSheet, vSelector, vStyle) { + vSheet.insertRule(vSelector + "{" + vStyle + "}", vSheet.cssRules.length); + }; +} + + +/** + * remove a CSS rule from a stylesheet + * + * @param vSheet {Object} the Stylesheet + * @param vSelector {string} the Selector of the rule to remove + */ +qx.dom.StyleSheet.removeRule = function(vSheet, vSelector) {}; +if (document.createStyleSheet) // IE 4+ +{ + qx.dom.StyleSheet.removeRule = function(vSheet, vSelector) + { + var vRules = vSheet.rules; + var vLength = vRules.length; + + for (var i=vLength-1; i>=0; i--) + { + if (vRules[i].selectorText == vSelector) { + vSheet.removeRule(i); + } + } + } +} +else if (qx.sys.Client.getInstance().isSafari2()) // removeRule in Safari 2 doesn't work +{ + qx.dom.StyleSheet.removeRule = function(vSheet, vSelector) + { + var warn = function() { + qx.dev.log.Logger.ROOT_LOGGER.warn("In Safari/Webkit you can only remove rules that are created using qx.dom.StyleSheet.addRule"); + } + if (!vSheet._qxRules) { + warn(); + } + var ruleNode = vSheet._qxRules[vSelector]; + if (ruleNode) { + vSheet.ownerNode.removeChild(ruleNode); + vSheet._qxRules[vSelector] = null; + } else { + warn(); + } + } +} +else +{ + qx.dom.StyleSheet.removeRule = function(vSheet, vSelector) + { + var vRules = vSheet.cssRules; + var vLength = vRules.length; + + for (var i=vLength-1; i>=0; i--) + { + if (vRules[i].selectorText == vSelector) { + vSheet.deleteRule(i); + } + } + } +} + + +/** + * remove all CSS rules from a stylesheet + * + * @param vSheet {Object} + */ +qx.dom.StyleSheet.removeAllRules = function(vSheet) {}; +if (document.createStyleSheet) // IE 4+ +{ + qx.dom.StyleSheet.removeAllRules = function(vSheet) + { + var vRules = vSheet.rules; + var vLength = vRules.length; + + for (var i=vLength-1; i>=0; i--) { + vSheet.removeRule(i); + } + } +} +else if (qx.sys.Client.getInstance().isSafari2()) // removeRule in Safari 2 doesn't work +{ + qx.dom.StyleSheet.removeAllRules = function(vSheet) + { + var node = vSheet.ownerNode; + var rules = node.childNodes; + while (rules.length > 0) { + node.removeChild(rules[0]); + } + } +} +else // FF, etc +{ + qx.dom.StyleSheet.removeAllRules = function(vSheet) + { + var vRules = vSheet.cssRules; + var vLength = vRules.length; + + for (var i=vLength-1; i>=0; i--) { + vSheet.deleteRule(i); + } + } +} + + + +// TODO import functions are not working crossbrowser (Safari) !! +// see CSS_1.html test + +/** + * add an import of an external CSS file to a stylesheet + * @param vSheet {Object} + * @param vUrl {string} + */ +qx.dom.StyleSheet.addImport = function(vSheet, vUrl) {}; +if (document.createStyleSheet) // IE 4+ +{ + qx.dom.StyleSheet.addImport = function(vSheet, vUrl) { + vSheet.addImport(vUrl); + } +} +else if (qx.sys.Client.getInstance().isSafari2()) // insertRule in Safari 2 doesn't work +{ + qx.dom.StyleSheet.addImport = function(vSheet, vUrl) { + vSheet.ownerNode.appendChild(document.createTextNode('@import "' + vUrl + '";')); + } +} +else // FF, etc +{ + qx.dom.StyleSheet.addImport = function(vSheet, vUrl) { + vSheet.insertRule('@import "' + vUrl + '";', vSheet.cssRules.length); + } +} + + +/** + * removes an import from a stylesheet + * + * @param vSheet {Object} + * @param vUrl {string} URL of the importet CSS file + */ +qx.dom.StyleSheet.removeImport = function(vSheet, vUrl) {}; +if (document.createStyleSheet) // IE 4+ +{ + qx.dom.StyleSheet.removeImport = function(vSheet, vUrl) { + var vImports = vSheet.imports; + var vLength = vImports.length; + + for (var i=vLength-1; i>=0; i--) { + if (vImports[i].href == vUrl) { + vSheet.removeImport(i); + } + } + } +} +else // FF, etc +{ + qx.dom.StyleSheet.removeImport = function(vSheet, vUrl) { + var vRules = vSheet.cssRules; + var vLength = vRules.length; + + for (var i=vLength-1; i>=0; i--) { + if (vRules[i].href == vUrl) { + vSheet.deleteRule(i); + } + } + } +} + + +/** + * remove all imports from a stylesheet + * + * @param vSheet {Object} + */ +qx.dom.StyleSheet.removeAllImports = function(vSheet) {}; +if (document.createStyleSheet) // IE 4+ +{ + qx.dom.StyleSheet.removeAllImports = function(vSheet) { + var vImports = vSheet.imports; + var vLength = vImports.length; + + for (var i=vLength-1; i>=0; i--) { + vSheet.removeImport(i); + } + } +} +else // FF, etc +{ + qx.dom.StyleSheet.removeAllImports = function(vSheet) { + var vRules = vSheet.cssRules; + var vLength = vRules.length; + + for (var i=vLength-1; i>=0; i--) { + if (vRules[i].type == vRules[i].IMPORT_RULE) { + vSheet.deleteRule(i); + } + } + } +} diff --git a/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/dom/Window.js b/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/dom/Window.js new file mode 100644 index 0000000000..21f94d1171 --- /dev/null +++ b/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/dom/Window.js @@ -0,0 +1,102 @@ +/* ************************************************************************ + + qooxdoo - the new era of web development + + http://qooxdoo.org + + Copyright: + 2004-2006 by 1&1 Internet AG, Germany, http://www.1and1.org + + License: + LGPL 2.1: http://www.gnu.org/licenses/lgpl.html + + Authors: + * Sebastian Werner (wpbasti) + * Andreas Ecker (ecker) + +************************************************************************ */ + +/* ************************************************************************ + +#require(qx.sys.Client) + +************************************************************************ */ + +qx.OO.defineClass("qx.dom.Window"); + +if (qx.sys.Client.getInstance().isMshtml()) +{ + qx.dom.Window.getInnerWidth = function(w) + { + if (w.document.documentElement && w.document.documentElement.clientWidth) + { + return w.document.documentElement.clientWidth; + } + else if (w.document.body) + { + return w.document.body.clientWidth; + } + + return 0; + } + + qx.dom.Window.getInnerHeight = function(w) + { + if (w.document.documentElement && w.document.documentElement.clientHeight) + { + return w.document.documentElement.clientHeight; + } + else if (w.document.body) + { + return w.document.body.clientHeight; + } + + return 0; + } + + qx.dom.Window.getScrollLeft = function(w) + { + if (w.document.documentElement && w.document.documentElement.scrollLeft) + { + return w.document.documentElement.scrollLeft; + } + else if (w.document.body) + { + return w.document.body.scrollTop; + } + + return 0; + } + + qx.dom.Window.getScrollTop = function(w) + { + if (w.document.documentElement && w.document.documentElement.scrollTop) + { + return w.document.documentElement.scrollTop; + } + else if (w.document.body) + { + return w.document.body.scrollTop; + } + + return 0; + } +} +else +{ + qx.dom.Window.getInnerWidth = function(w) { + return w.innerWidth; + } + + qx.dom.Window.getInnerHeight = function(w) { + return w.innerHeight; + } + + qx.dom.Window.getScrollLeft = function(w) { + return w.document.body.scrollLeft; + } + + qx.dom.Window.getScrollTop = function(w) { + return w.document.body.scrollTop; + } +} |