Milonic provide full featured pull down web menus for some of the worlds largest companies
click here to see what it can do for you

Download Milonic DHTML Menu
Buy Milonic DHTML Menu

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:54

How can I put the styles properties in one file?


Poster: heinrichegg
Dated: Saturday November 29 2003 - 0:46:41 GMT

I have a site with three different languages and therefore three different menu-files (with alll the same styles).

I would like to have the styles properties only one place so that I don't have to change styles in three different files. Is it possible to put them in a separate file and have a reference to this file in the other menu-files?

Thanks
Heinrichegg


Poster: John
Dated: Saturday November 29 2003 - 3:01:14 GMT

Not being the JS expert around here :roll: I suspect you could put the styles in one file and call it using a JS call the same way the JS files are called now.

Can't hurt to try...


Poster: kevin3442
Dated: Saturday November 29 2003 - 4:30:36 GMT

Hi Heinrichegg,

What John is suggesting should work. In other words, remove your global variable settings and styles from menu_data.js and save them in a separate file; maybe call it "menu_styles.js". So menu_styles.js might look something like this:
Code:
_menuCloseDelay=500
_menuOpenDelay=150
_followSpeed=5
_followRate=40
_subOffsetTop=10
_subOffsetLeft=-10
_scrollAmount=3
_scrollDelay=20

with(menuStyle=new mm_style()){
onbgcolor="#4F8EB6";
oncolor="#ffffff";
offbgcolor="#DCE9F0";
offcolor="#515151";
bordercolor="#296488";
borderstyle="solid";
borderwidth=1;
separatorcolor="#2D729D";
separatorsize="1";
padding=5;
fontsize="75%";
fontstyle="normal";
fontfamily="Verdana, Tahoma, Arial";
pagecolor="black";
pagebgcolor="#82B6D7";
headercolor="#000000";
headerbgcolor="#ffffff";
subimage="arrow.gif";
subimagepadding="2";
overfilter="Fade(duration=0.2);Alpha(opacity=90);Shadow(color='#777777', Direction=135, Strength=5)";
outfilter="randomdissolve(duration=0.3)";
}

The above example is taken from the standard horizontal menu sample. Of course, you'd use your own style(s)

Now, menu_data.js (or whatever file names you use) should contain only your menu definitions:
Code:
with(milonic=new menuname("Main Menu")){
style=menuStyle;
etc...;
}

Load the additional menu_styles.js file into your pages before the _data.js file, like so:
Code:
<SCRIPT language=JavaScript src="menu_styles.js" type=text/javascript></SCRIPT>
<SCRIPT language=JavaScript src="menu_data.js" type=text/javascript></SCRIPT>

You have to load the menu_styles.js file before the _data.js file so that the styles are already defined prior to the menu definitions; otherwise, you'll get undefined object errors.

Hope that helps,

Kevin

Thanks!


Poster: heinrichegg
Dated: Saturday November 29 2003 - 7:23:15 GMT

Thank you for the help. It works!

I upgraded the old ver. 3.4 to 5 yesterday and everything works without any problems. Even the online converter worked fine.

This version is a lot easier to change menuitems and to edit the menus.

Hovewer:

I use the menu inside a table and it works fine when I use the method described - to put the main menu inside the cell directly in the html-document.

With the old menu I used the PLACEMENU function. This would be a better way of doing it since then you do not need to split the menu between the html-doc and the menu_data.js file.
Look forward to this is fixed.

Best regards
HE

Re: Thanks!


Poster: John
Dated: Saturday November 29 2003 - 20:00:38 GMT

heinrichegg wrote:
Thank you for the help. It works!

Glad to hear it!
heinrichegg wrote:
I use the menu inside a table and it works fine when I use the method described - to put the main menu inside the cell directly in the html-document.

With the old menu I used the PLACEMENU function. This would be a better way of doing it since then you do not need to split the menu between the html-doc and the menu_data.js file.
Look forward to this is fixed.

I do mine differently than the example, and it seems to work fine...

1. Leave all the JS calls as they are at the top of the <body>.

2. Move only the JS call to your _data.js file to the desired <td>. Nothing else should be in that <td>, and especially no <div> messing around with the table.

3. Keep all your main menu code, etc., together in the JS file as it originally was, not split off in the HTML.

That's it.

Thanks!


Poster: heinrichegg
Dated: Saturday November 29 2003 - 23:06:56 GMT

It works! Thank you very much!

H


Poster: John
Dated: Sunday November 30 2003 - 16:39:25 GMT

You're welcome.

That'll be 3 bucks, please :!: :D