From ffcab968d30674fa70282941b2d3b5a51f373e6e Mon Sep 17 00:00:00 2001 From: james Date: Thu, 19 Aug 2010 18:58:25 +0000 Subject: [PATCH] move navigation javascripts to a separate file --- js/nav.js | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 js/nav.js diff --git a/js/nav.js b/js/nav.js new file mode 100644 index 00000000..472b11f4 --- /dev/null +++ b/js/nav.js @@ -0,0 +1,45 @@ +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("/nav.php?level=1&id="+l1,null,function() { + $("#secondarymenu").show(); + + $("#tertiarymenu_accordion").accordion("destroy"); + $("#tertiarymenu_accordion").load("/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("/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(); + }); + } + +}