3 * $Revision: 1.2 $ $Date: 2003/02/07 16:04:21 $
\r
7 /* ***** BEGIN LICENSE BLOCK *****
\r
8 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
\r
10 * The contents of this file are subject to the Mozilla Public License Version
\r
11 * 1.1 (the "License"); you may not use this file except in compliance with
\r
12 * the License. You may obtain a copy of the License at
\r
13 * http://www.mozilla.org/MPL/
\r
15 * Software distributed under the License is distributed on an "AS IS" basis,
\r
16 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
\r
17 * for the specific language governing rights and limitations under the
\r
20 * The Original Code is Netscape code.
\r
22 * The Initial Developer of the Original Code is
\r
23 * Netscape Corporation.
\r
24 * Portions created by the Initial Developer are Copyright (C) 2001
\r
25 * the Initial Developer. All Rights Reserved.
\r
27 * Contributor(s): Bob Clary <bclary@netscape.com>
\r
29 * ***** END LICENSE BLOCK ***** */
\r
31 // xbStyle.getClip()
\r
33 function cssStyleGetClip()
\r
35 var clip = this.getEffectiveValue('clip');
\r
38 if (clip == 'rect()')
\r
41 if (clip == '' || clip == 'auto')
\r
43 clip = 'rect(0px, ' + this.getWidth() + 'px, ' + this.getHeight() + 'px, 0px)';
\r
47 clip = clip.replace(/px /g, 'px, ');
\r
53 // xbStyle.setClip()
\r
55 function cssStyleSetClip(sClipString)
\r
57 this.styleObj.clip = sClipString;
\r
60 // xbStyle.getClipTop()
\r
62 function cssStyleGetClipTop()
\r
64 var clip = this.getClip();
\r
65 var rect = new xbClipRect(clip);
\r
69 // xbStyle.setClipTop()
\r
71 function cssStyleSetClipTop(top)
\r
73 var clip = this.getClip();
\r
74 var rect = new xbClipRect(clip);
\r
76 this.styleObj.clip = rect.toString();
\r
79 // xbStyle.getClipRight()
\r
81 function cssStyleGetClipRight()
\r
83 var clip = this.getClip();
\r
84 var rect = new xbClipRect(clip);
\r
88 // xbStyle.setClipRight()
\r
90 function cssStyleSetClipRight(right)
\r
92 var clip = this.getClip();
\r
93 var rect = new xbClipRect(clip);
\r
95 this.styleObj.clip = rect.toString();
\r
98 // xbStyle.getClipBottom()
\r
100 function cssStyleGetClipBottom()
\r
102 var clip = this.getClip();
\r
103 var rect = new xbClipRect(clip);
\r
104 return rect.bottom;
\r
107 // xbStyle.setClipBottom()
\r
109 function cssStyleSetClipBottom(bottom)
\r
111 var clip = this.getClip();
\r
112 var rect = new xbClipRect(clip);
\r
113 rect.bottom = bottom;
\r
114 this.styleObj.clip = rect.toString();
\r
117 // xbStyle.getClipLeft()
\r
119 function cssStyleGetClipLeft()
\r
121 var clip = this.getClip();
\r
122 var rect = new xbClipRect(clip);
\r
126 // xbStyle.setClipLeft()
\r
128 function cssStyleSetClipLeft(left)
\r
130 var clip = this.getClip();
\r
131 var rect = new xbClipRect(clip);
\r
133 this.styleObj.clip = rect.toString();
\r
136 // xbStyle.getClipWidth()
\r
138 function cssStyleGetClipWidth()
\r
140 var clip = this.getClip();
\r
141 var rect = new xbClipRect(clip);
\r
142 return rect.getWidth();
\r
145 // xbStyle.setClipWidth()
\r
147 function cssStyleSetClipWidth(width)
\r
149 var clip = this.getClip();
\r
150 var rect = new xbClipRect(clip);
\r
151 rect.setWidth(width);
\r
152 this.styleObj.clip = rect.toString();
\r
155 // xbStyle.getClipHeight()
\r
157 function cssStyleGetClipHeight()
\r
159 var clip = this.getClip();
\r
160 var rect = new xbClipRect(clip);
\r
161 return rect.getHeight();
\r
164 // xbStyle.setClipHeight()
\r
166 function cssStyleSetClipHeight(height)
\r
168 var clip = this.getClip();
\r
169 var rect = new xbClipRect(clip);
\r
170 rect.setHeight(height);
\r
171 this.styleObj.clip = rect.toString();
\r
174 // the CSS attributes left,top are for absolutely positioned elements
\r
175 // measured relative to the containing element. for relatively positioned
\r
176 // elements, left,top are measured from the element's normal inline position.
\r
177 // getLeft(), setLeft() operate on this type of coordinate.
\r
179 // to allow dynamic positioning the getOffsetXXX and setOffsetXXX methods are
\r
180 // defined to return and set the position of either an absolutely or relatively
\r
181 // positioned element relative to the containing element.
\r
185 // xbStyle.getLeft()
\r
187 function cssStyleGetLeft()
\r
189 var left = this.getEffectiveValue('left');
\r
190 if (typeof(left) == 'number')
\r
193 if (left != '' && left.indexOf('px') == -1)
\r
195 xbDEBUG.dump('xbStyle.getLeft: Element ID=' + this.object.id + ' does not use pixels as units. left=' + left + ' Click Ok to continue, Cancel to Abort');
\r
199 if (top == 'auto' && this.object && typeof(this.object.offsetTop) == 'number')
\r
201 left = this.object.offsetTop + 'px';
\r
207 return xbToInt(left);
\r
210 // xbStyle.setLeft()
\r
212 function cssStyleSetLeft(left)
\r
214 if (typeof(this.styleObj.left) == 'number')
\r
215 this.styleObj.left = left;
\r
217 this.styleObj.left = left + 'px';
\r
220 // xbStyle.getTop()
\r
222 function cssStyleGetTop()
\r
224 var top = this.getEffectiveValue('top');
\r
225 if (typeof(top) == 'number')
\r
228 if (top != '' && top.indexOf('px') == -1)
\r
230 xbDEBUG.dump('xbStyle.getTop: Element ID=' + this.object.id + ' does not use pixels as units. top=' + top + ' Click Ok to continue, Cancel to Abort');
\r
234 if (top == 'auto' && this.object && typeof(this.object.offsetTop) == 'number')
\r
236 top = this.object.offsetTop + 'px';
\r
242 return xbToInt(top);
\r
245 // xbStyle.setTop()
\r
247 function cssStyleSetTop(top)
\r
249 if (typeof(this.styleObj.top) == 'number')
\r
250 this.styleObj.top = top;
\r
252 this.styleObj.top = top + 'px';
\r
255 // xbStyle.getPageX()
\r
257 function cssStyleGetPageX()
\r
260 var elm = this.object;
\r
264 //xxxHack: Due to limitations in Gecko's (0.9.6) ability to determine the
\r
265 // effective position attribute , attempt to use offsetXXX
\r
267 if (typeof(elm.offsetLeft) == 'number')
\r
271 x += elm.offsetLeft;
\r
272 elm = elm.offsetParent;
\r
281 elmstyle = new xbStyle(elm);
\r
282 position = elmstyle.getEffectiveValue('position');
\r
283 if (position != '' && position != 'static')
\r
284 x += elmstyle.getLeft();
\r
286 elm = elm.parentNode;
\r
293 // xbStyle.setPageX()
\r
295 function cssStyleSetPageX(x)
\r
298 var elm = this.object.parentNode;
\r
302 //xxxHack: Due to limitations in Gecko's (0.9.6) ability to determine the
\r
303 // effective position attribute , attempt to use offsetXXX
\r
305 if (elm && typeof(elm.offsetLeft) == 'number')
\r
309 xParent += elm.offsetLeft;
\r
310 elm = elm.offsetParent;
\r
319 elmstyle = new xbStyle(elm);
\r
320 position = elmstyle.getEffectiveValue('position');
\r
321 if (position != '' && position != 'static')
\r
322 xParent += elmstyle.getLeft();
\r
324 elm = elm.parentNode;
\r
333 // xbStyle.getPageY()
\r
335 function cssStyleGetPageY()
\r
338 var elm = this.object;
\r
342 //xxxHack: Due to limitations in Gecko's (0.9.6) ability to determine the
\r
343 // effective position attribute , attempt to use offsetXXX
\r
345 if (typeof(elm.offsetTop) == 'number')
\r
349 y += elm.offsetTop;
\r
350 elm = elm.offsetParent;
\r
359 elmstyle = new xbStyle(elm);
\r
360 position = elmstyle.getEffectiveValue('position');
\r
361 if (position != '' && position != 'static')
\r
362 y += elmstyle.getTop();
\r
364 elm = elm.parentNode;
\r
371 // xbStyle.setPageY()
\r
373 function cssStyleSetPageY(y)
\r
376 var elm = this.object.parentNode;
\r
380 //xxxHack: Due to limitations in Gecko's (0.9.6) ability to determine the
\r
381 // effective position attribute , attempt to use offsetXXX
\r
383 if (elm && typeof(elm.offsetTop) == 'number')
\r
387 yParent += elm.offsetTop;
\r
388 elm = elm.offsetParent;
\r
397 elmstyle = new xbStyle(elm);
\r
398 position = elmstyle.getEffectiveValue('position');
\r
399 if (position != '' && position != 'static')
\r
400 yParent += elmstyle.getTop();
\r
402 elm = elm.parentNode;
\r
411 // xbStyle.getHeight()
\r
413 function cssStyleGetHeight()
\r
415 var display = this.getEffectiveValue('display');
\r
416 var height = this.getEffectiveValue('height');
\r
418 if (typeof(height) == 'number')
\r
424 if (height == '' || height == 'auto' || height.indexOf('%') != -1)
\r
426 if (typeof(this.object.offsetHeight) == 'number')
\r
428 height = this.object.offsetHeight + 'px';
\r
430 else if (typeof(this.object.scrollHeight) == 'number')
\r
432 height = this.object.scrollHeight + 'px';
\r
436 if (height.indexOf('px') == -1)
\r
438 xbDEBUG.dump('xbStyle.getHeight: Element ID=' + this.object.id + ' does not use pixels as units. height=' + height + ' Click Ok to continue, Cancel to Abort');
\r
442 height = xbToInt(height);
\r
447 // xbStyle.setHeight()
\r
449 function cssStyleSetHeight(height)
\r
451 if (typeof(this.styleObj.height) == 'number')
\r
452 this.styleObj.height = height;
\r
454 this.styleObj.height = height + 'px';
\r
457 // xbStyle.getWidth()
\r
459 function cssStyleGetWidth()
\r
461 var display = this.getEffectiveValue('display');
\r
462 var width = this.getEffectiveValue('width');
\r
464 if (typeof(width) == 'number')
\r
466 // note Opera 6 has a bug in width and offsetWidth where
\r
467 // it returns the page width. Use clientWidth instead.
\r
468 if (navigator.userAgent.indexOf('Opera') != -1)
\r
469 return this.object.clientWidth;
\r
474 if (width == '' || width == 'auto' || width.indexOf('%') != -1)
\r
476 if (typeof(this.object.offsetWidth) == 'number')
\r
478 width = this.object.offsetWidth + 'px';
\r
480 else if (typeof(this.object.scrollHeight) == 'number')
\r
482 width = this.object.scrollWidth + 'px';
\r
486 if (width.indexOf('px') == -1)
\r
488 xbDEBUG.dump('xbStyle.getWidth: Element ID=' + this.object.id + ' does not use pixels as units. width=' + width + ' Click Ok to continue, Cancel to Abort');
\r
492 width = xbToInt(width);
\r
497 // xbStyle.setWidth()
\r
499 function cssStyleSetWidth(width)
\r
501 if (typeof(this.styleObj.width) == 'number')
\r
502 this.styleObj.width = width;
\r
504 this.styleObj.width = width + 'px';
\r
507 // xbStyle.getVisibility()
\r
509 function cssStyleGetVisibility()
\r
511 return this.getEffectiveValue('visibility');
\r
514 // xbStyle.setVisibility()
\r
516 function cssStyleSetVisibility(visibility)
\r
518 this.styleObj.visibility = visibility;
\r
521 // xbStyle.getzIndex()
\r
523 function cssStyleGetzIndex()
\r
525 return xbToInt(this.getEffectiveValue('zIndex'));
\r
528 // xbStyle.setzIndex()
\r
530 function cssStyleSetzIndex(zIndex)
\r
532 this.styleObj.zIndex = zIndex;
\r
535 // xbStyle.getBackgroundColor()
\r
537 function cssStyleGetBackgroundColor()
\r
539 return this.getEffectiveValue('backgroundColor');
\r
542 // xbStyle.setBackgroundColor()
\r
544 function cssStyleSetBackgroundColor(color)
\r
546 this.styleObj.backgroundColor = color;
\r
549 // xbStyle.getColor()
\r
551 function cssStyleGetColor()
\r
553 return this.getEffectiveValue('color');
\r
556 // xbStyle.setColor()
\r
558 function cssStyleSetColor(color)
\r
560 this.styleObj.color = color;
\r
563 // xbStyle.moveAbove()
\r
565 function xbStyleMoveAbove(cont)
\r
567 this.setzIndex(cont.getzIndex()+1);
\r
570 // xbStyle.moveBelow()
\r
572 function xbStyleMoveBelow(cont)
\r
574 var zindex = cont.getzIndex() - 1;
\r
576 this.setzIndex(zindex);
\r
579 // xbStyle.moveBy()
\r
581 function xbStyleMoveBy(deltaX, deltaY)
\r
583 this.moveTo(this.getLeft() + deltaX, this.getTop() + deltaY);
\r
586 // xbStyle.moveTo()
\r
588 function xbStyleMoveTo(x, y)
\r
594 // xbStyle.moveToAbsolute()
\r
596 function xbStyleMoveToAbsolute(x, y)
\r
602 // xbStyle.resizeBy()
\r
604 function xbStyleResizeBy(deltaX, deltaY)
\r
606 this.setWidth( this.getWidth() + deltaX );
\r
607 this.setHeight( this.getHeight() + deltaY );
\r
610 // xbStyle.resizeTo()
\r
612 function xbStyleResizeTo(x, y)
\r
618 // xbStyle.setInnerHTML()
\r
620 function xbSetInnerHTML(str)
\r
622 if (typeof(this.object.innerHTML) != 'undefined')
\r
623 this.object.innerHTML = str;
\r
627 // Extensions to xbStyle that are not supported by Netscape Navigator 4
\r
628 // but that provide cross browser implementations of properties for
\r
629 // Mozilla, Gecko, Netscape 6.x and Opera
\r
631 // xbStyle.getBorderTopWidth()
\r
633 function cssStyleGetBorderTopWidth()
\r
635 return xbToInt(this.getEffectiveValue('borderTopWidth'));
\r
638 // xbStyle.getBorderRightWidth()
\r
640 function cssStyleGetBorderRightWidth()
\r
642 return xbToInt(this.getEffectiveValue('borderRightWidth'));
\r
645 // xbStyle.getBorderBottomWidth()
\r
647 function cssStyleGetBorderBottomWidth()
\r
649 return xbToInt(this.getEffectiveValue('borderBottomWidth'));
\r
652 // xbStyle.getBorderLeftWidth()
\r
654 function cssStyleGetBorderLeftWidth()
\r
656 return xbToInt(this.getEffectiveValue('borderLeftWidth'));
\r
659 // xbStyle.getMarginTop()
\r
661 function cssStyleGetMarginTop()
\r
663 return xbToInt(this.getEffectiveValue('marginTop'));
\r
666 // xbStyle.getMarginRight()
\r
668 function cssStyleGetMarginRight()
\r
670 return xbToInt(this.getEffectiveValue('marginRight'));
\r
673 // xbStyle.getMarginBottom()
\r
675 function cssStyleGetMarginBottom()
\r
677 return xbToInt(this.getEffectiveValue('marginBottom'));
\r
680 // xbStyle.getMarginLeft()
\r
682 function cssStyleGetMarginLeft()
\r
684 return xbToInt(this.getEffectiveValue('marginLeft'));
\r
687 // xbStyle.getPaddingTop()
\r
689 function cssStyleGetPaddingTop()
\r
691 return xbToInt(this.getEffectiveValue('paddingTop'));
\r
694 // xbStyle.getPaddingRight()
\r
696 function cssStyleGetPaddingRight()
\r
698 return xbToInt(this.getEffectiveValue('paddingRight'));
\r
701 // xbStyle.getPaddingBottom()
\r
703 function cssStyleGetPaddingBottom()
\r
705 return xbToInt(this.getEffectiveValue('paddingBottom'));
\r
708 // xbStyle.getPaddingLeft()
\r
710 function cssStyleGetPaddingLeft()
\r
712 return xbToInt(this.getEffectiveValue('paddingLeft'));
\r
715 // xbStyle.getClientWidth()
\r
717 function cssStyleGetClientWidth()
\r
719 return this.getWidth() + this.getPaddingLeft() + this.getPaddingRight();
\r
721 if (typeof(this.object.clientWidth) == 'number')
\r
722 return this.object.clientWidth;
\r
728 // xbStyle.getClientHeight()
\r
730 function cssStyleGetClientHeight()
\r
732 return this.getHeight() + this.getPaddingTop() + this.getPaddingBottom();
\r
734 if (typeof(this.object.clientHeight) == 'number')
\r
735 return this.object.clientHeight;
\r
741 xbStyle.prototype.getClip = cssStyleGetClip;
\r
742 xbStyle.prototype.setClip = cssStyleSetClip;
\r
743 xbStyle.prototype.getClipTop = cssStyleGetClipTop;
\r
744 xbStyle.prototype.setClipTop = cssStyleSetClipTop;
\r
745 xbStyle.prototype.getClipRight = cssStyleGetClipRight;
\r
746 xbStyle.prototype.setClipRight = cssStyleSetClipRight;
\r
747 xbStyle.prototype.getClipBottom = cssStyleGetClipBottom;
\r
748 xbStyle.prototype.setClipBottom = cssStyleSetClipBottom;
\r
749 xbStyle.prototype.getClipLeft = cssStyleGetClipLeft;
\r
750 xbStyle.prototype.setClipLeft = cssStyleSetClipLeft;
\r
751 xbStyle.prototype.getClipWidth = cssStyleGetClipWidth;
\r
752 xbStyle.prototype.setClipWidth = cssStyleSetClipWidth;
\r
753 xbStyle.prototype.getClipHeight = cssStyleGetClipHeight;
\r
754 xbStyle.prototype.setClipHeight = cssStyleSetClipHeight;
\r
755 xbStyle.prototype.getLeft = cssStyleGetLeft;
\r
756 xbStyle.prototype.setLeft = cssStyleSetLeft;
\r
757 xbStyle.prototype.getTop = cssStyleGetTop;
\r
758 xbStyle.prototype.setTop = cssStyleSetTop;
\r
759 xbStyle.prototype.getPageX = cssStyleGetPageX;
\r
760 xbStyle.prototype.setPageX = cssStyleSetPageX;
\r
761 xbStyle.prototype.getPageY = cssStyleGetPageY;
\r
762 xbStyle.prototype.setPageY = cssStyleSetPageY;
\r
763 xbStyle.prototype.getVisibility = cssStyleGetVisibility;
\r
764 xbStyle.prototype.setVisibility = cssStyleSetVisibility;
\r
765 xbStyle.prototype.getzIndex = cssStyleGetzIndex;
\r
766 xbStyle.prototype.setzIndex = cssStyleSetzIndex;
\r
767 xbStyle.prototype.getHeight = cssStyleGetHeight;
\r
768 xbStyle.prototype.setHeight = cssStyleSetHeight;
\r
769 xbStyle.prototype.getWidth = cssStyleGetWidth;
\r
770 xbStyle.prototype.setWidth = cssStyleSetWidth;
\r
771 xbStyle.prototype.getBackgroundColor = cssStyleGetBackgroundColor;
\r
772 xbStyle.prototype.setBackgroundColor = cssStyleSetBackgroundColor;
\r
773 xbStyle.prototype.getColor = cssStyleGetColor;
\r
774 xbStyle.prototype.setColor = cssStyleSetColor;
\r
775 xbStyle.prototype.setInnerHTML = xbSetInnerHTML;
\r
776 xbStyle.prototype.getBorderTopWidth = cssStyleGetBorderTopWidth;
\r
777 xbStyle.prototype.getBorderRightWidth = cssStyleGetBorderRightWidth;
\r
778 xbStyle.prototype.getBorderBottomWidth = cssStyleGetBorderBottomWidth;
\r
779 xbStyle.prototype.getBorderLeftWidth = cssStyleGetBorderLeftWidth;
\r
780 xbStyle.prototype.getMarginLeft = cssStyleGetMarginLeft;
\r
781 xbStyle.prototype.getMarginTop = cssStyleGetMarginTop;
\r
782 xbStyle.prototype.getMarginRight = cssStyleGetMarginRight;
\r
783 xbStyle.prototype.getMarginBottom = cssStyleGetMarginBottom;
\r
784 xbStyle.prototype.getMarginLeft = cssStyleGetMarginLeft;
\r
785 xbStyle.prototype.getPaddingTop = cssStyleGetPaddingTop;
\r
786 xbStyle.prototype.getPaddingRight = cssStyleGetPaddingRight;
\r
787 xbStyle.prototype.getPaddingBottom = cssStyleGetPaddingBottom;
\r
788 xbStyle.prototype.getPaddingLeft = cssStyleGetPaddingLeft;
\r
789 xbStyle.prototype.getClientWidth = cssStyleGetClientWidth;
\r
790 xbStyle.prototype.getClientHeight = cssStyleGetClientHeight;
\r