+++ /dev/null
-/*\r
- * xbStyle.js\r
- * $Revision: 1.2 $ $Date: 2003/02/07 16:04:22 $\r
- */\r
-\r
-/* ***** BEGIN LICENSE BLOCK *****\r
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1\r
- *\r
- * The contents of this file are subject to the Mozilla Public License Version\r
- * 1.1 (the "License"); you may not use this file except in compliance with\r
- * the License. You may obtain a copy of the License at\r
- * http://www.mozilla.org/MPL/\r
- *\r
- * Software distributed under the License is distributed on an "AS IS" basis,\r
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License\r
- * for the specific language governing rights and limitations under the\r
- * License.\r
- *\r
- * The Original Code is Netscape code.\r
- *\r
- * The Initial Developer of the Original Code is\r
- * Netscape Corporation.\r
- * Portions created by the Initial Developer are Copyright (C) 2001\r
- * the Initial Developer. All Rights Reserved.\r
- *\r
- * Contributor(s): Bob Clary <bclary@netscape.com>\r
- *\r
- * ***** END LICENSE BLOCK ***** */\r
-\r
-function xbStyleNotSupported() {}\r
-\r
-function xbStyleNotSupportStringValue(propname) { xbDEBUG.dump(propname + ' is not supported in this browser'); return '';};\r
-\r
-/////////////////////////////////////////////////////////////\r
-// xbClipRect\r
-\r
-function xbClipRect(a1, a2, a3, a4)\r
-{\r
- this.top = 0;\r
- this.right = 0;\r
- this.bottom = 0;\r
- this.left = 0;\r
-\r
- if (typeof(a1) == 'string')\r
- {\r
- var val;\r
- var ca;\r
- var i;\r
- \r
- if (a1.indexOf('rect(') == 0)\r
- {\r
- // I would have preferred [0-9]+[a-zA-Z]+ for a regexp\r
- // but NN4 returns null for that. \r
- ca = a1.substring(5, a1.length-1).match(/-?[0-9a-zA-Z]+/g);\r
- for (i = 0; i < 4; ++i)\r
- {\r
- val = xbToInt(ca[i]);\r
- if (val != 0 && ca[i].indexOf('px') == -1)\r
- {\r
- xbDEBUG.dump('xbClipRect: A clipping region ' + a1 + ' was detected that did not use pixels as units. Click Ok to continue, Cancel to Abort');\r
- return;\r
- }\r
- ca[i] = val;\r
- }\r
- this.top = ca[0];\r
- this.right = ca[1];\r
- this.bottom = ca[2];\r
- this.left = ca[3];\r
- }\r
- } \r
- else if (typeof(a1) == 'number' && typeof(a2) == 'number' && typeof(a3) == 'number' && typeof(a4) == 'number')\r
- {\r
- this.top = a1;\r
- this.right = a2;\r
- this.bottom = a3;\r
- this.left = a4;\r
- }\r
-}\r
-\r
-xbClipRect.prototype.top = 0;\r
-xbClipRect.prototype.right = 0;\r
-xbClipRect.prototype.bottom = 0;\r
-xbClipRect.prototype.left = 0;\r
-\r
-\r
-function xbClipRectGetWidth()\r
-{\r
- return this.right - this.left;\r
-}\r
-xbClipRect.prototype.getWidth = xbClipRectGetWidth; \r
-\r
-function xbClipRectSetWidth(width)\r
-{\r
- this.right = this.left + width;\r
-}\r
-xbClipRect.prototype.setWidth = xbClipRectSetWidth;\r
-\r
-function xbClipRectGetHeight()\r
-{\r
- return this.bottom - this.top;\r
-}\r
-xbClipRect.prototype.getHeight = xbClipRectGetHeight; \r
-\r
-function xbClipRectSetHeight(height)\r
-{\r
- this.bottom = this.top + height;\r
-}\r
-xbClipRect.prototype.setHeight = xbClipRectSetHeight;\r
-\r
-function xbClipRectToString()\r
-{\r
- return 'rect(' + this.top + 'px ' + this.right + 'px ' + this.bottom + 'px ' + this.left + 'px )' ;\r
-}\r
-xbClipRect.prototype.toString = xbClipRectToString;\r
-\r
-/////////////////////////////////////////////////////////////\r
-// xbStyle\r
-//\r
-// Note Opera violates the standard by cascading the effective values\r
-// into the HTMLElement.style object. We can use IE's HTMLElement.currentStyle\r
-// to get the effective values. In Gecko we will use the W3 DOM Style Standard getComputedStyle\r
-\r
-function xbStyle(obj, win, position)\r
-{\r
- if (typeof(obj) == 'object' && typeof(obj.style) != 'undefined') \r
- this.styleObj = obj.style;\r
- else if (document.layers) // NN4\r
- {\r
- if (typeof(position) == 'undefined')\r
- position = '';\r
- \r
- this.styleObj = obj;\r
- this.styleObj.position = position;\r
- }\r
- this.object = obj;\r
- this.window = win ? win : window;\r
-}\r
-\r
-xbStyle.prototype.styleObj = null;\r
-xbStyle.prototype.object = null;\r
-\r
-/////////////////////////////////////////////////////////////\r
-// xbStyle.getEffectiveValue()\r
-// note that xbStyle's constructor uses the currentStyle object \r
-// for IE5+ and that Opera's style object contains computed values\r
-// already. Netscape Navigator's layer object also contains the \r
-// computed values as well. Note that IE4 will not return the \r
-// computed values.\r
-\r
-function xbStyleGetEffectiveValue(propname)\r
-{\r
- var value = null;\r
-\r
- if (this.window.document.defaultView && this.window.document.defaultView.getComputedStyle)\r
- {\r
- // W3\r
- // Note that propname is the name of the property in the CSS Style\r
- // Object. However the W3 method getPropertyValue takes the actual\r
- // property name from the CSS Style rule, i.e., propname is \r
- // 'backgroundColor' but getPropertyValue expects 'background-color'.\r
-\r
- var capIndex;\r
- var cappropname = propname;\r
-\r
- while ( (capIndex = cappropname.search(/[A-Z]/)) != -1)\r
- {\r
- if (capIndex != -1)\r
- {\r
- cappropname = cappropname.substring(0, capIndex) + '-' + cappropname.substring(capIndex, capIndex+1).toLowerCase() + cappropname.substr(capIndex+1);\r
- }\r
- }\r
-\r
- value = this.window.document.defaultView.getComputedStyle(this.object, '').getPropertyValue(cappropname);\r
-\r
- // xxxHack for Gecko:\r
- if (!value && this.styleObj[propname])\r
- {\r
- value = this.styleObj[propname];\r
- }\r
- }\r
- else if (typeof(this.styleObj[propname]) == 'undefined') \r
- {\r
- value = xbStyleNotSupportStringValue(propname);\r
- }\r
- else if (typeof(this.object.currentStyle) != 'undefined')\r
- {\r
- // IE5+\r
- value = this.object.currentStyle[propname];\r
- if (!value)\r
- {\r
- value = this.styleObj[propname];\r
- }\r
-\r
- if (propname == 'clip' && !value)\r
- {\r
- // clip is not stored in IE5/6 handle separately\r
- value = 'rect(' + this.object.currentStyle.clipTop + ', ' + this.object.currentStyle.clipRight + ', ' + this.object.currentStyle.clipBottom + ', ' + this.object.currentStyle.clipLeft + ')';\r
- }\r
- }\r
- else\r
- {\r
- // IE4+, Opera, NN4\r
- value = this.styleObj[propname];\r
- }\r
-\r
- return value;\r
-}\r
-\r
-/////////////////////////////////////////////////////////////////////////////\r
-// xbStyle.moveAbove()\r
-\r
-function xbStyleMoveAbove(cont)\r
-{\r
- this.setzIndex(cont.getzIndex()+1);\r
-}\r
-\r
-/////////////////////////////////////////////////////////////////////////////\r
-// xbStyle.moveBelow()\r
-\r
-function xbStyleMoveBelow(cont)\r
-{\r
- var zindex = cont.getzIndex() - 1;\r
- \r
- this.setzIndex(zindex);\r
-}\r
-\r
-/////////////////////////////////////////////////////////////////////////////\r
-// xbStyle.moveBy()\r
-\r
-function xbStyleMoveBy(deltaX, deltaY)\r
-{\r
- this.moveTo(this.getLeft() + deltaX, this.getTop() + deltaY);\r
-}\r
-\r
-/////////////////////////////////////////////////////////////////////////////\r
-// xbStyle.moveTo()\r
-\r
-function xbStyleMoveTo(x, y)\r
-{\r
- this.setLeft(x);\r
- this.setTop(y);\r
-}\r
-\r
-/////////////////////////////////////////////////////////////////////////////\r
-// xbStyle.moveToAbsolute()\r
-\r
-function xbStyleMoveToAbsolute(x, y)\r
-{\r
- this.setPageX(x);\r
- this.setPageY(y);\r
-}\r
-\r
-/////////////////////////////////////////////////////////////////////////////\r
-// xbStyle.resizeBy()\r
-\r
-function xbStyleResizeBy(deltaX, deltaY)\r
-{\r
- this.setWidth( this.getWidth() + deltaX );\r
- this.setHeight( this.getHeight() + deltaY );\r
-}\r
-\r
-/////////////////////////////////////////////////////////////////////////////\r
-// xbStyle.resizeTo()\r
-\r
-function xbStyleResizeTo(x, y)\r
-{\r
- this.setWidth(x);\r
- this.setHeight(y);\r
-}\r
-\r
-////////////////////////////////////////////////////////////////////////\r
-\r
-xbStyle.prototype.getEffectiveValue = xbStyleGetEffectiveValue;\r
-xbStyle.prototype.moveAbove = xbStyleMoveAbove;\r
-xbStyle.prototype.moveBelow = xbStyleMoveBelow;\r
-xbStyle.prototype.moveBy = xbStyleMoveBy;\r
-xbStyle.prototype.moveTo = xbStyleMoveTo;\r
-xbStyle.prototype.moveToAbsolute = xbStyleMoveToAbsolute;\r
-xbStyle.prototype.resizeBy = xbStyleResizeBy;\r
-xbStyle.prototype.resizeTo = xbStyleResizeTo;\r
-\r
-if (document.all || document.getElementsByName)\r
-{\r
- xblibrary.loadScript('xbStyle-css.js');\r
-}\r
-else if (document.layers)\r
-{\r
- xblibrary.loadScript('xbStyle-nn4.js');\r
-}\r
-else \r
-{\r
- xblibrary.loadScript('xbStyle-not-supported.js');\r
-}\r
-\r
-\r