/    Sign up×
Community /Pin to ProfileBookmark

Accordion Menu Help

Hello to all,
I have a little problem with my accordion menu and I CRAVE for your help!

I try to make this: when you visit my page I need the menu to be all collapsed.
Also the history of clicks (it remembers which menus where left opened) works fine on IE but not on firefox.

Here is the js code:

function add_menu_event_handlers()
{
var elems = document.getElementsByTagName(‘h3’);
for (i = 0; i < elems.length; i++)
{
switch (elems[i].parentNode.className)
{
/*case ‘moduletable’:
case ‘moduletable_menu’:*
/
case ‘left_module_title’:
case ‘left_module_title_menu’:
{
if (elems[i].parentNode.parentNode.parentNode.id == ‘xp-left’)
{
xplike_addEvent(elems[i], ‘click’, function(){menu_header_click(this);});
// menu_header_click(elems[i]);
//Load status from cookies and collapse if required
var cookie_array = document.cookie.split(‘;’);
for(var j=0; j<cookie_array.length; j++)
{
var c = cookie_array[j];
while (c.charAt(0)==’ ‘) c = c.substring(1,c.length);
if (c.indexOf(‘xplike_menu_status_‘ + elems[i].firstChild.nodeValue.replace(‘.’, ‘_‘).replace(‘ ‘, ‘_’)) == 0)
{
var menu_cookie = c.split(‘=’)
if (menu_cookie.length == 2 && menu_cookie[1] == ‘1’)
{
menu_header_click(elems[i]);
}
}
}
}
}
}
}
}

And it also has this for the history thing.

function save_menu_status(menu_title, value, how_many_days)
{
var date = new Date();
date.setTime(date.getTime()+(how_many_days*24*60*6 0*1000));
var expires = “”;
document.cookie = ‘xplike_menu_status_‘ + menu_title.replace(‘.’, ‘_‘).replace(‘ ‘, ‘_’) + ‘=’ + value + expires + ‘; path=/’;
}

It might be easy and stupid, I know, but since I’m a designer – not a developer – all look weird to me!
Any thoughts?

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@fede2008authorApr 07.2011 — You may see the menu here:

http://www.igtech.gr/index.php
Copy linkTweet thisAlerts:
@fede2008authorApr 07.2011 — I forgot one more function:

[COLOR="DarkRed"]function menu_header_click(elem)

{

if (elem.parentNode.parentNode.childNodes.length > 0)

{

for (var i=0; i<elem.parentNode.parentNode.childNodes.length; i++)

{

if (elem.parentNode.parentNode.childNodes[i].firstChild != elem)

{

if (elem.parentNode.parentNode.childNodes[i].style)

{

if (elem.parentNode.parentNode.childNodes[i].style.display == 'none')

{

//Expand menu and delete cookie

set_background_image(elem, 'expanded');

elem.parentNode.parentNode.childNodes[i].style.display = '';

save_menu_status(elem.firstChild.nodeValue, '0', -1);

}

else

{

//Collapse menu and save cookie

set_background_image(elem, 'collapsed');

elem.parentNode.parentNode.childNodes[i].style.display = 'none';

save_menu_status(elem.firstChild.nodeValue, '1', 30);

}

}

}

}

}

}
[/COLOR]
×

Success!

Help @fede2008 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.6,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...