PDA

View Full Version : What parameters should I pass to my construction function???


JlynnMc10
02-11-2003, 03:04 PM
How would I add the below ConstructObject() and InitialiseScrollableArea() functions to my current _create() function so that my menus would be scrollable. I just don't know what parameters to pass to ConstructObject in the Initialise fuction because I am confused on how to use document.all[i].

When create is called it looks like this: _create(document.all[i],tree) Where tree is a multilevel array containing all the menu text

function _create(e,ary){
var str = new String();
var strNewP
var menuId = _menus.length;
str = '<DIV ID="_div_'
+ menuId
+ '" STYLE="visibility:hidden;position:absolute;top:0;left:0;width:'
+ e.attribs["width"]
+ ';height:10;background-color:black;">';
e.insertAdjacentHTML("AfterEnd",str);
var thismenu = document.all.item("_div_" + menuId);
_menus[menuId] = thismenu;
thismenu.menuId = menuId;
thismenu.close = _close;
thismenu.menuParent = null;
thismenu.menuChild = null;
thismenu.highlightBG = e.attribs["highlight"];
thismenu.normalBG = e.attribs["background"];
thismenu.menuOffset = e.attribs["menu-offset"];
thismenu.menuTopoffset = e.attribs["menu-topoffset"];
thismenu.waitDelay = e.attribs


for(var i=0;i<ary.length;i++){
str = '<SPAN ID="_link_'
+ menuId
+ '_'
+ i
+ '" STYLE="position:absolute;top:'
+ prevBottom
+ ';left:0;height:'
+ e.attribs["height"]
+ ';overflow:hidden;width:'
+ e.attribs["width"]
+ ';background:'
+ e.attribs["background"]
+ ';border-width:'
+ e.attribs["border-width"]
+ ';border-style:solid;border-color:'
+ e.attribs["border-color"]
+ ';';
if(e.attribs["showrow"]!=true && i != 0){
str +='border-top-width:0;';
}
str +='text-align:left;font-size:'
+ e.attribs["font-size"]
+ ';padding-left:4;">';
if(ary[i].icon!=null){
str +='<SPAN STYLE="font-family:webdings;color:'
+ e.attribs["icon-color"]
+ '">&#'
+ ary[i].icon
+ ';</SPAN> ';
}

strNewP =' ';
if(ary[i].url=="http://help.archaio.com"){
strNewP ='" Target="New"';
}
str +='<A HREF="'
+ ary[i].url
+ strNewP + ''
+ '" TITLE="'
+ ary[i].desc
+ '" STYLE="font-family:'
+ e.attribs["font-family"]
+ ';color:'
+ e.attribs["font-color"]
+ ';padding-left:3;">'
+ ary[i].name
+ '</A>';
if(ary[i].length > 0 && e.attribs["arrow"]){
str +='<SPAN STYLE="font-family:webdings;position:absolute;top:0;left:'
+ e.attribs["arrow-offset"]
+ ';width:'
+ (e.attribs["width"] - e.attribs["arrow-offset"])
+ ';overflow:hidden;color:'
+ e.attribs["icon-color"]
+ '">4</SPAN>';
}
str +='</SPAN>';
thismenu.insertAdjacentHTML("BeforeEnd",str);
thisoption = document.all.item('_link_' + menuId + '_' + i);
thisoption.menuId = menuId;
thisoption.onmouseover = _optionmouseover;
thisoption.onmouseout = _optionmouseout;
prevBottom = thisoption.style.pixelTop + (e.attribs["height"] - e.attribs["border-width"]);
if(ary[i].length > 0){
thisoption.menuChild=_menus.length;
_create(e,ary[i]);
}
}
thismenu.style.pixelHeight = prevBottom;
}

function ConstructObject(obj,nest){
nest=(!nest) ? '':'document.'+nest+'.'
this.el = document.getElementById( obj );
this.css = this.el.style;

this.scrollHeight = this.el.offsetHeight
this.clipHeight = this.el.offsetHeight

this.up = MoveAreaUp;
this.down = MoveAreaDown;
this.MoveArea = MoveArea;
this.x;
this.y;
this.obj = obj + "Object"
eval(this.obj + "=this")
return this;
}

function InitialiseScrollableArea(){
objContainer=new ConstructObject('divContainer')
objScroller=new ConstructObject('divContent','divContainer')
objScroller.MoveArea(0,0)
objContainer.css.visibility='visible'
initialised=true;
}

brothercake
02-11-2003, 03:27 PM
Originally posted by JlynnMc10
I am confused on how to use document.all[i]


Don't.

document.all is a proprietary and horrendously inefficient collection; you should use document.getElementById instead.

Other than that, I don't really understand your question - surely you pass the parameters you need; what is it you need that isn't available within the scope of your function?

JlynnMc10
02-11-2003, 03:35 PM
Well I know that I need to pass the ConstructObject the menu and then the data, but what I am confused about is what those are in the create function.
I think I should pass it e.attribs somehow because that is the menu and then the array with the text?????
My problem is that in the InitialiseScrollableArea() the ConstructObject takes in 'divContent' and 'divContainer' but those were too a whole different project. I am just trying to incorporate ConstructObject and InitialiseScrollableArea into my create function. Does that make sense????

JlynnMc10
02-11-2003, 03:40 PM
_create() is in the current .js I working with, but the menus are not scrollable so I found this script that includes the ConstructObject and InitialiseScrollableArea which creates a menu that is scrollable.
Now I am trying to incorporate those functions into my function that creates my menus