Log in

View Full Version : prehistoric version of dynamic_drive.js



edwardsmarkf
03-29-2021, 06:49 PM
hello -

i am using probably a prehistoric version of dynamic_drive.js.

today i had to make the following changes:

line 37:
OLD: + ( (typeof x_position!="undefined" && x_position.indexOf("right")!=-1)
NEW: + ( (typeof x_position!="undefined" && x_position.toString().indexOf("right")!=-1)

line 53:
OLD: + ( (typeof y_position!="undefined" && y_position.indexOf("bottom")!=-1
NEW: + ( (typeof y_position!="undefined" && y_position.toString().indexOf("bottom")!=-1

i believe a new version of google-chrome "broke" the code.

or should i be using a much newer version of dynamic_drive.js? maybe this version was written by your grandfather? :D


/***********************************************
* Drop Down/ Overlapping Content- ▒ Dynamic Drive (www.dynamicdrive.com)
* This notice must stay intact for legal use.
* Visit http://www.dynamicdrive.com/ for full source code
*
* 2021-03-28 -- channged _position.indexOf( to _position.toString().indexOf(
***********************************************/

function getposOffset(overlay, offsettype){
var totaloffset=(offsettype=="left")? overlay.offsetLeft : overlay.offsetTop;
var parentEl=overlay.offsetParent;
while (parentEl!=null){
totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
parentEl=parentEl.offsetParent;
}
return totaloffset;
}

var globalCurobjOffsetWidth = 0 ; // save values in case
var globalCurobjOffsetHeight = 0 ; // the popup form comes thru without an offsetWidth/offsetHeight

function overlay(curobj, subobjstr, x_position, y_position, x_offset, y_offset ){
if (document.getElementById){
var subobj=document.getElementById(subobjstr)
subobj.style.display=(subobj.style.display!="block")? "block" : "none"

var xpos='';
var ypos='';

if ( curobj.offsetWidth > 0 ) { // for some reason, offsetWidth is coming thru as zero
// on the popup form

if ( x_position == parseInt(x_position) ) {
xpos=x_position;
} else {
xpos=getposOffset(curobj, "left")
+ ( (typeof x_position!="undefined" && x_position.toString().indexOf("right")!=-1)
? -(subobj.offsetWidth-curobj.offsetWidth)
: 0
)
;
};
globalCurobjOffsetWidth = xpos ;
} else {
xpos = globalCurobjOffsetWidth + 20 ;
};

if ( curobj.offsetHeight > 0 ) { // again, for some reason, offsetHeight comes thru as zero
if ( y_position == parseInt(y_position) ) {
ypos=y_position;
} else {
ypos=getposOffset(curobj, "top")
+ ( (typeof y_position!="undefined" && y_position.toString().indexOf("bottom")!=-1)
? curobj.offsetHeight
: 0
)
;
};
globalCurobjOffsetHeight = ypos ;
} else {
ypos = globalCurobjOffsetHeight + 20 ;
};

if ( x_offset == parseInt(x_offset) ) {
xpos += parseInt(x_offset); // 2007-06-07 - added parseInt (not tested before?)
};
if ( y_offset == parseInt(y_offset) ) {
ypos += parseInt(y_offset); // 2007-06-07 - added parseInt[
};

//alert ( xpos + '<-->' + ypos );
subobj.style.left=xpos+"px"
subobj.style.top=ypos+"px"
return false;
} else {
return true;
};
}

function overlayclose(subobj){
document.getElementById(subobj).style.display="none"
}