/[cvs]/nfo/js/com.cross-browser.cbe/cbe_core.js
ViewVC logotype

Contents of /nfo/js/com.cross-browser.cbe/cbe_core.js

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (show annotations)
Sun Apr 6 04:51:35 2003 UTC (21 years, 3 months ago) by joko
Branch: MAIN
CVS Tags: HEAD
File MIME type: application/javascript
initial commit

1 /* cbe_core.js $Revision: 0.22 $
2 * CBE v4.19, Cross-Browser DHTML API from Cross-Browser.com
3 * Copyright (c) 2002 Michael Foster (mike@cross-browser.com)
4 * Distributed under the terms of the GNU LGPL from gnu.org
5 */
6 var cbeVersion="4.19", cbeDocumentId='idDocument', cbeWindowId='idWindow', cbeAll=new Array();
7 window.onload=function(){cbeInitialize("DIV", "SPAN"); if (window.windowOnload) window.windowOnload();}
8 window.onunload=function(){if(window.windowOnunload){window.windowOnunload();}if(window.cbeDebugObj){window.cbeDebugObj=null;}for(var i=0; i<cbeAll.length; i++){if(cbeAll[i]){if(cbeAll[i].ele){if(cbeAll[i].ele.cbe){cbeAll[i].ele.cbe=null;}cbeAll[i].ele=null;}cbeAll[i]=null;}}}
9 function CrossBrowserNode(){this.parentNode=null; this.childNodes=0; this.firstChild=null; this.lastChild=null; this.previousSibling=null; this.nextSibling=null;}
10 CrossBrowserNode.prototype.appendNode=function(cbeChild){if (cbeChild){if (!this.firstChild){this.firstChild=cbeChild;} else{cbeChild.previousSibling=this.lastChild; this.lastChild.nextSibling=cbeChild;}cbeChild.parentNode=this; this.lastChild=cbeChild; ++this.childNodes;}return cbeChild;}
11 CrossBrowserElement.prototype=new CrossBrowserNode;
12 function CrossBrowserElement(){
13 this.contains=this.left=this.top=this.offsetLeft=this.offsetTop=this.pageX=this.pageY=this.zIndex=_retZero;
14 this.show=this.hide=this.moveTo=this.moveBy=this.sizeTo=this.sizeBy=this.resizeTo=this.resizeBy=_retVoid;
15 this.visibility=this.color=this.background=this.clip=this.innerHtml=_retEStr;
16 if (cbeAll.length < 2){this.width=cbeInnerWidth; this.height=cbeInnerHeight; this.scrollLeft=cbePageXOffset; this.scrollTop=cbePageYOffset;}
17 else{this.width=this.height=this.scrollLeft=this.scrollTop=_retZero;}
18 this.id=""; this.index=cbeAll.length; cbeAll[this.index]=this; this.w=this.h=0; this.x=this.y=0;
19 if (window.cbeEventJsLoaded) this.listeners=new Array();
20 }
21 function cbeBindElement(cbe, ele){
22 if (!cbe || !ele) return;
23 cbe.ele=ele; cbe.ele.cbe=cbe; cbe.parentElement=cbeGetParentElement(ele);
24 if (ele==window){cbe.id=ele.id=cbeWindowId; return;} else if (ele==document){cbe.id=ele.id=cbeDocumentId; return;} else{cbe.id=ele.id;}
25 if (_def(ele.clip)){cbe.w=ele.clip.width; cbe.h=ele.clip.height;}
26 var css=_def(ele.style);
27 // left, top
28 cbe.moveTo=_cbeMoveTo; cbe.moveBy=_cbeMoveBy; if (css && _def(ele.style.left, ele.style.top) && typeof(ele.style.left)=="string"){cbe.left=_domLeft; cbe.top=_domTop;}else if (css && _def(ele.style.pixelLeft, ele.style.pixelTop)){cbe.left=_ieLeft; cbe.top=_ieTop;}else if (_def(ele.left, ele.top)){cbe.left=_nnLeft; cbe.top=_nnTop;}else{_sup(false,"left","top","moveTo","moveBy");}
29 // width, height
30 cbe.sizeTo=_cbeSizeTo; cbe.sizeBy=_cbeSizeBy; cbe.resizeTo=_cbeResizeTo; cbe.resizeBy=_cbeResizeBy; if (css && _def(ele.style.width, ele.style.height, ele.offsetWidth, ele.offsetHeight) && typeof(ele.style.width)=="string"){cbe.width=_domWidth; cbe.height=_domHeight;}else if (css && _def(ele.style.pixelWidth, ele.style.pixelHeight)){cbe.width=_ieWidth; cbe.height=_ieHeight;}else if (_def(ele.clip) && _def(ele.clip.width, ele.clip.height)){cbe.width=_nnWidth; cbe.height=_nnHeight;}else{_sup(false, "width","height","sizeTo","sizeBy","resizeTo","resizeBy");}
31 // zIndex
32 if (css && _def(ele.style.zIndex)){cbe.zIndex=_domZIndex;} else if (_def(ele.zIndex)){cbe.zIndex=_nnZIndex;} else{_sup(false,"zIndex");}
33 // visibility
34 cbe.show=_cbeShow; cbe.hide=_cbeHide; if (css && _def(ele.style.visibility)){cbe.visibility=_domVisibility;} else if (_def(ele.visibility)){cbe.visibility=_nnVisibility;} else{_sup(false,"visibility","show","hide");}
35 // background
36 if (css && _def(ele.style.backgroundColor, ele.style.backgroundImage)){cbe.background=_domBackground;} else if (_def(ele.bgColor, ele.background)){cbe.background=_nnBackground;} else{_sup(false,"background");}
37 // color
38 if (css && _def(ele.style.color)){cbe.color=_domColor;} else{_sup(false,"color");}
39 // clip
40 if (css && _def(ele.style.clip)){cbe.clip=_domClip;} else if (_def(ele.clip)){cbe.clip=_nnClip;} else{_sup(false,"clip");}
41 // offsetLeft, offsetTop
42 if (_def(ele.offsetLeft, ele.offsetTop, ele.offsetParent)){cbe.offsetLeft=_ieOffsetLeft; cbe.offsetTop=_ieOffsetTop;}else if (_def(ele.pageX, ele.pageY)){cbe.offsetLeft=_nnOffsetLeft; cbe.offsetTop=_nnOffsetTop;}else{_sup(false,"offsetLeft","offsetTop");}
43 // pageX, pageY
44 cbe.contains=_cbeContains; if (_def(ele.pageX, ele.pageY)){cbe.pageX=_nnPageX; cbe.pageY=_nnPageY;}else if (document.cbe.isSupported("offsetLeft")){cbe.pageX=_cbePageX; cbe.pageY=_cbePageY;}else{_sup(false,"pageX","pageY","contains");}
45 // innerHtml
46 if (_def(ele.innerHTML)){cbe.innerHtml=_ieInnerHtml;} else if (_def(ele.document) && _def(ele.document.write)){cbe.innerHtml=_nnInnerHtml;} else{_sup(false,"innerHtml");}
47 // scrollLeft, scrollTop
48 if (_def(ele.scrollLeft, ele.scrollTop)){cbe.scrollLeft=_cbeScrollLeft; cbe.scrollTop=_cbeScrollTop;}else{_sup(false,"scrollLeft","scrollTop");}
49 // createElement, appendChild, removeChild (these need more work)
50 if (!_def(document.createElement) && !document.layers){_sup(false,"createElement","appendChild","removeChild");}else{if (!_def(ele.appendChild)){_sup(false,"appendChild");} if (!_def(ele.removeChild)){_sup(false,"removeChild");}}
51 }
52 function cbeInitialize(sTagNames){
53 var t,i,ele,eleList,cbe;
54 cbe=new CrossBrowserElement(window);
55 cbeBindElement(cbe, window);
56 cbe=new CrossBrowserElement(document);
57 cbeBindElement(cbe, document);
58 if (!document.getElementById) document.getElementById=cbeGetElementById;
59 if (document.createElement || document.layers) document.cbe.createElement=_cbeCreateElement;
60 document.cbe.isSupported=_cbeIsSupported;
61 document.cbe.supported=new Array();
62 _sup(true,"left","top","width","height","zIndex","show","hide","visibility","background","color","clip","offsetLeft","offsetTop","pageX","pageY","innerHtml","scrollLeft","scrollTop","createElement","appendChild","removeChild","moveTo","moveBy","sizeTo","sizeBy","resizeTo","resizeBy","contains");
63 for (t=0; t < arguments.length; ++t){
64 eleList=cbeGetElementsByTagName(arguments[t]);
65 for (i=0; i < eleList.length; ++i){
66 ele=eleList[i];
67 if ( ele.id && ele.id !=""){
68 cbe=new CrossBrowserElement();
69 cbeBindElement(cbe, ele);
70 }
71 }
72 if (document.layers) break;
73 }
74 _cbeCreateTree();
75 if (window.cbeEventJsLoaded && (document.layers || is.opera5or6)){window.cbe.addEventListener("resize", cbeDefaultResizeListener);}
76 }
77 function _cbeIsSupported(sMethods){var i; for (i=0; i<arguments.length; ++i){if (!document.cbe.supported[arguments[i]]) return false;}return true;}
78 function _sup(bValue, sMethods){var i; for (i=1; i<arguments.length; ++i) document.cbe.supported[arguments[i]]=bValue;}
79 function _cbeCreateTree(){var parent; for (var i=1; i < cbeAll.length; ++i){parent=cbeAll[i].parentElement; if (!parent.cbe){while (parent && !parent.cbe){parent=cbeGetParentElement(parent);}if (!parent) parent=document;}parent.cbe.appendNode(cbeAll[i]);}}
80 function cbeGetElementById(sId){var ele=null; if (sId==window.cbeWindowId) ele=window; else if (sId==window.cbeDocumentId) ele=document; else if (is.dom1getbyid) ele=document.getElementById(sId); else if (document.all) ele=document.all[sId]; else if (document.layers) ele=nnGetElementById(sId); if (!ele && window.cbeUtilJsLoaded){ele=cbeGetImageByName(sId); if (!ele){ele=cbeGetFormByName(sId);}} return ele;}
81 function nnGetElementById(sId){for (var i=0; i < cbeAll.length; i++){if ( cbeAll[i].id==sId ) return cbeAll[i].ele;}return null;}
82 function cbeGetElementsByTagName(sTagName){
83 var eleList;
84 if (document.getElementsByTagName) eleList=document.getElementsByTagName(sTagName); // standard
85 else if (document.body && document.body.getElementsByTagName) eleList=document.body.getElementsByTagName(sTagName); // opera5or6
86 else if (document.all && document.all.tags) eleList=document.all.tags(sTagName); // ie4
87 else if (document.layers){eleList=new Array(); nnGetAllLayers(window, eleList, 0);}// nn4
88 return eleList;
89 }
90 function nnGetAllLayers(parent, layerArray, nextIndex){
91 var i, layer;
92 for (i=0; i < parent.document.layers.length; i++){
93 layer=parent.document.layers[i]; layerArray[nextIndex++]=layer;
94 if (layer.document.layers.length) nextIndex=nnGetAllLayers(layer, layerArray, nextIndex);
95 }
96 return nextIndex;
97 }
98 function cbeGetParentElement(child){
99 var parent=document;
100 if (child==window) parent=null;
101 else if (child==document) parent=window;
102 else if (child.parentLayer){if (child.parentLayer !=window) parent=child.parentLayer;}
103 else{
104 if (child.parentNode) parent=child.parentNode;
105 else if (child.offsetParent) parent=child.offsetParent;
106 else if (child.parentElement) parent=child.parentElement;
107 }
108 return parent;
109 }
110 function _def(){var i; for (i=0; i<arguments.length; ++i){if (typeof(arguments[i])=="" || typeof(arguments[i])=="undefined") return false;}return true;}
111 function _retZero(){return 0;}
112 function _retNull(){return null;}
113 function _retEStr(){return "";}
114 function _retVoid(){}
115 ////// when optimizing, don't remove anything above this comment //////
116 function _cbeCreateElement(sEleType){// returns an Element object
117 var ele=null;
118 if (document.createElement && sEleType.length){
119 ele=document.createElement(sEleType);
120 if (ele && ele.style){ele.style.position="absolute";}
121 }
122 else if (document.layers){
123 ele=new Object();
124 }
125 return ele;
126 }
127 CrossBrowserNode.prototype.appendChild=function(eleChild){// returns the appended Element object on success
128 var cbe, ele, rv=null;
129 if (document.layers){
130 var thisEle;
131 if (this.index < 2) thisEle=window;
132 else thisEle=this.ele;
133 ele=new Layer(this.width(), thisEle);
134 if (ele){
135 if (eleChild.id) ele.id=ele.name=eleChild.id;
136 cbe=new CrossBrowserElement();
137 cbeBindElement(cbe, ele);
138 this.appendNode(ele.cbe);
139 eleChild.cbe=cbe;
140 ++this.childNodes;
141 rv=ele;
142 }
143 }
144 else{
145 if (this.index < 2) ele=document.body;
146 else ele=this.ele;
147 if (ele.appendChild){
148 ele.appendChild(eleChild);
149 cbe=new CrossBrowserElement();
150 cbeBindElement(cbe, eleChild);
151 this.appendNode(eleChild.cbe);
152 ++this.childNodes;
153 rv=eleChild;
154 }
155 }
156 return rv;
157 }
158 CrossBrowserNode.prototype.removeChild=function(eleChild){
159 var ele, rv=null;
160 if (this.index < 2) ele=document.body;
161 else ele=this.ele;
162 if (ele.removeChild || document.layers){
163 --this.childNodes;
164 var prevSib=eleChild.cbe.previousSibling;
165 var nextSib=eleChild.cbe.nextSibling;
166 with (eleChild.cbe){
167 parentNode=null;
168 previousSibling=null;
169 nextSibling=null;
170 }
171 if (prevSib) prevSib.nextSibling=nextSib;
172 else this.firstChild=nextSib;
173 if (nextSib) nextSib.previousSibling=prevSib;
174 else this.lastChild=prevSib;
175 if (document.layers){
176 //// working on it
177 }
178 else{
179 ele.removeChild(eleChild);
180 }
181 rv=eleChild;
182 }
183 return rv;
184 }
185 function _cbeContains(iLeft, iTop, iClipTop, iClipRight, iClipBottom, iClipLeft){if (arguments.length==2){iClipTop=iClipRight=iClipBottom=iClipLeft=0;} else if (arguments.length==3){iClipRight=iClipBottom=iClipLeft=iClipTop;} else if (arguments.length==4){iClipLeft=iClipRight; iClipBottom=iClipTop;} var thisX=this.pageX(), thisY=this.pageY(); return ( iLeft >=thisX + iClipLeft && iLeft <=thisX + this.width() - iClipRight && iTop >=thisY + iClipTop && iTop <=thisY + this.height() - iClipBottom );}
186 function _cbeMoveTo(x_cr, y_mar, outside, xEndL){if (isFinite(x_cr)){this.left(x_cr); this.top(y_mar);}else{this.cardinalPosition(x_cr, y_mar, outside); this.left(this.x); this.top(this.y);}if (xEndL) cbeEval(xEndL, this);}
187 function _cbeMoveBy(uDX, uDY, xEndL){if (uDX){this.left(this.left() + uDX);} if (uDY){this.top(this.top() + uDY);} if (xEndL){cbeEval(xEndL, this);}}
188 function _domLeft(iX){if (arguments.length){this.ele.style.left=iX + "px";} else{iX=parseInt(this.ele.style.left); if (isNaN(iX)) iX=0;}return iX;}
189 function _ieLeft(iX){if (arguments.length){this.ele.style.pixelLeft=iX;} else{iX=this.ele.style.pixelLeft;} return iX;}
190 function _nnLeft(iX){if (arguments.length){this.ele.left=iX;} else{iX=this.ele.left;} return iX;}
191 function _domTop(iY){if (arguments.length){this.ele.style.top=iY + "px";} else{iY=parseInt(this.ele.style.top); if (isNaN(iY)) iY=0;}return iY;}
192 function _ieTop(iY){if (arguments.length){this.ele.style.pixelTop=iY;} else{iY=this.ele.style.pixelTop;} return iY;}
193 function _nnTop(iY){if (arguments.length){this.ele.top=iY;} else{iY=this.ele.top;} return iY;}
194 function _nnOffsetLeft(){var ol=this.ele.pageX - this.parentElement.pageX; if (isNaN(ol)){ol=this.ele.pageX;} return ol;}
195 function _nnOffsetTop(){var ot=this.ele.pageY - this.parentElement.pageY; if (isNaN(ot)){ot=this.ele.pageY;} return ot;}
196 function _ieOffsetLeft(){var x=this.ele.offsetLeft, parent=this.ele.offsetParent; while(parent && !parent.cbe){x +=parent.offsetLeft; parent=parent.offsetParent;}return x;}
197 function _ieOffsetTop(){var y=this.ele.offsetTop, parent=this.ele.offsetParent; while(parent && !parent.cbe){y +=parent.offsetTop; parent=parent.offsetParent;}return y;}
198 function _nnPageX(){return this.ele.pageX;}
199 function _nnPageY(){return this.ele.pageY;}
200 function _cbePageX(){var x=this.offsetLeft(), parent=this.parentNode; if (parent){while(parent.index > 1){x +=parent.offsetLeft(); parent=parent.parentNode;}} return x;}
201 function _cbePageY(){var y=this.offsetTop(), parent=this.parentNode; if (parent){while(parent.index > 1){y +=parent.offsetTop(); parent=parent.parentNode;}} return y;}
202 function _cbeSizeTo(uW, uH){this.width(uW); this.height(uH);}
203 function _cbeSizeBy(iDW, iDH){this.width(this.width() + iDW); this.height(this.height() + iDH);}
204 function _cbeResizeTo(uW, uH, xEndListener){this.sizeTo(uW, uH); this.clip('auto'); cbeEval(xEndListener, this);}
205 function _cbeResizeBy(iDW, iDH, xEndListener){this.sizeBy(iDW, iDH); this.clip('auto'); cbeEval(xEndListener, this);}
206 function _domWidth(uW){if (arguments.length){uW=Math.round(uW); _domSetWidth(this.ele, uW);}return this.ele.offsetWidth;}
207 function _ieWidth(uW){if (arguments.length){uW=Math.round(uW); this.ele.style.pixelWidth=uW;}return this.ele.style.pixelWidth;}
208 function _nnWidth(uW){if (arguments.length){this.w=Math.round(uW); this.ele.clip.right=this.w;}return this.w;}
209 function _domHeight(uH){if (arguments.length){uH=Math.round(uH); _domSetHeight(this.ele, uH);}return this.ele.offsetHeight;}
210 function _ieHeight(uH){if (arguments.length){uH=Math.round(uH); this.ele.style.pixelHeight=uH;}return this.ele.style.pixelHeight;}
211 function _nnHeight(uH){if (arguments.length){this.h=Math.round(uH); this.ele.clip.bottom=this.h;}return this.h;}
212 function _domSetWidth(ele,uW){
213 if (uW < 0) return;
214 var pl=0,pr=0,bl=0,br=0;
215 if (_def(document.defaultView) && _def(document.defaultView.getComputedStyle)){// gecko and standard
216 pl=parseInt(document.defaultView.getComputedStyle(ele, "").getPropertyValue("padding-left"));
217 pr=parseInt(document.defaultView.getComputedStyle(ele, "").getPropertyValue("padding-right"));
218 bl=parseInt(document.defaultView.getComputedStyle(ele, "").getPropertyValue("border-left-width"));
219 br=parseInt(document.defaultView.getComputedStyle(ele, "").getPropertyValue("border-right-width"));
220 }
221 else if (_def(ele.currentStyle, document.compatMode)){
222 if (document.compatMode=="CSS1Compat"){// ie6up in css1compat mode
223 pl=parseInt(ele.currentStyle.paddingLeft);
224 pr=parseInt(ele.currentStyle.paddingRight);
225 bl=parseInt(ele.currentStyle.borderLeftWidth);
226 br=parseInt(ele.currentStyle.borderRightWidth);
227 }
228 }
229 if (isNaN(pl)) pl=0; if (isNaN(pr)) pr=0; if (isNaN(bl)) bl=0; if (isNaN(br)) br=0;
230 var cssW=uW-(pl+pr+bl+br);
231 if (isNaN(cssW) || cssW < 0) return;
232 ele.style.width=cssW + "px";
233 }
234 function _domSetHeight(ele,uH){
235 if (uH < 0) return;
236 var pt=0,pb=0,bt=0,bb=0;
237 if (_def(document.defaultView) && _def(document.defaultView.getComputedStyle)){
238 pt=parseInt(document.defaultView.getComputedStyle(ele, "").getPropertyValue("padding-top"));
239 pb=parseInt(document.defaultView.getComputedStyle(ele, "").getPropertyValue("padding-bottom"));
240 bt=parseInt(document.defaultView.getComputedStyle(ele, "").getPropertyValue("border-top-width"));
241 bb=parseInt(document.defaultView.getComputedStyle(ele, "").getPropertyValue("border-bottom-width"));
242 }
243 else if (_def(ele.currentStyle, document.compatMode)){
244 if (document.compatMode=="CSS1Compat"){
245 pt=parseInt(ele.currentStyle.paddingTop);
246 pb=parseInt(ele.currentStyle.paddingBottom);
247 bt=parseInt(ele.currentStyle.borderTopWidth);
248 bb=parseInt(ele.currentStyle.borderBottomWidth);
249 }
250 }
251 if (isNaN(pt)) pt=0; if (isNaN(pb)) pb=0; if (isNaN(bt)) bt=0; if (isNaN(bb)) bb=0;
252 var cssH=uH-(pt+pb+bt+bb);
253 if (isNaN(cssH) || cssH < 0) return;
254 ele.style.height=cssH + "px";
255 }
256 function _cbeScrollLeft(){return this.ele.scrollLeft;}
257 function _cbeScrollTop(){return this.ele.scrollTop;}
258 function _cbeShow(){this.visibility(1);}
259 function _cbeHide(){this.visibility(0);}
260 function _domVisibility(vis){if (arguments.length){if (vis){this.ele.style.visibility='inherit';} else{this.ele.style.visibility='hidden';}}else return (this.ele.style.visibility=='visible' || this.ele.style.visibility=='inherit' || this.ele.style.visibility=='');}
261 function _nnVisibility(vis){if (arguments.length){if (vis){this.ele.visibility='inherit';} else{this.ele.visibility='hide';}}else return (this.ele.visibility=='show' || this.ele.visibility=='inherit' || this.ele.visibility=='');}
262 function _domZIndex(uZ){if (arguments.length){this.ele.style.zIndex=uZ;} else{uZ=parseInt(this.ele.style.zIndex); if (isNaN(uZ)) uZ=0;}return uZ;}
263 function _nnZIndex(uZ){if (arguments.length) this.ele.zIndex=uZ; return this.ele.zIndex;}
264 function _domBackground(sColor, sImage){if (arguments.length){if (!sColor){sColor='transparent';} this.ele.style.backgroundColor=sColor; if (arguments.length==2){this.ele.style.backgroundImage="url(" + sImage + ")";}}else return this.ele.style.backgroundColor;}
265 function _nnBackground(sColor, sImage){if (arguments.length){if (sColor=='transparent'){sColor=null;} this.ele.bgColor=sColor; if (arguments.length==2){this.ele.background.src=sImage || null;}}else{var bg=this.ele.bgColor; if (window.cbeUtilJsLoaded){bg=cbeHexString(bg,6,'#');} return bg;}}
266 function _domColor(newColor){if (arguments.length){this.ele.style.color=newColor;}else return this.ele.style.color;}
267 function _domClip(iTop, iRight, iBottom, iLeft){if (arguments.length==4){var clipRect="rect(" + iTop + "px " + iRight + "px " + iBottom + "px " + iLeft + "px" + ")"; this.ele.style.clip=clipRect;}else{this.clip(0, this.ele.offsetWidth, this.ele.offsetHeight, 0);}}
268 function _nnClip(iTop, iRight, iBottom, iLeft){if (arguments.length==4){this.ele.clip.top=iTop; this.ele.clip.right=iRight; this.ele.clip.bottom=iBottom; this.ele.clip.left=iLeft;}else{this.clip(0, this.width(), this.height(), 0);}}
269 function _ieInnerHtml(sHtml){if (arguments.length){this.ele.innerHTML=sHtml;}else return this.ele.innerHTML;}
270 function _nnInnerHtml(sHtml){if (arguments.length){if (sHtml==""){sHtml=" ";} this.ele.document.open(); this.ele.document.write(sHtml); this.ele.document.close();}else return "";}
271 CrossBrowserElement.prototype.cardinalPosition=function(cp, margin, outside){
272 if (typeof(cp) !='string'){window.status='cardinalPosition() error: cp=' + cp + ', id=' + this.id; return;}
273 var x=this.left(), y=this.top(), w=this.width(), h=this.height();
274 var pw=this.parentNode.width(), ph=this.parentNode.height();
275 var sx=this.parentNode.scrollLeft(), sy=this.parentNode.scrollTop();
276 var right=sx + pw, bottom=sy + ph;
277 var cenLeft=sx + Math.floor((pw-w)/2), cenTop=sy + Math.floor((ph-h)/2);
278 if (!margin) margin=0;
279 else{
280 if (outside) margin=-margin;
281 sx +=margin; sy +=margin; right -=margin; bottom -=margin;
282 }
283 switch (cp.toLowerCase()){
284 case 'n': x=cenLeft; if (outside) y=sy - h; else y=sy; break;
285 case 'ne': if (outside){x=right; y=sy - h;}else{x=right - w; y=sy;}break;
286 case 'e': y=cenTop; if (outside) x=right; else x=right - w; break;
287 case 'se': if (outside){x=right; y=bottom;}else{x=right - w; y=bottom - h}break;
288 case 's': x=cenLeft; if (outside) y=sy - h; else y=bottom - h; break;
289 case 'sw': if (outside){x=sx - w; y=bottom;}else{x=sx; y=bottom - h;}break;
290 case 'w': y=cenTop; if (outside) x=sx - w; else x=sx; break;
291 case 'nw': if (outside){x=sx - w; y=sy - h;}else{x=sx; y=sy;}break;
292 case 'cen': case 'center': x=cenLeft; y=cenTop; break;
293 case 'cenh': x=cenLeft; break;
294 case 'cenv': y=cenTop; break;
295 }
296 this.x=x; this.y=y;
297 }
298 function cbeInnerWidth(){
299 var w=0;
300 if (is.opera5or6){w=window.innerWidth;}
301 else if (is.ie && document.documentElement && document.documentElement.clientWidth) w=document.documentElement.clientWidth; // ie6 compat mode
302 else if (document.body && document.body.clientWidth) w=document.body.clientWidth; // ie4up and gecko
303 else if (_def(window.innerWidth,window.innerHeight,document.height)){// nn4
304 w=window.innerWidth;
305 if (document.height > window.innerHeight) w -=16;
306 }
307 return w;
308 }
309 function cbeInnerHeight(){
310 var h=0;
311 if (is.opera5or6){h=window.innerHeight;}
312 else if (is.ie && document.documentElement && document.documentElement.clientHeight) h=document.documentElement.clientHeight;
313 else if (document.body && document.body.clientHeight) h=document.body.clientHeight;
314 else if (_def(window.innerWidth,window.innerHeight,document.width)){
315 h=window.innerHeight;
316 if (document.width > window.innerWidth) h -=16;
317 }
318 return h;
319 }
320 function cbePageXOffset(){
321 var offset=0;
322 if (_def(window.pageXOffset)) offset=window.pageXOffset; // gecko, nn4, opera
323 else if (document.documentElement && document.documentElement.scrollLeft) offset=document.documentElement.scrollLeft; // ie6 compat mode
324 else if (document.body && _def(document.body.scrollLeft)) offset=document.body.scrollLeft; // ie4up
325 return offset;
326 }
327 function cbePageYOffset(){
328 var offset=0;
329 if (_def(window.pageYOffset)) offset=window.pageYOffset;
330 else if (document.documentElement && document.documentElement.scrollTop) offset=document.documentElement.scrollTop;
331 else if (document.body && _def(document.body.scrollTop)) offset=document.body.scrollTop;
332 return offset;
333 }
334 function cbeEval(exp, arg1, arg2, arg3, arg4, arg5, arg6){
335 if (typeof(exp)=="function") exp(arg1, arg2, arg3, arg4, arg5, arg6);
336 else if (typeof(exp)=="object" && typeof(arg1)=="function") {
337 exp._cbeEval_ = arg1;
338 exp._cbeEval_(arg2, arg3, arg4, arg5, arg6);
339 }
340 else if (typeof(exp)=="string") eval(exp);
341 }
342 function ClientSnifferJr(){
343 this.ua=navigator.userAgent.toLowerCase();
344 this.major=parseInt(navigator.appVersion);
345 this.minor=parseFloat(navigator.appVersion);
346 if (document.addEventListener && document.removeEventListener) this.dom2events=true;
347 if (document.getElementById) this.dom1getbyid=true;
348 if (window.opera){
349 this.opera=true;
350 this.opera5=(this.ua.indexOf("opera 5") !=-1 || this.ua.indexOf("opera/5") !=-1);
351 this.opera6=(this.ua.indexOf("opera 6") !=-1 || this.ua.indexOf("opera/6") !=-1);
352 this.opera5or6=this.opera5 || this.opera6;
353 this.opera7=(this.ua.indexOf("opera 7") !=-1 || this.ua.indexOf("opera/7") !=-1);
354 return;
355 }
356 this.konq=this.ua.indexOf('konqueror') !=-1;
357 this.ie=this.ua.indexOf('msie') !=-1;
358 if (this.ie){
359 this.ie3=this.major < 4;
360 this.ie4=(this.major==4 && this.ua.indexOf('msie 5')==-1 && this.ua.indexOf('msie 6')==-1);
361 this.ie4up=this.major >=4;
362 this.ie5=(this.major==4 && this.ua.indexOf('msie 5.0') !=-1);
363 this.ie5up=!this.ie3 && !this.ie4;
364 this.ie6=(this.major==4 && this.ua.indexOf('msie 6.0') !=-1);
365 this.ie6up=(!this.ie3 && !this.ie4 && !this.ie5 && this.ua.indexOf("msie 5.5")==-1);
366 return;
367 }
368 this.hotjava=this.ua.indexOf('hotjava') !=-1;
369 this.webtv=this.ua.indexOf('webtv') !=-1;
370 this.aol=this.ua.indexOf('aol') !=-1;
371 if (this.hotjava || this.webtv || this.aol) return;
372 // Gecko, NN4, and NS6
373 this.gecko=this.ua.indexOf('gecko') !=-1;
374 this.nav=(this.ua.indexOf('mozilla') !=-1 && this.ua.indexOf('spoofer')==-1 && this.ua.indexOf('compatible')==-1);
375 if (this.nav){
376 this.nav4=this.major==4;
377 this.nav4up=this.major >=4;
378 this.nav5up=this.major >=5;
379 this.nav6=this.major==5;
380 this.nav6up=this.nav5up;
381 }
382 }
383 window.is=new ClientSnifferJr();
384 // End cbe_core.js

MailToCvsAdmin">MailToCvsAdmin
ViewVC Help
Powered by ViewVC 1.1.26 RSS 2.0 feed