New JS: Append to Menu after drawmenu

Having problems with DHTML Menu? There is usually somebody here who knows the answer.
Post Reply
lake
Beginner
Beginner
Posts: 1
Joined: Mon May 09, 2005 2:46 pm

New JS: Append to Menu after drawmenu

Post by lake »

Hi,
I had this problem:
I needed to append to the menu many items, after the call to "drawMenus();"

I have some prorblems with the "mm_insertItem" :
- it doesen't seem to work well if I call after drawMenus and I have added many items with aI before)
- it works well if I call it after the drawmenu without using aI (with more than 1 item per submenu)
- in the last case, it is very very slow due to the many "for"

I created this script, that seem to work well (using some tricks) to append item to menu:

Code: Select all

function mm_appendItem(_mN, _aI)
{
	_mn=_mN;
	
	// -- Add the Menu Item --
	var new_item_id=_mi.length;
	_mi[new_item_id]=_nA();
	
	// Copying from item 0 (must be empty)
	_mi[new_item_id][0]=_mn;
	for(_r=2;_r<_mi[0].length;_r++) 
	{
		_mi[new_item_id][_r]=_mi[0][_r];
	}

	// Apply Style and proprieties in _aI
	_it=_aI.split(";");
	for(_r=0;_r<_it.length;_r++){
		_sp=_it[_r].indexOf("=");
		if(_sp>-1){
			_si=_it[_r].slice(_sp+1);
			_w=_it[_r].slice(0,_sp);
			if(_w=="showmenu")_si=$tL(_si);
			_mi[new_item_id][_$S[_w]]=_si;
		}
	}
	
	// -- Add the Item to the Menu Item List --
	var x = _m[_mn][0];
	x[x.length]=new_item_id;
	
	// Redraw
	try {
		_rbMenus(_mn);
	}
	catch(er) 
	{
		
	}
}
This function works only with menu ID, not with menu name (sorry but I had to add many items, why do we have to use a for if we don't need it?). So this get the id from the name only the first time:

Code: Select all

var _mNOld="";
var _mnOld=0;
function AddItem(_mN,_aI) 
{
	if(_mNOld==_mN) mm_appendItem(_mnOld,_aI);
	else 
	{
		_mNOld=_mN;
		_mnOld=getMenuByName(_mN);
		mm_appendItem(_mnOld,_aI);
	}	
}
mm_appendItem function copy everything from the item "0" (not name or url), and use all the other proprieties in the _aI.
So you have to add as first item in your data js:

Code: Select all

with(menufff=new menuname("MenuBlank"))
{
	aI("");
}
I hope someone understand my bad english, and my code.
I didn't find any solution to the problem reading this: viewtopic.php?t=5451

Please avoid unusefull "for", thanks

PS: I bought Milonic professional license, is it possible to get a clear source? I will give you all my modifications...
[/url]
User avatar
John
 Team
 Team
Posts: 5967
Joined: Sun May 19, 2002 8:23 pm
Location: Phoenix, AZ
Contact:

Re: New JS: Append to Menu after drawmenu

Post by John »

lake wrote:PS: I bought Milonic professional license, is it possible to get a clear source? I will give you all my modifications...
Copyright 2005 (c) Milonic Solutions Limited. All Rights Reserved.
This is a commercial software product, please visit http://milonic.com/ for more information.
See http://milonic.com/license.php for Commercial License Agreement
All Copyright statements must always remain in place in all files at all times
That should answer it, but I think the bottom line is - no. You have a license to use but not modify. Further, any modifications made to the Milonic code files will result in no support of the product.
John
Post Reply