science-ation/js/nav.js
james 02998f98d6 A few more UI div recommendations and CSS touchups
Make php '$config' array available in javascript as javascript 'config' object
2010-08-20 15:11:11 +00:00

46 lines
1.8 KiB
JavaScript

function taskNavLevel(l1,l2,l3,l4) {
if(l2) {
//we have a secondary click, which implies we also have a primary nav selected
//we may or may not have l3 or l4 though, so they are handled separately below
$("#secondarymenu").load(config.SFIABDIRECTORY+"/nav.php?level=1&id="+l1,null,function() {
$("#secondarymenu").show();
$("#tertiarymenu_accordion").accordion("destroy");
$("#tertiarymenu_accordion").load(config.SFIABDIRECTORY+"/nav.php?level=2&id="+l2,null,function() {
$("#tertiarymenu_accordion").accordion({clearStyle: true, collapsible: true, active: false}); //"option", "collapsible", true);
$("#tertiarymenu").show();
$(".primarynav-selected").removeClass("primarynav-selected");
$("#primary_nav_"+l1).addClass("primarynav-selected");
$(".secondarynav-selected").removeClass("secondarynav-selected");
$("#secondary_nav_"+l2).addClass("secondarynav-selected");
//if we have a 3rd level nav, open up the accordion to the appropriate place
if(l3) {
$("#tertiarymenu_accordion").accordion("activate",$("#tertiary_nav_"+l3));
}
//if we have a 4th level nav, set the selected class on the appropriate item in the list
if(l4) {
$(".tertiarylinknav-selected").removeClass("tertiarylinknav-selected");
$("#tertiarylink_nav_"+l4).addClass("tertiarylinknav-selected");
}
});
});
}
else {
//only the primary link clicked, so show the secondary, and thats it.
$("#secondarymenu").load(config.SFIABDIRECTORY+"/nav.php?level=1&id="+l1,null,function() {
$(".primarynav-selected").removeClass("primarynav-selected");
$("#primary_nav_"+l1).addClass("primarynav-selected");
//show the secondary
$("#secondarymenu").show();
//and hide the tertiary
$("#tertiarymenu").hide();
});
}
}