From 38c78645942056d80a1bff692938838ad2002d81 Mon Sep 17 00:00:00 2001 From: Norman Walsh Date: Fri, 19 Dec 2003 16:49:34 +0000 Subject: [PATCH] No need to have this in CVS, it's copied from ../../browser --- slides/demo/browser/overlay.js | 140 ---- slides/demo/browser/slides.js | 13 +- slides/demo/browser/ua.js | 54 +- slides/demo/browser/xbDOM.js | 383 ++++++----- slides/demo/browser/xbDebug.js | 130 +++- slides/demo/browser/xbStyle.js | 1160 ++------------------------------ 6 files changed, 441 insertions(+), 1439 deletions(-) delete mode 100644 slides/demo/browser/overlay.js diff --git a/slides/demo/browser/overlay.js b/slides/demo/browser/overlay.js deleted file mode 100644 index 9b52d9b7c..000000000 --- a/slides/demo/browser/overlay.js +++ /dev/null @@ -1,140 +0,0 @@ -// -*- Java -*- -// -// Overlay.js, adapted from Floating image II on dynamicdrive.com -/* Usage: - - - -...rest of head... - - -
-...body of overlay... -
-...rest of page... -*/ - -var overlayNS4 = document.layers ? 1 : 0; -var overlayIE = document.all ? 1 : 0; -var overlayNS6 = document.getElementById && !document.all ? 1 : 0; - -var overlayPadX = 15; -var overlayPadY = 15; -var overlayDelay = 60; - -var overlayCorner = 'ur'; // ul, ll, ur, lr, uc, lc, cl, cr - -function overlayRefresh() { - var overlayLx = 0; - var overlayLy = 0; - - var overlayX = 0; - var overlayY = 0; - var overlayW = 0; - var overlayH = 0; - var contentH = 0; - - var body = xbGetElementsByName('BODY')[0]; - - if (overlayIE) { - overlayLx = document.body.clientWidth; - overlayLy = document.body.clientHeight; - - if (document.body.parentElement) { - // For IE6 - overlayLx = document.body.parentElement.clientWidth; - overlayLy = document.body.parentElement.clientHeight; - } - - overlayH = overlayDiv.offsetHeight; - overlayW = body.offsetWidth; // overlayDiv.offsetWidth; - contentH = body.offsetHeight; - } else if (overlayNS4) { - overlayLy = window.innerHeight; - overlayLx = window.innerWidth; - overlayH = document.overlayDiv.clip.height; - overlayW = body.clip.width; // document.overlayDiv.clip.width; - contentH = body.clip.height; - } else if (overlayNS6) { - var odiv = document.getElementById('overlayDiv'); - - overlayLy = window.innerHeight; - overlayLx = window.innerWidth; - overlayH = odiv.offsetHeight; - overlayW = body.offsetWidth; // odiv.offsetWidth; - contentH = body.offsetHeight; - } - - if (overlayCorner == 'ul') { - overlayX = overlayPadX; - overlayY = overlayPadY; - } else if (overlayCorner == 'cl') { - overlayX = overlayPadX; - overlayY = (overlayLy - overlayH) / 2; - } else if (overlayCorner == 'll') { - overlayX = overlayPadX; - overlayY = (overlayLy - overlayH) - overlayPadY; - } else if (overlayCorner == 'ur') { - overlayX = (overlayLx - overlayW) - overlayPadX; - overlayY = overlayPadY; - } else if (overlayCorner == 'cr') { - overlayX = (overlayLx - overlayW) - overlayPadX; - overlayY = (overlayLy - overlayH) / 2; - } else if (overlayCorner == 'lr') { - overlayX = (overlayLx - overlayW) - overlayPadX; - overlayY = (overlayLy - overlayH) - overlayPadY; - } else if (overlayCorner == 'uc') { - overlayX = (overlayLx - overlayW) / 2; - overlayY = overlayPadY; - } else { // overlayCorner == 'lc' - overlayX = (overlayLx - overlayW) / 2; - overlayY = (overlayLy - overlayH) - overlayPadY; - } - - if (overlayIE) { - overlayDiv.style.left=overlayX; - overlayDiv.style.top=overlayY+document.body.scrollTop; - - if (contentH > overlayLy) { - overlayDiv.style.visibility = "hidden"; - } - } else if (overlayNS4) { - document.overlayDiv.pageX=overlayX; - document.overlayDiv.pageY=overlayY+window.pageYOffset; - document.overlayDiv.visibility="visible"; - - if (contentH > overlayLy) { - document.overlayDiv.style.visibility = "hidden"; - } - } else if (overlayNS6) { - var div = document.getElementById("overlayDiv"); - var leftpx = overlayX; - var toppx = overlayY+window.pageYOffset; - var widthpx = overlayW; - - div.style.left = leftpx + "px"; - div.style.top = toppx + "px"; - div.style.width = widthpx + "px"; - - if (contentH > overlayLy) { - div.style.visibility = "hidden"; - } - } -} - -function onad() { - loopfunc(); -} - -function loopfunc() { - overlayRefresh(); - setTimeout('loopfunc()',overlayDelay); -} - -function overlaySetup(corner) { - overlayCorner = corner; - - if (overlayIE || overlayNS4 || overlayNS6) { - onad(); - } -} diff --git a/slides/demo/browser/slides.js b/slides/demo/browser/slides.js index 23905e562..50f674d45 100644 --- a/slides/demo/browser/slides.js +++ b/slides/demo/browser/slides.js @@ -10,7 +10,7 @@ // This script assumes that the Netscape 'ua.js' module has also been loaded. function newPage(filename, overlay) { - divs = xbGetElementsByName("DIV"); + divs = document.getElementsByTagName("div"); if (divs) { var xdiv = divs[0]; @@ -55,7 +55,8 @@ function navigate (evt) { var home = (kc == 36); var toc = (kc == 112) || (kc == 224); - var links = xbGetElementsByName("LINK"); + var links = document.getElementsByTagName("link"); + var count = 0; var target = ""; @@ -75,14 +76,18 @@ function navigate (evt) { } if (target != "") { - window.location = target; + if (window.top.frames[1]) { + window.top.frames[1].location = target; + } else { + window.location = target; + } } return false; } function toggletoc (img, width, hidegraphic, showgraphic) { - var fsc = xbGetElementsByName('FRAMESET',top); + var fsc = top.GetElementsByTagName('frameset'); if (fsc) { var fs = fsc[0]; if (fs) { diff --git a/slides/demo/browser/ua.js b/slides/demo/browser/ua.js index 236822c25..4cec485d9 100644 --- a/slides/demo/browser/ua.js +++ b/slides/demo/browser/ua.js @@ -1,13 +1,31 @@ /* -ua.js revision 0.200 2001-12-03 + * ua.js + * $Revision$ $Date$ + */ -Contributor(s): Bob Clary, Netscape Communications, Copyright 2001 - -Netscape grants you a royalty free license to use, modify and -distribute this software provided that this copyright notice -appears on all copies. This software is provided "AS IS," -without a warranty of any kind. -*/ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Netscape code. + * + * The Initial Developer of the Original Code is + * Netscape Corporation. + * Portions created by the Initial Developer are Copyright (C) 2001 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): Bob Clary + * + * ***** END LICENSE BLOCK ***** */ function xbDetectBrowser() { @@ -59,16 +77,20 @@ function xbDetectBrowser() else if (ua.indexOf('gecko') != -1) { navigator.family = 'gecko'; - var rvStart = navigator.userAgent.indexOf('rv:') + 3; - var rvEnd = navigator.userAgent.indexOf(')', rvStart); - var rv = navigator.userAgent.substring(rvStart, rvEnd); - var decIndex = rv.indexOf('.'); - if (decIndex != -1) + var rvStart = ua.indexOf('rv:'); + var rvEnd = ua.indexOf(')', rvStart); + var rv = ua.substring(rvStart+3, rvEnd); + var rvParts = rv.split('.'); + var rvValue = 0; + var exp = 1; + + for (var i = 0; i < rvParts.length; i++) { - rv = rv.replace(/\./g, '') - rv = rv.substring(0, decIndex-1) + '.' + rv.substr(decIndex) + var val = parseInt(rvParts[i]); + rvValue += val / exp; + exp *= 100; } - navigator.version = parseFloat(rv); + navigator.version = rvValue; if (ua.indexOf('netscape') != -1) navigator.org = 'netscape'; diff --git a/slides/demo/browser/xbDOM.js b/slides/demo/browser/xbDOM.js index 40bcb8f32..2b7dfaba2 100644 --- a/slides/demo/browser/xbDOM.js +++ b/slides/demo/browser/xbDOM.js @@ -1,41 +1,31 @@ /* -xbDOM.js v 0.004 2002-03-09 - -Contributor(s): Bob Clary, Netscape Communications, Copyright 2001, 2002 - -Netscape grants you a royalty free license to use, modify and -distribute this software provided that this copyright notice -appears on all copies. This software is provided "AS IS," -without a warranty of any kind. - -Change Log: - -2002-03-15: v 0.004 - bclary - - fix bug in bugfix for 0.003 in xbGetElementsByName - to not confuse elements with length properties with arrays - -2002-03-09: v 0.003 - bclary - - fix bug in xbGetElementsByName in Internet Explorer when there is - only one instance of an element with name value. - -2002-01-19: v 0.002 - bclary - - nav4FindElementsByName - removed erroneous obj and return - added search of form elements - xbFindElementsByNameAndType - renamed from FindElementsByNameAndType - removed erroneouse obj and return - xbSetInnerHTML - ported over from xbStyle since it is more - appropriate here. - -2001-11-27: v 0.01 - bclary - - removed from xbStyle -*/ + * xbDOM.js + * $Revision$ $Date$ + */ + +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Netscape code. + * + * The Initial Developer of the Original Code is + * Netscape Corporation. + * Portions created by the Initial Developer are Copyright (C) 2001 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): Bob Clary + * + * ***** END LICENSE BLOCK ***** */ function xbToInt(s) { @@ -51,12 +41,18 @@ function xbGetWindowWidth(windowRef) var width = 0; if (!windowRef) + { windowRef = window; + } if (typeof(windowRef.innerWidth) == 'number') + { width = windowRef.innerWidth; + } else if (windowRef.document.body && typeof(windowRef.document.body.clientWidth) == 'number') + { width = windowRef.document.body.clientWidth; + } return width; } @@ -66,89 +62,19 @@ function xbGetWindowHeight(windowRef) var height = 0; if (!windowRef) - windowRef = window; - - if (typeof(windowRef.innerWidth) == 'number') - height = windowRef.innerHeight; - else if (windowRef.document.body && typeof(windowRef.document.body.clientWidth) == 'number') - height = windowRef.document.body.clientHeight; - - return height; -} - -function nav4FindLayer(doc, id) -{ - var i; - var subdoc; - var obj; - - for (i = 0; i < doc.layers.length; ++i) { - if (doc.layers[i].id && id == doc.layers[i].id) - return doc.layers[i]; - - subdoc = doc.layers[i].document; - obj = nav4FindLayer(subdoc, id); - if (obj != null) - return obj; - } - return null; -} - -function nav4FindElementsByName(doc, name, elmlist) -{ - var i; - var j; - var subdoc; - - for (i = 0; i < doc.images.length; ++i) - { - if (doc.images[i].name && name == doc.images[i].name) - elmlist[elmlist.length] = doc.images[i]; - } - - for (i = 0; i < doc.forms.length; ++i) - { - for (j = 0; j < doc.forms[i].elements.length; j++) - if (doc.forms[i].elements[j].name && name == doc.forms[i].elements[j].name) - elmlist[elmlist.length] = doc.forms[i].elements[j]; - - if (doc.forms[i].name && name == doc.forms[i].name) - elmlist[elmlist.length] = doc.forms[i]; - } - - for (i = 0; i < doc.anchors.length; ++i) - { - if (doc.anchors[i].name && name == doc.anchors[i].name) - elmlist[elmlist.length] = doc.anchors[i]; - } - - for (i = 0; i < doc.links.length; ++i) - { - if (doc.links[i].name && name == doc.links[i].name) - elmlist[elmlist.length] = doc.links[i]; - } - - for (i = 0; i < doc.applets.length; ++i) - { - if (doc.applets[i].name && name == doc.applets[i].name) - elmlist[elmlist.length] = doc.applets[i]; + windowRef = window; } - for (i = 0; i < doc.embeds.length; ++i) + if (typeof(windowRef.innerWidth) == 'number') { - if (doc.embeds[i].name && name == doc.embeds[i].name) - elmlist[elmlist.length] = doc.embeds[i]; + height = windowRef.innerHeight; } - - for (i = 0; i < doc.layers.length; ++i) + else if (windowRef.document.body && typeof(windowRef.document.body.clientWidth) == 'number') { - if (doc.layers[i].name && name == doc.layers[i].name) - elmlist[elmlist.length] = doc.layers[i]; - - subdoc = doc.layers[i].document; - nav4FindElementsByName(subdoc, name, elmlist); + height = windowRef.document.body.clientHeight; } + return height; } function xbGetElementsByNameAndType(name, type, windowRef) @@ -171,7 +97,9 @@ function xbFindElementsByNameAndType(doc, name, type, elmlist) for (i = 0; i < doc[type].length; ++i) { if (doc[type][i].name && name == doc[type][i].name) + { elmlist[elmlist.length] = doc[type][i]; + } } if (doc.layers) @@ -184,10 +112,103 @@ function xbFindElementsByNameAndType(doc, name, type, elmlist) } } -//alert("layers: " + document.layers + " all: " + document.all); - if (document.layers) { + nav4FindLayer = + function (doc, id) + { + var i; + var subdoc; + var obj; + + for (i = 0; i < doc.layers.length; ++i) + { + if (doc.layers[i].id && id == doc.layers[i].id) + return doc.layers[i]; + + subdoc = doc.layers[i].document; + obj = nav4FindLayer(subdoc, id); + if (obj != null) + return obj; + } + return null; + } + + nav4FindElementsByName = + function (doc, name, elmlist) + { + var i; + var j; + var subdoc; + + for (i = 0; i < doc.images.length; ++i) + { + if (doc.images[i].name && name == doc.images[i].name) + { + elmlist[elmlist.length] = doc.images[i]; + } + } + + for (i = 0; i < doc.forms.length; ++i) + { + for (j = 0; j < doc.forms[i].elements.length; j++) + { + if (doc.forms[i].elements[j].name && name == doc.forms[i].elements[j].name) + { + elmlist[elmlist.length] = doc.forms[i].elements[j]; + } + } + + if (doc.forms[i].name && name == doc.forms[i].name) + { + elmlist[elmlist.length] = doc.forms[i]; + } + } + + for (i = 0; i < doc.anchors.length; ++i) + { + if (doc.anchors[i].name && name == doc.anchors[i].name) + { + elmlist[elmlist.length] = doc.anchors[i]; + } + } + + for (i = 0; i < doc.links.length; ++i) + { + if (doc.links[i].name && name == doc.links[i].name) + { + elmlist[elmlist.length] = doc.links[i]; + } + } + + for (i = 0; i < doc.applets.length; ++i) + { + if (doc.applets[i].name && name == doc.applets[i].name) + { + elmlist[elmlist.length] = doc.applets[i]; + } + } + + for (i = 0; i < doc.embeds.length; ++i) + { + if (doc.embeds[i].name && name == doc.embeds[i].name) + { + elmlist[elmlist.length] = doc.embeds[i]; + } + } + + for (i = 0; i < doc.layers.length; ++i) + { + if (doc.layers[i].name && name == doc.layers[i].name) + { + elmlist[elmlist.length] = doc.layers[i]; + } + + subdoc = doc.layers[i].document; + nav4FindElementsByName(subdoc, name, elmlist); + } + } + xbGetElementById = function (id, windowRef) { if (!windowRef) @@ -211,26 +232,30 @@ if (document.layers) } else if (document.all) { - xbGetElementById = function (id, windowRef) - { - if (!windowRef) windowRef = window; - var elm = windowRef.document.all[id]; - if (!elm) elm = null; - return elm; + xbGetElementById = + function (id, windowRef) + { + if (!windowRef) + { + windowRef = window; + } + var elm = windowRef.document.all[id]; + if (!elm) + { + elm = null; + } + return elm; }; xbGetElementsByName = function (name, windowRef) { - if (!windowRef) windowRef = window; + if (!windowRef) + windowRef = window; var i; - var idnamelist = windowRef.document.all.tags(name); + var idnamelist = windowRef.document.all[name]; var elmlist = new Array(); - if (!idnamelist) { - return null; - } - if (!idnamelist.length || idnamelist.name == name) { if (idnamelist) @@ -240,7 +265,7 @@ else if (document.all) { for (i = 0; i < idnamelist.length; i++) { - if (idnamelist.item(i).tagName == name) + if (idnamelist[i].name == name) elmlist[elmlist.length] = idnamelist[i]; } } @@ -251,43 +276,99 @@ else if (document.all) } else if (document.getElementById) { - xbGetElementById = function (id, windowRef) { if (!windowRef) windowRef = window; return windowRef.document.getElementById(id); }; - xbGetElementsByName = function (name, windowRef) { if (!windowRef) windowRef = window; return windowRef.document.getElementsByTagName(name); }; + xbGetElementById = + function (id, windowRef) + { + if (!windowRef) + { + windowRef = window; + } + return windowRef.document.getElementById(id); + }; + + xbGetElementsByName = + function (name, windowRef) + { + if (!windowRef) + { + windowRef = window; + } + return windowRef.document.getElementsByName(name); + }; } else { - xbGetElementById = function (id, windowRef) { return null; } - xbGetElementsByName = function (name, windowRef) { return new Array(); } -} + xbGetElementById = + function (id, windowRef) + { + return null; + }; -if (typeof(window.pageXOffset) == 'number') -{ - xbGetPageScrollX = function (windowRef) { if (!windowRef) windowRef = window; return windowRef.pageXOffset; }; - xbGetPageScrollY = function (windowRef) { if (!windowRef) windowRef = window; return windowRef.pageYOffset; }; + xbGetElementsByName = + function (name, windowRef) + { + return new Array(); + }; } -else if (document.all) + +function xbGetPageScrollX(windowRef) { - xbGetPageScrollX = function (windowRef) { if (!windowRef) windowRef = window; return windowRef.document.body.scrollLeft; }; - xbGetPageScrollY = function (windowRef) { if (!windowRef) windowRef = window; return windowRef.document.body.scrollTop; }; + if (!windowRef) + { + windowRef = window; + } + + if (typeof(windowRef.pageXOffset) == 'number') + { + return windowRef.pageXOffset; + } + + if (typeof(windowRef.document.body && windowRef.document.body.scrollLeft) == 'number') + { + return windowRef.document.body.scrollLeft; + } + + return 0; } -else + +function xbGetPageScrollY(windowRef) { - xbGetPageScrollX = function (windowRef) { return 0; }; - xbGetPageScrollY = function (windowRef) { return 0; }; + if (!windowRef) + { + windowRef = window; + } + + if (typeof(windowRef.pageYOffset) == 'number') + { + return windowRef.pageYOffset; + } + + if (typeof(windowRef.document.body && windowRef.document.body.scrollTop) == 'number') + { + return windowRef.document.body.scrollTop; + } + + return 0; } if (document.layers) { - xbSetInnerHTML = function (element, str) { element.document.write(str); element.document.close(); }; -} -else if (document.all || document.getElementById) -{ - xbSetInnerHTML = function (element, str) { if (typeof(element.innerHTML) != 'undefined') element.innerHTML = str; }; + xbSetInnerHTML = + function (element, str) + { + element.document.write(str); + element.document.close(); + }; } -else +else { - xbSetInnerHTML = function (element, str) {}; + xbSetInnerHTML = function (element, str) + { + if (typeof(element.innerHTML) != 'undefined') + { + element.innerHTML = str; + } + }; } - // eof: xbDOM.js diff --git a/slides/demo/browser/xbDebug.js b/slides/demo/browser/xbDebug.js index 88f600670..61978a9f7 100644 --- a/slides/demo/browser/xbDebug.js +++ b/slides/demo/browser/xbDebug.js @@ -1,13 +1,33 @@ /* -xbDebug.js revision: 0.003 2002-02-26 - -Contributor(s): Bob Clary, Netscape Communications, Copyright 2001 - -Netscape grants you a royalty free license to use, modify and -distribute this software provided that this copyright notice -appears on all copies. This software is provided "AS IS," -without a warranty of any kind. + * xbDebug.js + * $Revision$ $Date$ + */ + +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Netscape code. + * + * The Initial Developer of the Original Code is + * Netscape Corporation. + * Portions created by the Initial Developer are Copyright (C) 2001 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): Bob Clary + * + * ***** END LICENSE BLOCK ***** */ +/* ChangeLog: 2002-02-25: bclary - modified xbDebugTraceOject to make sure @@ -16,8 +36,8 @@ ChangeLog: 2002-02-07: bclary - modified xbDebug.prototype.close to not null the debug window reference. This can cause problems with - Internet Explorer if the page is refreshed. These issues will - be addressed at a later date. + Internet Explorer if the page is refreshed. These issues will + be addressed at a later date. */ function xbDebug() @@ -46,10 +66,10 @@ xbDebug.prototype.open = function () this.close(); this.debugwindow = window.open('about:blank', 'DEBUGWINDOW', 'height=400,width=600,resizable=yes,scrollbars=yes'); + this.debugwindow.moveTo(0,0); + window.focus(); - this.debugwindow.title = 'xbDebug Window'; this.debugwindow.document.write('xbDebug Window

Javascript Debug Window

'); - this.debugwindow.focus(); } xbDebug.prototype.close = function () @@ -83,6 +103,11 @@ window.onunload = function () { xbDEBUG.close(); } function xbDebugGetFunctionName(funcref) { + if (!funcref) + { + return ''; + } + if (funcref.name) return funcref.name; @@ -90,9 +115,42 @@ function xbDebugGetFunctionName(funcref) name = name.substring(name.indexOf(' ') + 1, name.indexOf('(')); funcref.name = name; + if (!name) alert('name not defined'); return name; } + +// emulate functionref.apply for IE mac and IE win < 5.5 +function xbDebugApplyFunction(funcname, funcref, thisref, argumentsref) +{ + var rv; + + if (!funcref) + { + alert('xbDebugApplyFunction: funcref is null'); + } + + if (typeof(funcref.apply) != 'undefined') + return funcref.apply(thisref, argumentsref); + + var applyexpr = 'thisref.xbDebug_orig_' + funcname + '('; + var i; + + for (i = 0; i < argumentsref.length; i++) + { + applyexpr += 'argumentsref[' + i + '],'; + } + + if (argumentsref.length > 0) + { + applyexpr = applyexpr.substring(0, applyexpr.length - 1); + } + + applyexpr += ')'; + + return eval(applyexpr); +} + function xbDebugCreateFunctionWrapper(scopename, funcname, precall, postcall) { var wrappedfunc; @@ -103,8 +161,10 @@ function xbDebugCreateFunctionWrapper(scopename, funcname, precall, postcall) wrappedfunc = function () { + var rv; + precall(scopename, funcname, arguments); - var rv = funcref.apply(this, arguments); + rv = xbDebugApplyFunction(funcname, funcref, scopeobject, arguments); postcall(scopename, funcname, arguments, rv); return rv; }; @@ -118,10 +178,33 @@ function xbDebugCreateFunctionWrapper(scopename, funcname, precall, postcall) scopeobject[funcname] = wrappedfunc; } +function xbDebugCreateMethodWrapper(contextname, classname, methodname, precall, postcall) +{ + var context = eval(contextname); + var methodref = context[classname].prototype[methodname]; + + context[classname].prototype['xbDebug_orig_' + methodname] = methodref; + + var wrappedmethod = function () + { + var rv; + // eval 'this' at method run time to pick up reference to the object's instance + var thisref = eval('this'); + // eval 'arguments' at method run time to pick up method's arguments + var argsref = arguments; + + precall(contextname + '.' + classname, methodname, argsref); + rv = xbDebugApplyFunction(methodname, methodref, thisref, argsref); + postcall(contextname + '.' + classname, methodname, argsref, rv); + return rv; + }; + + return wrappedmethod; +} + function xbDebugPersistToString(obj) { var s = ''; - var p; if (obj == null) return 'null'; @@ -138,7 +221,10 @@ function xbDebugPersistToString(obj) return obj + ''; } - return '[' + xbDebugGetFunctionName(obj.constructor) + ']'; + if (obj.constructor) + return '[' + xbDebugGetFunctionName(obj.constructor) + ']'; + + return null; } function xbDebugTraceBefore(scopename, funcname, funcarguments) @@ -191,19 +277,21 @@ function xbDebugTraceFunction(scopename, funcname) xbDebugCreateFunctionWrapper(scopename, funcname, xbDebugTraceBefore, xbDebugTraceAfter); } -function xbDebugTraceObject(scopename, objname) +function xbDebugTraceObject(contextname, classname) { - var objref = eval(scopename + '.' + objname); + var classref = eval(contextname + '.' + classname); var p; + var sp; - if (!objref || !objref.prototype) + if (!classref || !classref.prototype) return; - for (p in objref.prototype) + for (p in classref.prototype) { - if (typeof(objref.prototype[p]) == 'function' && (p+'').indexOf('xbDebug_orig') == -1) + sp = p + ''; + if (typeof(classref.prototype[sp]) == 'function' && (sp).indexOf('xbDebug_orig') == -1) { - xbDebugCreateFunctionWrapper(scopename + '.' + objname + '.prototype', p + '', xbDebugTraceBefore, xbDebugTraceAfter); + classref.prototype[sp] = xbDebugCreateMethodWrapper(contextname, classname, sp, xbDebugTraceBefore, xbDebugTraceAfter); } } } diff --git a/slides/demo/browser/xbStyle.js b/slides/demo/browser/xbStyle.js index 77cfef42a..1bfb125cc 100644 --- a/slides/demo/browser/xbStyle.js +++ b/slides/demo/browser/xbStyle.js @@ -1,35 +1,31 @@ /* -xbStyle.js Revision: 0.202 2002-02-11 - -Contributor(s): Bob Clary, Original Work, Copyright 2000 - Bob Clary, Netscape Communications, Copyright 2001 - -Netscape grants you a royalty free license to use, modify and -distribute this software provided that this copyright notice -appears on all copies. This software is provided "AS IS," -without a warranty of any kind. - -Change Log: - -2001-07-19: bclary - fixed function cssStyleGetLeft() and cssStyleGetTop() to - correctly handle the case where the initial style.left/style.top - are not initialized. This fixes positioning for relatively positioned - DIVS and as a result fixes behavior for ILAYERs exposed as relatively - positioned divs. -2001-10-02: bclary - added missing xbClipRect.getHeight/setHeight methods. - -2001-11-20: bclary - removed use of practical browser sniffer, - added object sniffing, and limited support for opera - note opera returns ints for HTMLElement.style.[left|top|height|width] etc. - -2002-02-11: v 0.201 bclary - with the help of Rob Johnston - found that the "if (document.getElementsByName)" test excluded - IE4. Added a test for document.all to enable IE4 to fully use - xbStyle. - -2002-03-12: v 0.202 Daniel Resare contributed a patch to cssStyleSetPage[X|Y]() which - handles the case where the element has no parentNode. -*/ + * xbStyle.js + * $Revision$ $Date$ + */ + +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Netscape code. + * + * The Initial Developer of the Original Code is + * Netscape Corporation. + * Portions created by the Initial Developer are Copyright (C) 2001 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): Bob Clary + * + * ***** END LICENSE BLOCK ***** */ function xbStyleNotSupported() {} @@ -124,7 +120,7 @@ xbClipRect.prototype.toString = xbClipRectToString; // into the HTMLElement.style object. We can use IE's HTMLElement.currentStyle // to get the effective values. In Gecko we will use the W3 DOM Style Standard getComputedStyle -function xbStyle(obj, position) +function xbStyle(obj, win, position) { if (typeof(obj) == 'object' && typeof(obj.style) != 'undefined') this.styleObj = obj.style; @@ -137,6 +133,7 @@ function xbStyle(obj, position) this.styleObj.position = position; } this.object = obj; + this.window = win ? win : window; } xbStyle.prototype.styleObj = null; @@ -154,24 +151,9 @@ function xbStyleGetEffectiveValue(propname) { var value = null; - // W3/Gecko - if (document.defaultView && document.defaultView.getComputedStyle) + if (this.window.document.defaultView && this.window.document.defaultView.getComputedStyle) { - if (navigator.family == 'gecko') - { - // xxxHack: work around Gecko getComputedStyle bugs... - switch(propname) - { - case 'clip': - return this.styleObj[propname]; - case 'top': - if (navigator.family == 'gecko' && navigator.version < 0.96 && this.styleObj.position == 'relative') - return this.object.offsetTop; - case 'left': - if (navigator.family == 'gecko' && navigator.version < 0.96 && this.styleObj.position == 'relative') - return this.object.offsetLeft; - } - } + // W3 // Note that propname is the name of the property in the CSS Style // Object. However the W3 method getPropertyValue takes the actual // property name from the CSS Style rule, i.e., propname is @@ -179,771 +161,51 @@ function xbStyleGetEffectiveValue(propname) var capIndex; var cappropname = propname; + while ( (capIndex = cappropname.search(/[A-Z]/)) != -1) { if (capIndex != -1) - cappropname = cappropname.substring(0, capIndex) + '-' + cappropname.substring(capIndex, capIndex).toLowerCase() + cappropname.substr(capIndex+1); + { + cappropname = cappropname.substring(0, capIndex) + '-' + cappropname.substring(capIndex, capIndex+1).toLowerCase() + cappropname.substr(capIndex+1); + } } - value = document.defaultView.getComputedStyle(this.object, '').getPropertyValue(cappropname); + value = this.window.document.defaultView.getComputedStyle(this.object, '').getPropertyValue(cappropname); // xxxHack for Gecko: if (!value && this.styleObj[propname]) + { value = this.styleObj[propname]; + } } else if (typeof(this.styleObj[propname]) == 'undefined') - value = xbStyleNotSupportStringValue(propname); - else - { - if (navigator.family != 'ie4' || navigator.version < 5) - { - // IE4+, Opera, NN4 - value = this.styleObj[propname]; - } - else - { - // IE5+ - value = this.object.currentStyle[propname]; - if (!value) - value = this.styleObj[propname]; - } - } - - return value; -} - -///////////////////////////////////////////////////////////// -// xbStyle.getClip() - -function cssStyleGetClip() -{ - var clip = this.getEffectiveValue('clip'); - - // hack opera - if (clip == 'rect()') - clip = ''; - - if (clip == '') - clip = 'rect(0px ' + this.getWidth() + 'px ' + this.getHeight() + 'px 0px)'; - - return clip; -} - -function nsxbStyleGetClip() -{ - var clip = this.styleObj.clip; - var rect = new xbClipRect(clip.top, clip.right, clip.bottom, clip.left); - return rect.toString(); -} - -///////////////////////////////////////////////////////////// -// xbStyle.setClip() - -function cssStyleSetClip(sClipString) -{ - this.styleObj.clip = sClipString; -} - -function nsxbStyleSetClip(sClipString) -{ - var rect = new xbClipRect(sClipString); - this.styleObj.clip.top = rect.top; - this.styleObj.clip.right = rect.right; - this.styleObj.clip.bottom = rect.bottom; - this.styleObj.clip.left = rect.left; -} - -///////////////////////////////////////////////////////////// -// xbStyle.getClipTop() - -function cssStyleGetClipTop() -{ - var clip = this.getClip() - var rect = new xbClipRect(clip); - return rect.top; -} - -function nsxbStyleGetClipTop() -{ - return this.styleObj.clip.top; -} - -///////////////////////////////////////////////////////////// -// xbStyle.setClipTop() - -function cssStyleSetClipTop(top) -{ - var clip = this.getClip(); - var rect = new xbClipRect(clip); - rect.top = top; - this.styleObj.clip = rect.toString(); -} - -function nsxbStyleSetClipTop(top) -{ - return this.styleObj.clip.top = top; -} - -///////////////////////////////////////////////////////////// -// xbStyle.getClipRight() - -function cssStyleGetClipRight() -{ - var clip = this.getClip(); - var rect = new xbClipRect(clip); - return rect.right; -} - -function nsxbStyleGetClipRight() -{ - return this.styleObj.clip.right; -} - -///////////////////////////////////////////////////////////// -// xbStyle.setClipRight() - -function cssStyleSetClipRight(right) -{ - var clip = this.getClip(); - var rect = new xbClipRect(clip); - rect.right = right; - this.styleObj.clip = rect.toString(); -} - -function nsxbStyleSetClipRight(right) -{ - return this.styleObj.clip.right = right; -} - -///////////////////////////////////////////////////////////// -// xbStyle.getClipBottom() - -function cssStyleGetClipBottom() -{ - var clip = this.getClip(); - var rect = new xbClipRect(clip); - return rect.bottom; -} - -function nsxbStyleGetClipBottom() -{ - return this.styleObj.clip.bottom; -} - -///////////////////////////////////////////////////////////// -// xbStyle.setClipBottom() - -function cssStyleSetClipBottom(bottom) -{ - var clip = this.getClip(); - var rect = new xbClipRect(clip); - rect.bottom = bottom; - this.styleObj.clip = rect.toString(); -} - -function nsxbStyleSetClipBottom(bottom) -{ - return this.styleObj.clip.bottom = bottom; -} - -///////////////////////////////////////////////////////////// -// xbStyle.getClipLeft() - -function cssStyleGetClipLeft() -{ - var clip = this.getClip(); - var rect = new xbClipRect(clip); - return rect.left; -} - -function nsxbStyleGetClipLeft() -{ - return this.styleObj.clip.left; -} - -///////////////////////////////////////////////////////////// -// xbStyle.setClipLeft() - -function cssStyleSetClipLeft(left) -{ - var clip = this.getClip(); - var rect = new xbClipRect(clip); - rect.left = left; - this.styleObj.clip = rect.toString(); -} - -function nsxbStyleSetClipLeft(left) -{ - return this.styleObj.clip.left = left; -} - -///////////////////////////////////////////////////////////// -// xbStyle.getClipWidth() - -function cssStyleGetClipWidth() -{ - var clip = this.getClip(); - var rect = new xbClipRect(clip); - return rect.getWidth(); -} - -function nsxbStyleGetClipWidth() -{ - return this.styleObj.clip.width; -} - -///////////////////////////////////////////////////////////// -// xbStyle.setClipWidth() - -function cssStyleSetClipWidth(width) -{ - var clip = this.getClip(); - var rect = new xbClipRect(clip); - rect.setWidth(width); - this.styleObj.clip = rect.toString(); -} - -function nsxbStyleSetClipWidth(width) -{ - return this.styleObj.clip.width = width; -} - -///////////////////////////////////////////////////////////// -// xbStyle.getClipHeight() - -function cssStyleGetClipHeight() -{ - var clip = this.getClip(); - var rect = new xbClipRect(clip); - return rect.getHeight(); -} - -function nsxbStyleGetClipHeight() -{ - return this.styleObj.clip.height; -} - -///////////////////////////////////////////////////////////// -// xbStyle.setClipHeight() - -function cssStyleSetClipHeight(height) -{ - var clip = this.getClip(); - var rect = new xbClipRect(clip); - rect.setHeight(height); - this.styleObj.clip = rect.toString(); -} - -function nsxbStyleSetClipHeight(height) -{ - return this.styleObj.clip.height = height; -} - -// the CSS attributes left,top are for absolutely positioned elements -// measured relative to the containing element. for relatively positioned -// elements, left,top are measured from the element's normal inline position. -// getLeft(), setLeft() operate on this type of coordinate. -// -// to allow dynamic positioning the getOffsetXXX and setOffsetXXX methods are -// defined to return and set the position of either an absolutely or relatively -// positioned element relative to the containing element. -// -// - -///////////////////////////////////////////////////////////////////////////// -// xbStyle.getLeft() - -function cssStyleGetLeft() -{ - var left = this.getEffectiveValue('left'); - if (typeof(left) == 'number') - return left; - - if (left != '' && left.indexOf('px') == -1) - { - xbDEBUG.dump('xbStyle.getLeft: Element ID=' + this.object.id + ' does not use pixels as units. left=' + left + ' Click Ok to continue, Cancel to Abort'); - return 0; - } - - if (left == '') - left = this.styleObj.left = '0px'; - - return xbToInt(left); -} - -function nsxbStyleGetLeft() -{ - return this.styleObj.left; -} - -///////////////////////////////////////////////////////////////////////////// -// xbStyle.setLeft() - -function cssStyleSetLeft(left) -{ - if (typeof(this.styleObj.left) == 'number') - this.styleObj.left = left; - else - this.styleObj.left = left + 'px'; -} - -function nsxbStyleSetLeft(left) -{ - this.styleObj.left = left; -} - -///////////////////////////////////////////////////////////////////////////// -// xbStyle.getTop() - -function cssStyleGetTop() -{ - var top = this.getEffectiveValue('top'); - if (typeof(top) == 'number') - return top; - - if (top != '' && top.indexOf('px') == -1) - { - xbDEBUG.dump('xbStyle.getTop: Element ID=' + this.object.id + ' does not use pixels as units. top=' + top + ' Click Ok to continue, Cancel to Abort'); - return 0; - } - - if (top == '') - top = this.styleObj.top = '0px'; - - return xbToInt(top); -} - -function nsxbStyleGetTop() -{ - return this.styleObj.top; -} - -///////////////////////////////////////////////////////////////////////////// -// xbStyle.setTop() - -function cssStyleSetTop(top) -{ - if (typeof(this.styleObj.top) == 'number') - this.styleObj.top = top; - else - this.styleObj.top = top + 'px'; -} - -function nsxbStyleSetTop(top) -{ - this.styleObj.top = top; -} - - -///////////////////////////////////////////////////////////////////////////// -// xbStyle.getPageX() - -function cssStyleGetPageX() -{ - var x = 0; - var elm = this.object; - var elmstyle; - var position; - - //xxxHack: Due to limitations in Gecko's (0.9.6) ability to determine the - // effective position attribute , attempt to use offsetXXX - - if (typeof(elm.offsetLeft) == 'number') - { - while (elm) - { - x += elm.offsetLeft; - elm = elm.offsetParent; - } - } - else - { - while (elm) - { - if (elm.style) - { - elmstyle = new xbStyle(elm); - position = elmstyle.getEffectiveValue('position'); - if (position != '' && position != 'static') - x += elmstyle.getLeft(); - } - elm = elm.parentNode; - } - } - - return x; -} - -function nsxbStyleGetPageX() -{ - return this.styleObj.pageX; -} - -///////////////////////////////////////////////////////////////////////////// -// xbStyle.setPageX() - -function cssStyleSetPageX(x) -{ - var xParent = 0; - var elm = this.object.parentNode; - var elmstyle; - var position; - - //xxxHack: Due to limitations in Gecko's (0.9.6) ability to determine the - // effective position attribute , attempt to use offsetXXX - - if (elm && typeof(elm.offsetLeft) == 'number') - { - while (elm) - { - xParent += elm.offsetLeft; - elm = elm.offsetParent; - } - } - else - { - while (elm) - { - if (elm.style) - { - elmstyle = new xbStyle(elm); - position = elmstyle.getEffectiveValue('position'); - if (position != '' && position != 'static') - xParent += elmstyle.getLeft(); - } - elm = elm.parentNode; - } - } - - x -= xParent; - - this.setLeft(x); -} - -function nsxbStyleSetPageX(x) -{ - this.styleObj.x = this.styleObj.x + x - this.styleObj.pageX; -} - -///////////////////////////////////////////////////////////////////////////// -// xbStyle.getPageY() - -function cssStyleGetPageY() -{ - var y = 0; - var elm = this.object; - var elmstyle; - var position; - - //xxxHack: Due to limitations in Gecko's (0.9.6) ability to determine the - // effective position attribute , attempt to use offsetXXX - - if (typeof(elm.offsetTop) == 'number') { - while (elm) - { - y += elm.offsetTop; - elm = elm.offsetParent; - } + value = xbStyleNotSupportStringValue(propname); } - else + else if (typeof(this.object.currentStyle) != 'undefined') { - while (elm) + // IE5+ + value = this.object.currentStyle[propname]; + if (!value) { - if (elm.style) - { - elmstyle = new xbStyle(elm); - position = elmstyle.getEffectiveValue('position'); - if (position != '' && position != 'static') - y += elmstyle.getTop(); - } - elm = elm.parentNode; + value = this.styleObj[propname]; } - } - - return y; -} - -function nsxbStyleGetPageY() -{ - return this.styleObj.pageY; -} -///////////////////////////////////////////////////////////////////////////// -// xbStyle.setPageY() - -function cssStyleSetPageY(y) -{ - var yParent = 0; - var elm = this.object.parentNode; - var elmstyle; - var position; - - //xxxHack: Due to limitations in Gecko's (0.9.6) ability to determine the - // effective position attribute , attempt to use offsetXXX - - if (elm && typeof(elm.offsetTop) == 'number') - { - while (elm) - { - yParent += elm.offsetTop; - elm = elm.offsetParent; - } - } - else - { - while (elm) + if (propname == 'clip' && !value) { - if (elm.style) - { - elmstyle = new xbStyle(elm); - position = elmstyle.getEffectiveValue('position'); - if (position != '' && position != 'static') - yParent += elmstyle.getTop(); - } - elm = elm.parentNode; + // clip is not stored in IE5/6 handle separately + value = 'rect(' + this.object.currentStyle.clipTop + ', ' + this.object.currentStyle.clipRight + ', ' + this.object.currentStyle.clipBottom + ', ' + this.object.currentStyle.clipLeft + ')'; } } - - y -= yParent; - - this.setTop(y); -} - -function nsxbStyleSetPageY(y) -{ - this.styleObj.y = this.styleObj.y + y - this.styleObj.pageY; -} - -///////////////////////////////////////////////////////////////////////////// -// xbStyle.getHeight() - -function cssStyleGetHeight() -{ - var height = this.getEffectiveValue('height'); - if (typeof(height) == 'number') - return height; - - if ((height == 'auto' || height.indexOf('%') != -1) && typeof(this.object.offsetHeight) == 'number') - height = this.object.offsetHeight + 'px'; - - if (height != '' && height != 'auto' && height.indexOf('px') == -1) - { - xbDEBUG.dump('xbStyle.getHeight: Element ID=' + this.object.id + ' does not use pixels as units. height=' + height + ' Click Ok to continue, Cancel to Abort'); - return 0; - } - - height = xbToInt(height); - - return height; -} - -function nsxbStyleGetHeight() -{ - //if (this.styleObj.document && this.styleObj.document.height) - // return this.styleObj.document.height; - - return this.styleObj.clip.height; -} - -///////////////////////////////////////////////////////////////////////////// -// xbStyle.setHeight() - -function cssStyleSetHeight(height) -{ - if (typeof(this.styleObj.height) == 'number') - this.styleObj.height = height; - else - this.styleObj.height = height + 'px'; -} - -function nsxbStyleSetHeight(height) -{ - this.styleObj.clip.height = height; -} - -///////////////////////////////////////////////////////////////////////////// -// xbStyle.getWidth() - -function cssStyleGetWidth() -{ - var width = this.getEffectiveValue('width'); - if (typeof(width) == 'number') - return width; - - if ((width == 'auto' || width.indexOf('%') != -1) && typeof(this.object.offsetWidth) == 'number') - width = this.object.offsetWidth + 'px'; - - if (width != '' && width != 'auto' && width.indexOf('px') == -1) - { - xbDEBUG.dump('xbStyle.getWidth: Element ID=' + this.object.id + ' does not use pixels as units. width=' + width + ' Click Ok to continue, Cancel to Abort'); - return 0; - } - - width = xbToInt(width); - - return width; -} - -function nsxbStyleGetWidth() -{ - //if (this.styleObj.document && this.styleObj.document.width) - // return this.styleObj.document.width; - - return this.styleObj.clip.width; -} - -///////////////////////////////////////////////////////////////////////////// -// xbStyle.setWidth() - -function cssStyleSetWidth(width) -{ - if (typeof(this.styleObj.width) == 'number') - this.styleObj.width = width; else - this.styleObj.width = width + 'px'; -} - -// netscape will not dynamically change the width of a -// layer. It will only happen upon a refresh. -function nsxbStyleSetWidth(width) -{ - this.styleObj.clip.width = width; -} - -///////////////////////////////////////////////////////////////////////////// - -///////////////////////////////////////////////////////////////////////////// -// xbStyle.getVisibility() - -function cssStyleGetVisibility() -{ - return this.getEffectiveValue('visibility'); -} - -function nsxbStyleGetVisibility() -{ - switch(this.styleObj.visibility) { - case 'hide': - return 'hidden'; - case 'show': - return 'visible'; + // IE4+, Opera, NN4 + value = this.styleObj[propname]; } - return ''; -} - -///////////////////////////////////////////////////////////////////////////// -// xbStyle.setVisibility() - -function cssStyleSetVisibility(visibility) -{ - this.styleObj.visibility = visibility; -} - -function nsxbStyleSetVisibility(visibility) -{ - switch(visibility) - { - case 'hidden': - visibility = 'hide'; - break; - case 'visible': - visibility = 'show'; - break; - case 'inherit': - break; - default: - visibility = 'show'; - break; - } - this.styleObj.visibility = visibility; -} -///////////////////////////////////////////////////////////////////////////// -// xbStyle.getzIndex() - -function cssStyleGetzIndex() -{ - return xbToInt(this.getEffectiveValue('zIndex')); -} - -function nsxbStyleGetzIndex() -{ - return this.styleObj.zIndex; -} - -///////////////////////////////////////////////////////////////////////////// -// xbStyle.setzIndex() - -function cssStyleSetzIndex(zIndex) -{ - this.styleObj.zIndex = zIndex; -} - -function nsxbStyleSetzIndex(zIndex) -{ - this.styleObj.zIndex = zIndex; -} - -///////////////////////////////////////////////////////////////////////////// -// xbStyle.getBackgroundColor() - -function cssStyleGetBackgroundColor() -{ - return this.getEffectiveValue('backgroundColor'); -} - -function nsxbStyleGetBackgroundColor() -{ - return this.styleObj.bgColor; -} - -///////////////////////////////////////////////////////////////////////////// -// xbStyle.setBackgroundColor() - -function cssStyleSetBackgroundColor(color) -{ - this.styleObj.backgroundColor = color; -} - -function nsxbStyleSetBackgroundColor(color) -{ - if (color) - { - this.styleObj.bgColor = color; - this.object.document.bgColor = color; - this.resizeTo(this.getWidth(), this.getHeight()); - } -} - -///////////////////////////////////////////////////////////////////////////// -// xbStyle.getColor() - -function cssStyleGetColor() -{ - return this.getEffectiveValue('color'); -} - -function nsxbStyleGetColor() -{ - return '#ffffff'; -} - -///////////////////////////////////////////////////////////////////////////// -// xbStyle.setColor() - -function cssStyleSetColor(color) -{ - this.styleObj.color = color; -} - -function nsxbStyleSetColor(color) -{ - this.object.document.fgColor = color; + return value; } - ///////////////////////////////////////////////////////////////////////////// // xbStyle.moveAbove() @@ -1006,166 +268,6 @@ function xbStyleResizeTo(x, y) this.setHeight(y); } -//////////////////////////////////////////////////////////////////////// -// Navigator 4.x resizing... - -function nsxbStyleOnresize() -{ - if (saveInnerWidth != xbGetWindowWidth() || saveInnerHeight != xbGetWindowHeight()) - location.reload(); - - return false; -} - -///////////////////////////////////////////////////////////////////////////// -// xbStyle.setInnerHTML() - -function xbSetInnerHTML(str) -{ - if (typeof(this.object.innerHTML) != 'undefined') - this.object.innerHTML = str; -} - -function nsxbSetInnerHTML(str) -{ - this.object.document.open('text/html'); - this.object.document.write(str); - this.object.document.close(); -} - -//////////////////////////////////////////////////////////////////////// -// Extensions to xbStyle that are not supported by Netscape Navigator 4 -// but that provide cross browser implementations of properties for -// Mozilla, Gecko, Netscape 6.x and Opera - -///////////////////////////////////////////////////////////////////////////// -// xbStyle.getBorderTopWidth() - -function cssStyleGetBorderTopWidth() -{ - return xbToInt(this.getEffectiveValue('borderTopWidth')); -} - -///////////////////////////////////////////////////////////////////////////// -// xbStyle.getBorderRightWidth() - -function cssStyleGetBorderRightWidth() -{ - return xbToInt(this.getEffectiveValue('borderRightWidth')); -} - -///////////////////////////////////////////////////////////////////////////// -// xbStyle.getBorderBottomWidth() - -function cssStyleGetBorderBottomWidth() -{ - return xbToInt(this.getEffectiveValue('borderLeftWidth')); -} - -///////////////////////////////////////////////////////////////////////////// -// xbStyle.getBorderLeftWidth() - -function cssStyleGetBorderLeftWidth() -{ - return xbToInt(this.getEffectiveValue('borderLeftWidth')); -} - -///////////////////////////////////////////////////////////////////////////// -// xbStyle.getMarginTop() - -function cssStyleGetMarginTop() -{ - return xbToInt(this.getEffectiveValue('marginTop')); -} - -///////////////////////////////////////////////////////////////////////////// -// xbStyle.getMarginRight() - -function cssStyleGetMarginRight() -{ - return xbToInt(this.getEffectiveValue('marginRight')); -} - -///////////////////////////////////////////////////////////////////////////// -// xbStyle.getMarginBottom() - -function cssStyleGetMarginBottom() -{ - return xbToInt(this.getEffectiveValue('marginBottom')); -} - -///////////////////////////////////////////////////////////////////////////// -// xbStyle.getMarginLeft() - -function cssStyleGetMarginLeft() -{ - return xbToInt(this.getEffectiveValue('marginLeft')); -} - -///////////////////////////////////////////////////////////////////////////// -// xbStyle.getPaddingTop() - -function cssStyleGetPaddingTop() -{ - return xbToInt(this.getEffectiveValue('paddingTop')); -} - -///////////////////////////////////////////////////////////////////////////// -// xbStyle.getPaddingRight() - -function cssStyleGetPaddingRight() -{ - return xbToInt(this.getEffectiveValue('paddingRight')); -} - -///////////////////////////////////////////////////////////////////////////// -// xbStyle.getPaddingBottom() - -function cssStyleGetPaddingBottom() -{ - return xbToInt(this.getEffectiveValue('paddingBottom')); -} - -///////////////////////////////////////////////////////////////////////////// -// xbStyle.getPaddingLeft() - -function cssStyleGetPaddingLeft() -{ - return xbToInt(this.getEffectiveValue('paddingLeft')); -} - -///////////////////////////////////////////////////////////////////////////// -// xbStyle.getClientTop() - -function cssStyleGetClientTop() -{ - return this.getTop() - this.getMarginTop() - this.getBorderTopWidth() - this.getPaddingTop(); -} - -///////////////////////////////////////////////////////////////////////////// -// xbStyle.getClientLeft() - -function cssStyleGetClientLeft() -{ - return this.getLeft() - this.getMarginLeft() - this.getBorderLeftWidth() - this.getPaddingLeft(); -} - -///////////////////////////////////////////////////////////////////////////// -// xbStyle.getClientWidth() - -function cssStyleGetClientWidth() -{ - return this.getMarginLeft() + this.getBorderLeftWidth() + this.getPaddingLeft() + this.getWidth() + this.getPaddingRight() + this.getBorderRightWidth() + this.getMarginRight(); -} - -///////////////////////////////////////////////////////////////////////////// -// xbStyle.getClientHeight() - -function cssStyleGetClientHeight() -{ - return this.getMarginTop() + this.getBorderTopWidth() + this.getPaddingTop() + this.getHeight() + this.getPaddingBottom() + this.getBorderBottomWidth() + this.getMarginBottom(); -} - //////////////////////////////////////////////////////////////////////// xbStyle.prototype.getEffectiveValue = xbStyleGetEffectiveValue; @@ -1179,171 +281,15 @@ xbStyle.prototype.resizeTo = xbStyleResizeTo; if (document.all || document.getElementsByName) { - xbStyle.prototype.getClip = cssStyleGetClip; - xbStyle.prototype.setClip = cssStyleSetClip; - xbStyle.prototype.getClipTop = cssStyleGetClipTop; - xbStyle.prototype.setClipTop = cssStyleSetClipTop; - xbStyle.prototype.getClipRight = cssStyleGetClipRight; - xbStyle.prototype.setClipRight = cssStyleSetClipRight; - xbStyle.prototype.getClipBottom = cssStyleGetClipBottom; - xbStyle.prototype.setClipBottom = cssStyleSetClipBottom; - xbStyle.prototype.getClipLeft = cssStyleGetClipLeft; - xbStyle.prototype.setClipLeft = cssStyleSetClipLeft; - xbStyle.prototype.getClipWidth = cssStyleGetClipWidth; - xbStyle.prototype.setClipWidth = cssStyleSetClipWidth; - xbStyle.prototype.getClipHeight = cssStyleGetClipHeight; - xbStyle.prototype.setClipHeight = cssStyleSetClipHeight; - xbStyle.prototype.getLeft = cssStyleGetLeft; - xbStyle.prototype.setLeft = cssStyleSetLeft; - xbStyle.prototype.getTop = cssStyleGetTop; - xbStyle.prototype.setTop = cssStyleSetTop; - xbStyle.prototype.getPageX = cssStyleGetPageX; - xbStyle.prototype.setPageX = cssStyleSetPageX; - xbStyle.prototype.getPageY = cssStyleGetPageY; - xbStyle.prototype.setPageY = cssStyleSetPageY; - xbStyle.prototype.getVisibility = cssStyleGetVisibility; - xbStyle.prototype.setVisibility = cssStyleSetVisibility; - xbStyle.prototype.getzIndex = cssStyleGetzIndex; - xbStyle.prototype.setzIndex = cssStyleSetzIndex; - xbStyle.prototype.getHeight = cssStyleGetHeight; - xbStyle.prototype.setHeight = cssStyleSetHeight; - xbStyle.prototype.getWidth = cssStyleGetWidth; - xbStyle.prototype.setWidth = cssStyleSetWidth; - xbStyle.prototype.getBackgroundColor = cssStyleGetBackgroundColor; - xbStyle.prototype.setBackgroundColor = cssStyleSetBackgroundColor; - xbStyle.prototype.getColor = cssStyleGetColor; - xbStyle.prototype.setColor = cssStyleSetColor; - xbStyle.prototype.setInnerHTML = xbSetInnerHTML; - xbStyle.prototype.getBorderTopWidth = cssStyleGetBorderTopWidth; - xbStyle.prototype.getBorderRightWidth = cssStyleGetBorderRightWidth; - xbStyle.prototype.getBorderBottomWidth = cssStyleGetBorderBottomWidth; - xbStyle.prototype.getBorderLeftWidth = cssStyleGetBorderLeftWidth; - xbStyle.prototype.getMarginLeft = cssStyleGetMarginLeft; - xbStyle.prototype.getMarginTop = cssStyleGetMarginTop; - xbStyle.prototype.getMarginRight = cssStyleGetMarginRight; - xbStyle.prototype.getMarginBottom = cssStyleGetMarginBottom; - xbStyle.prototype.getMarginLeft = cssStyleGetMarginLeft; - xbStyle.prototype.getPaddingTop = cssStyleGetPaddingTop; - xbStyle.prototype.getPaddingRight = cssStyleGetPaddingRight; - xbStyle.prototype.getPaddingBottom = cssStyleGetPaddingBottom; - xbStyle.prototype.getPaddingLeft = cssStyleGetPaddingLeft; - xbStyle.prototype.getClientTop = cssStyleGetClientTop; - xbStyle.prototype.getClientLeft = cssStyleGetClientLeft; - xbStyle.prototype.getClientWidth = cssStyleGetClientWidth; - xbStyle.prototype.getClientHeight = cssStyleGetClientHeight; + xblibrary.loadScript('xbStyle-css.js'); } else if (document.layers) { - xbStyle.prototype.getClip = nsxbStyleGetClip; - xbStyle.prototype.setClip = nsxbStyleSetClip; - xbStyle.prototype.getClipTop = nsxbStyleGetClipTop; - xbStyle.prototype.setClipTop = nsxbStyleSetClipTop; - xbStyle.prototype.getClipRight = nsxbStyleGetClipRight; - xbStyle.prototype.setClipRight = nsxbStyleSetClipRight; - xbStyle.prototype.getClipBottom = nsxbStyleGetClipBottom; - xbStyle.prototype.setClipBottom = nsxbStyleSetClipBottom; - xbStyle.prototype.getClipLeft = nsxbStyleGetClipLeft; - xbStyle.prototype.setClipLeft = nsxbStyleSetClipLeft; - xbStyle.prototype.getClipWidth = nsxbStyleGetClipWidth; - xbStyle.prototype.setClipWidth = nsxbStyleSetClipWidth; - xbStyle.prototype.getClipHeight = nsxbStyleGetClipHeight; - xbStyle.prototype.setClipHeight = nsxbStyleSetClipHeight; - xbStyle.prototype.getLeft = nsxbStyleGetLeft; - xbStyle.prototype.setLeft = nsxbStyleSetLeft; - xbStyle.prototype.getTop = nsxbStyleGetTop; - xbStyle.prototype.setTop = nsxbStyleSetTop; - xbStyle.prototype.getPageX = nsxbStyleGetPageX; - xbStyle.prototype.setPageX = nsxbStyleSetPageX; - xbStyle.prototype.getPageY = nsxbStyleGetPageY; - xbStyle.prototype.setPageY = nsxbStyleSetPageY; - xbStyle.prototype.getVisibility = nsxbStyleGetVisibility; - xbStyle.prototype.setVisibility = nsxbStyleSetVisibility; - xbStyle.prototype.getzIndex = nsxbStyleGetzIndex; - xbStyle.prototype.setzIndex = nsxbStyleSetzIndex; - xbStyle.prototype.getHeight = nsxbStyleGetHeight; - xbStyle.prototype.setHeight = nsxbStyleSetHeight; - xbStyle.prototype.getWidth = nsxbStyleGetWidth; - xbStyle.prototype.setWidth = nsxbStyleSetWidth; - xbStyle.prototype.getBackgroundColor = nsxbStyleGetBackgroundColor; - xbStyle.prototype.setBackgroundColor = nsxbStyleSetBackgroundColor; - xbStyle.prototype.getColor = nsxbStyleGetColor; - xbStyle.prototype.setColor = nsxbStyleSetColor; - xbStyle.prototype.setInnerHTML = nsxbSetInnerHTML; - xbStyle.prototype.getBorderTopWidth = xbStyleNotSupported; - xbStyle.prototype.getBorderRightWidth = xbStyleNotSupported; - xbStyle.prototype.getBorderBottomWidth = xbStyleNotSupported; - xbStyle.prototype.getBorderLeftWidth = xbStyleNotSupported; - xbStyle.prototype.getMarginLeft = xbStyleNotSupported; - xbStyle.prototype.getMarginTop = xbStyleNotSupported; - xbStyle.prototype.getMarginRight = xbStyleNotSupported; - xbStyle.prototype.getMarginBottom = xbStyleNotSupported; - xbStyle.prototype.getMarginLeft = xbStyleNotSupported; - xbStyle.prototype.getPaddingTop = xbStyleNotSupported; - xbStyle.prototype.getPaddingRight = xbStyleNotSupported; - xbStyle.prototype.getPaddingBottom = xbStyleNotSupported; - xbStyle.prototype.getPaddingLeft = xbStyleNotSupported; - xbStyle.prototype.getClientTop = xbStyleNotSupported; - xbStyle.prototype.getClientLeft = xbStyleNotSupported; - xbStyle.prototype.getClientWidth = xbStyleNotSupported; - xbStyle.prototype.getClientHeight = xbStyleNotSupported; - - window.saveInnerWidth = window.innerWidth; - window.saveInnerHeight = window.innerHeight; - - window.onresize = nsxbStyleOnresize; - + xblibrary.loadScript('xbStyle-nn4.js'); } else { - xbStyle.prototype.toString = xbStyleNotSupported; - xbStyle.prototype.getClip = xbStyleNotSupported; - xbStyle.prototype.setClip = xbStyleNotSupported; - xbStyle.prototype.getClipTop = xbStyleNotSupported; - xbStyle.prototype.setClipTop = xbStyleNotSupported; - xbStyle.prototype.getClipRight = xbStyleNotSupported; - xbStyle.prototype.setClipRight = xbStyleNotSupported; - xbStyle.prototype.getClipBottom = xbStyleNotSupported; - xbStyle.prototype.setClipBottom = xbStyleNotSupported; - xbStyle.prototype.getClipLeft = xbStyleNotSupported; - xbStyle.prototype.setClipLeft = xbStyleNotSupported; - xbStyle.prototype.getClipWidth = xbStyleNotSupported; - xbStyle.prototype.setClipWidth = xbStyleNotSupported; - xbStyle.prototype.getClipHeight = xbStyleNotSupported; - xbStyle.prototype.setClipHeight = xbStyleNotSupported; - xbStyle.prototype.getLeft = xbStyleNotSupported; - xbStyle.prototype.setLeft = xbStyleNotSupported; - xbStyle.prototype.getTop = xbStyleNotSupported; - xbStyle.prototype.setTop = xbStyleNotSupported; - xbStyle.prototype.getVisibility = xbStyleNotSupported; - xbStyle.prototype.setVisibility = xbStyleNotSupported; - xbStyle.prototype.getzIndex = xbStyleNotSupported; - xbStyle.prototype.setzIndex = xbStyleNotSupported; - xbStyle.prototype.getHeight = xbStyleNotSupported; - xbStyle.prototype.setHeight = xbStyleNotSupported; - xbStyle.prototype.getWidth = xbStyleNotSupported; - xbStyle.prototype.setWidth = xbStyleNotSupported; - xbStyle.prototype.getBackgroundColor = xbStyleNotSupported; - xbStyle.prototype.setBackgroundColor = xbStyleNotSupported; - xbStyle.prototype.getColor = xbStyleNotSupported; - xbStyle.prototype.setColor = xbStyleNotSupported; - xbStyle.prototype.setInnerHTML = xbStyleNotSupported; - xbStyle.prototype.getBorderTopWidth = xbStyleNotSupported; - xbStyle.prototype.getBorderRightWidth = xbStyleNotSupported; - xbStyle.prototype.getBorderBottomWidth = xbStyleNotSupported; - xbStyle.prototype.getBorderLeftWidth = xbStyleNotSupported; - xbStyle.prototype.getMarginLeft = xbStyleNotSupported; - xbStyle.prototype.getMarginTop = xbStyleNotSupported; - xbStyle.prototype.getMarginRight = xbStyleNotSupported; - xbStyle.prototype.getMarginBottom = xbStyleNotSupported; - xbStyle.prototype.getMarginLeft = xbStyleNotSupported; - xbStyle.prototype.getPaddingTop = xbStyleNotSupported; - xbStyle.prototype.getPaddingRight = xbStyleNotSupported; - xbStyle.prototype.getPaddingBottom = xbStyleNotSupported; - xbStyle.prototype.getPaddingLeft = xbStyleNotSupported; - xbStyle.prototype.getClientTop = xbStyleNotSupported; - xbStyle.prototype.getClientLeft = xbStyleNotSupported; - xbStyle.prototype.getClientWidth = xbStyleNotSupported; - xbStyle.prototype.getClientHeight = xbStyleNotSupported; + xblibrary.loadScript('xbStyle-not-supported.js'); } -- 2.40.0