Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Please help with menu dynamic positioning

Status
Not open for further replies.

DanOoo

Programmer
Feb 26, 2005
15
US
I have a portion of script that I am trying to modify to automatically adjust my menu dynamic positioning. I have tried everything I can think of and have not had success. Your help is greatly appreciated.
Thank you,
DanOoo

These lines of (old code) I need to adjusted to work with my (new code)
--------------------------
Code:
//****old code****
function redo()
{
var offset = -293
var newLeft = getWindowWidth() / 2 + offset;
menu.container.style ? menu.container.style.left = newLeft + "px" : menu.container.left = newLeft;
}
function getWindowWidth()
{
return window.innerWidth ? window.innerWidth : document.body.offsetWidth;
}
--------------------------
Code:
//****new code****
document.write('<style type="text/css">' + ypSlideOutMenu.styleMod + '</style>');
for (var i = 0; i < menus.length; i++) {
menus[i].onactivate = new Function("document.getElementById('act" + i + "').className='active'");
menus[i].ondeactivate = new Function("document.getElementById('act" + i + "').className='';");
}
 

How exactly does the (old code) tie in with the (new code)?

Do you want it to affect ypSlideOutMenu.styleMod somehow? It's not too clear (to me).

Dan


The answers you get are only as good as the information you give!

 
BillyRayPreachersSon -
Thank you for taking the time to respond. Below you will find the code(new code) that I am working on. Then below the code(new code) you will find a dynamic reposition function(old code) that I am trying to incorporate into the new code. Thanks again for your help. Please let me know if you have any questions.
DanOoo

----------------
****new code****
----------------
Code:
<SCRIPT language=javascript src="menu/ypslideoutmenus/ypSlideOutMenusC.js"></SCRIPT>
<SCRIPT>
	var menus = [
		new ypSlideOutMenu("menu100", "right", 293, 139, 215,400, null),
		new ypSlideOutMenu("menu102", "right", 293, 159, 215,400, null),
		new ypSlideOutMenu("menu103", "right", 293, 177, 215,400, null),
		new ypSlideOutMenu("menu104", "right", 293, 197, 215,400, null),
		new ypSlideOutMenu("menu105", "right", 293, 215, 215,400, null),
		new ypSlideOutMenu("menu106", "right", 293, 234, 215,400, null),
		new ypSlideOutMenu("menu107", "right", 293, 253, 215,400, null),
		new ypSlideOutMenu("menu200", "right", 293, 295, 215,400, null),
		new ypSlideOutMenu("menu202", "right", 293, 314, 215,400, null),
		new ypSlideOutMenu("menu204", "right", 293, 332, 215,400, null),
		new ypSlideOutMenu("menu206", "right", 293, 351, 215,400, null),
		new ypSlideOutMenu("menu208", "right", 293, 370, 215,400, null),
		new ypSlideOutMenu("menu210", "right", 293, 389, 215,400, null),
		new ypSlideOutMenu("menu212", "right", 293, 408, 215,400, null),		
		new ypSlideOutMenu("menu214", "right", 293, 427, 215,400, null),
		new ypSlideOutMenu("menu216", "right", 293, 446, 215,400, null),
		new ypSlideOutMenu("menu218", "right", 293, 465, 215,400, null),
		new ypSlideOutMenu("menu220", "right", 293, 484, 215,400, null),
		new ypSlideOutMenu("menu222", "right", 293, 503, 215,400, null),
		new ypSlideOutMenu("menu224", "right", 293, 522, 215,400, null),
		new ypSlideOutMenu("menu226", "right", 293, 541, 215,400, null),		
		new ypSlideOutMenu("menu228", "right", 293, 560, 215,400, null),
		new ypSlideOutMenu("menu230", "right", 293, 579, 215,400, null),
		new ypSlideOutMenu("menu232", "right", 293, 598, 215,400, null),
		new ypSlideOutMenu("menu234", "right", 293, 617, 215,400, null),
		new ypSlideOutMenu("menu236", "right", 293, 636, 215,400, null),
		new ypSlideOutMenu("menu238", "right", 293, 655, 215,400, null),
		new ypSlideOutMenu("menu240", "right", 293, 674, 215,400, null),						
		new ypSlideOutMenu("menu242", "right", 293, 693, 215,400, null),
		new ypSlideOutMenu("menu244", "right", 293, 712, 215,400, null),
		new ypSlideOutMenu("menu3100", "right", 293, 753, 215, 400, null),
		new ypSlideOutMenu("menu3200", "right", 293, 772, 235, 400, null),
		new ypSlideOutMenu("menu3300", "right", 293, 791, 235, 400, null),
		new ypSlideOutMenu("menu3110", "right", 507, 753, 215, 400, 'menu3100'),	
		new ypSlideOutMenu("menu3112", "right", 507, 771, 215, 400, 'menu3100'),
		new ypSlideOutMenu("menu3114", "right", 507, 789, 215, 400, 'menu3100'),
		new ypSlideOutMenu("menu3116", "right", 507, 807, 215, 450, 'menu3100'),	
		new ypSlideOutMenu("menu3118", "right", 507, 825, 215, 400, 'menu3100'),
		new ypSlideOutMenu("menu3120", "right", 507, 843, 215, 400, 'menu3100'),
		new ypSlideOutMenu("menu3122", "right", 507, 861, 215, 400, 'menu3100'),
		new ypSlideOutMenu("menu3124", "right", 507, 879, 215, 400, 'menu3100'),		
		new ypSlideOutMenu("menu3126", "right", 507, 897, 215, 400, 'menu3100'),		
		new ypSlideOutMenu("menu3128", "right", 507, 915, 215, 400, 'menu3100'),		
		new ypSlideOutMenu("menu3130", "right", 507, 933, 215, 400, 'menu3100'),	
		new ypSlideOutMenu("menu3132", "right", 507, 951, 215, 400, 'menu3100'),
		new ypSlideOutMenu("menu3210", "right", 527, 772, 215, 400, 'menu3200'),	
		new ypSlideOutMenu("menu3212", "right", 527, 790, 215, 400, 'menu3200'),
		new ypSlideOutMenu("menu3214", "right", 527, 808, 215, 400, 'menu3200'),
		new ypSlideOutMenu("menu3216", "right", 527, 826, 215, 400, 'menu3200'),	
		new ypSlideOutMenu("menu3218", "right", 527, 844, 215, 400, 'menu3200'),
		new ypSlideOutMenu("menu3220", "right", 527, 862, 215, 400, 'menu3200'),
		new ypSlideOutMenu("menu3222", "right", 527, 880, 215, 400, 'menu3200'),
		new ypSlideOutMenu("menu3224", "right", 527, 898, 215, 400, 'menu3200'),		
		new ypSlideOutMenu("menu3226", "right", 527, 916, 215, 400, 'menu3200'),		
		new ypSlideOutMenu("menu3228", "right", 527, 934, 215, 400, 'menu3200'),		
		new ypSlideOutMenu("menu3310", "right", 527, 791, 215, 400, 'menu3300'),	
		new ypSlideOutMenu("menu3312", "right", 527, 809, 215, 400, 'menu3300'),
		new ypSlideOutMenu("menu3314", "right", 527, 827, 215, 400, 'menu3300'),
		new ypSlideOutMenu("menu3316", "right", 527, 845, 215, 400, 'menu3300'),	
		new ypSlideOutMenu("menu3318", "right", 527, 863, 215, 400, 'menu3300'),
		new ypSlideOutMenu("menu3320", "right", 527, 881, 215, 400, 'menu3300'),
		new ypSlideOutMenu("menu3322", "right", 527, 899, 215, 400, 'menu3300'),
		new ypSlideOutMenu("menu3324", "right", 527, 917, 215, 400, 'menu3300'),		
		new ypSlideOutMenu("menu3326", "right", 527, 935, 215, 400, 'menu3300'),		
		new ypSlideOutMenu("menu400", "right", 293, 832, 125,400, null),
		new ypSlideOutMenu("menu402", "right", 293, 851, 125,400, null),
		new ypSlideOutMenu("menu404", "right", 293, 870, 125,400, null),
		new ypSlideOutMenu("menu406", "right", 293, 889, 215,400, null),
		new ypSlideOutMenu("menu408", "right", 293, 908, 215,400, null),
		new ypSlideOutMenu("menu410", "right", 293, 927, 215,400, null),
		new ypSlideOutMenu("menu414", "right", 293, 946, 125,400, null),
		new ypSlideOutMenu("menu416", "right", 293, 965, 150,400, null),
		new ypSlideOutMenu("menu418", "right", 293, 984, 215,400, null),
		new ypSlideOutMenu("menu420", "right", 293, 1004, 215,400, null),
		new ypSlideOutMenu("menu422", "right", 293, 1022, 215,400, null),
		new ypSlideOutMenu("menu424", "right", 293, 1041, 170,400, null),
		new ypSlideOutMenu("menu426", "right", 293, 1060, 130,400, null),
		new ypSlideOutMenu("menu428", "right", 293, 1079, 215,400, null),
		new ypSlideOutMenu("menu430", "right", 293, 1098, 125,400, null),
		new ypSlideOutMenu("menu432", "right", 423, 1060, 160,400, "menu426"),
		new ypSlideOutMenu("menu434", "right", 423, 1078, 160,400, "menu426"),
		new ypSlideOutMenu("menu500", "right", 293, 1139, 150,400, null),
		new ypSlideOutMenu("menu502", "right", 293, 1158, 110,400, null),
		new ypSlideOutMenu("menu504", "right", 293, 1177, 125,400, null),
		new ypSlideOutMenu("menu506", "right", 293, 1196, 150,400, null),
		new ypSlideOutMenu("menu508", "right", 293, 1215, 100,400, null),
		new ypSlideOutMenu("menu510", "right", 403, 1158, 120, 400, "menu502"),
		new ypSlideOutMenu("menu512", "right", 403, 1176, 120, 400, "menu502"),
		new ypSlideOutMenu("menu514", "right", 403, 1212, 120,400, "menu502"),
		new ypSlideOutMenu("menu516", "right", 403, 1230, 120,400, "menu502"),
		new ypSlideOutMenu("menu518", "right", 443, 1196, 150,400, "menu506"),
		new ypSlideOutMenu("menu520", "right", 443, 1214, 160,400, "menu506"),
		new ypSlideOutMenu("menu524", "right", 443, 1232, 100,400, "menu506"),
		new ypSlideOutMenu("menu526", "right", 393, 1215, 150,400, "menu508"),
		new ypSlideOutMenu("menu528", "right", 393, 1251, 150,400, "menu508"),
		new ypSlideOutMenu("menu530", "right", 603, 1214, 215,400, "menu520"),
		new ypSlideOutMenu("menu532", "right", 603, 1232, 215,400, "menu520")
		]
	document.write('<style type="text/css">' + ypSlideOutMenu.styleMod + '</style>');
	for (var i = 0; i < menus.length; i++) {
		menus[i].onactivate = new Function("document.getElementById('act" + i + "').className='active';");
		menus[i].ondeactivate = new Function("document.getElementById('act" + i + "').className='';");
	}
</SCRIPT>

----------------
****old code****
----------------
Code:
<SCRIPT language=javascript src="menu/ypslideoutmenus/ypSlideDownMenusC.js"></SCRIPT>
<SCRIPT language=javascript>
 
// the number you pass to initLeft doesn't matter since it will get
// changed onactivate
	var myMenu1 = new ypSlideDownMenu("menu1", "down", -1000, 118, 260, 200)
	var myMenu2 = new ypSlideDownMenu("menu2", "down", -1000, 118, 260, 350)
	var myMenu3 = new ypSlideDownMenu("menu3", "down", -1000, 118, 260, 200)
	var myMenu4 = new ypSlideDownMenu("menu4", "down", -1000, 118, 260, 200)

// for each menu, we set up the onactivate event to call repositionMenu with the amount offset from center, in pixels
	myMenu1.onactivate = function() { repositionMenu(myMenu1, -427); }
	myMenu2.onactivate = function() { repositionMenu(myMenu2, -208); }
	myMenu3.onactivate = function() { repositionMenu(myMenu3, -195); }
	myMenu4.onactivate = function() { repositionMenu(myMenu4, -83); }


// this function repositions a menu to the speicified offset from center
	function repositionMenu(menu, offset)
	{
// the new left position should be the center of the window + the offset
		var newLeft = getWindowWidth() / 2 + offset;

// setting the left position in netscape is a little different than IE
		menu.container.style ? menu.container.style.left = newLeft + "px" : menu.container.left = newLeft;
	}

// this function calculates the window's width - different for IE and netscape
	function getWindowWidth()
	{
		return window.innerWidth ? window.innerWidth : document.body.offsetWidth;
	}	

</SCRIPT>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top