Back To Start Of Archive
Taken From The Forum: Help & Support for DHTML Menu Version 5+
Forum Topic: Click to view post
Last Updated: Saturday July 14 2012 - 06:07:45
New JS: Append to Menu after drawmenu
Poster: lake
Dated: Monday May 9 2005 - 15:01:38 BST
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:
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)
{
}
}
{
_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:
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);
}
}
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:
with(menufff=new menuname("MenuBlank"))
{
aI("");
}
{
aI("");
}
I hope someone understand my bad english, and my code.
I didn't find any solution to the problem reading this: http://www.milonic.com/forum/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]
Re: New JS: Append to Menu after drawmenu
Poster: John
Dated: Monday May 9 2005 - 18:21:28 BST
lake wrote:
PS: I bought Milonic professional license, is it possible to get a clear source? I will give you all my modifications...
Quote:
Copyright 2005 (c) Milonic Solutions Limited. All Rights Reserved.
This is a commercial software product, please visit http://www.milonic.com/ for more information.
See http://www.milonic.com/license.php for Commercial License Agreement
All Copyright statements must always remain in place in all files at all times
This is a commercial software product, please visit http://www.milonic.com/ for more information.
See http://www.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.