More updates to the nav - now keeps track of the accordion tab position, and which link within the accordion is seelcted

This commit is contained in:
james 2010-07-21 18:37:03 +00:00
parent f704f14134
commit a4ea8b2f4d
3 changed files with 70 additions and 23 deletions

View File

@ -79,13 +79,41 @@ function taskNav(id,pid,level) {
$("#tertiarymenu_accordion").accordion("destroy"); $("#tertiarymenu_accordion").accordion("destroy");
$("#tertiarymenu_accordion").load("<?=$config['SFIABDIRECTORY']?>/nav.php?level=2&id="+id,null,function() { $("#tertiarymenu_accordion").load("<?=$config['SFIABDIRECTORY']?>/nav.php?level=2&id="+id,null,function() {
$("#tertiarymenu_accordion").accordion({clearStyle: true}); //"option", "collapsible", true); $("#tertiarymenu_accordion").accordion({clearStyle: true}); //"option", "collapsible", true);
$("#tertiarymenu").show(); $("#tertiarymenu").show();
}); });
break; break;
} }
return false; return false;
} }
function taskNavLevel(l1,l2,l3,l4) {
if(l2) {
$("#secondarymenu").load("<?=$config['SFIABDIRECTORY']?>/nav.php?level=1&id="+l1);
$("#secondarymenu").show();
$("#tertiarymenu_accordion").accordion("destroy");
$("#tertiarymenu_accordion").load("<?=$config['SFIABDIRECTORY']?>/nav.php?level=2&id="+l2,null,function() {
$("#tertiarymenu_accordion").accordion({clearStyle: true}); //"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(l3) {
$("#tertiarymenu_accordion").accordion("activate",$("#tertiary_nav_"+l3));
}
if(l4) {
$(".tertiarylinknav-selected").removeClass("tertiarylinknav-selected");
$("#tertiarylink_nav_"+l4).addClass("tertiarylinknav-selected");
}
});
}
}
</script> </script>
<? <?
//if we're under /admin or /config we also want the translation editor //if we're under /admin or /config we also want the translation editor
@ -265,7 +293,9 @@ if(is_array($_SESSION['roles'])) {
$_SESSION['nav']['primary']=$r->id; $_SESSION['nav']['primary']=$r->id;
$cl="class=\"selected\""; $cl="class=\"selected\"";
} }
echo "<li id=\"primary_nav_{$r->id}\" $cl><a href=\"#\" onclick=\"return taskNav($r->id,$r->pid,$r->level)\">".i18n($r->task)."</a></li>\n"; echo "<li id=\"primary_nav_{$r->id}\" $cl>";
echo "<a href=\"#\" onclick=\"return taskNav($r->id,$r->pid,$r->level)\">".i18n($r->task)."</a>";
echo "</li>\n";
} }
} }
} }
@ -324,10 +354,10 @@ if($r=mysql_fetch_object($q)) {
//because we cannot assume that the user navigated to this page via the pri/sec/ter nav menus //because we cannot assume that the user navigated to this page via the pri/sec/ter nav menus
$navTree=array(); $navTree=array();
upTree($r->id,&$navTree); upTree($r->id,&$navTree);
$_SESSION['nav']['primary']=0;
echo "<script type=\"text/javascript\">"; $_SESSION['nav']['secondary']=0;
echo " $(document).ready(function() {\n"; $_SESSION['nav']['tertiary']=0;
echo "taskNav({$_SESSION['nav']['secondary']},{$_SESSION['nav']['primary']},1);"; $_SESSION['nav']['tertiarylink']=0;
foreach($navTree AS $t) { foreach($navTree AS $t) {
switch($t['level']) { switch($t['level']) {
@ -340,26 +370,26 @@ if($r=mysql_fetch_object($q)) {
// echo "$(\"#secondary_nav_".$t['id']."\").addClass('secondarynav-selected');"; // echo "$(\"#secondary_nav_".$t['id']."\").addClass('secondarynav-selected');";
break; break;
case 2: //tertiary nav heading case 2: //tertiary nav heading
$_SESSION['nav']['tertiary']=$t['id'];
break;
case 3: //tertiary nav link case 3: //tertiary nav link
$_SESSION['nav']['tertiarylink']=$t['id'];
break;
} }
} }
echo "<script type=\"text/javascript\">";
echo " $(document).ready(function() {\n";
echo "taskNavLevel({$_SESSION['nav']['primary']},
{$_SESSION['nav']['secondary']},
{$_SESSION['nav']['tertiary']},
{$_SESSION['nav']['tertiarylink']}
);";
echo " });"; echo " });";
echo "</script>\n"; echo "</script>\n";
} }
echo "<script type=\"text/javascript\">";
echo " $(document).ready(function() {\n";
if($_SESSION['nav']['primary']) {
echo "taskNav({$_SESSION['nav']['primary']},0,0);\n";
}
if($_SESSION['nav']['secondary']) {
echo "taskNav({$_SESSION['nav']['secondary']},{$_SESSION['nav']['primary']},1);\n";
}
echo " });";
echo "</script>\n";
/* /*
if(is_array($nav)) { if(is_array($nav)) {
echo "<div id=\"mainwhere\">".i18n('You are here:').' '; echo "<div id=\"mainwhere\">".i18n('You are here:').' ';

13
nav.php
View File

@ -40,7 +40,12 @@
$cl="class=\"secondarynav-selected\""; $cl="class=\"secondarynav-selected\"";
} }
else $cl=""; else $cl="";
echo "<li id=\"secondary_nav_{$r->id}\" $cl><a href=\"#\" onclick=\"return taskNav($r->id,$r->pid,$r->level)\">".i18n($r->task)."</a></li>\n"; echo "<li id=\"secondary_nav_{$r->id}\" $cl>";
echo "<a href=\"#\" onclick=\"return taskNav($r->id,$r->pid,$r->level)\">".i18n($r->task)."</a>";
if($_SESSION['debug']) {
//echo "<a href=\"#\" onclick=\"return taskNavLevel($r->pid, $r->id)\">(*)</a>";
}
echo "</li>\n";
} }
echo "</ul>\n"; echo "</ul>\n";
break; break;
@ -49,11 +54,11 @@
$_SESSION['nav']['secondary']=$id; $_SESSION['nav']['secondary']=$id;
$q=mysql_query("SELECT * FROM rolestasks WHERE pid='$id' AND level=2 ORDER By ord,task"); $q=mysql_query("SELECT * FROM rolestasks WHERE pid='$id' AND level=2 ORDER By ord,task");
while($r=mysql_fetch_object($q)) { while($r=mysql_fetch_object($q)) {
echo "<h3><a href=\"{$config['SFIABDIRECTORY']}$r->link\">".i18n("$r->task")."</a></h3>\n"; echo "<h3 id=\"tertiary_nav_{$r->id}\"><a href=\"{$config['SFIABDIRECTORY']}$r->link\">".i18n("$r->task")."</a></h3>\n";
echo "<ul>"; echo "<ul class=\"tertiary_nav\">";
$q2=mysql_query("SELECT * FROM rolestasks WHERE pid='$r->id' AND level=3 ORDER BY ord,task"); $q2=mysql_query("SELECT * FROM rolestasks WHERE pid='$r->id' AND level=3 ORDER BY ord,task");
while($r2=mysql_fetch_object($q2)) { while($r2=mysql_fetch_object($q2)) {
echo "<li><a href=\"".$config['SFIABDIRECTORY']."$r2->link\">".i18n($r2->task)."</a></li>\n"; echo "<li id=\"tertiarylink_nav_{$r2->id}\"><a href=\"".$config['SFIABDIRECTORY']."$r2->link\">".i18n($r2->task)."</a></li>\n";
} }
echo "</ul>"; echo "</ul>";
} }

View File

@ -251,6 +251,18 @@ ul.secondarynav li.secondarynav-selected a {
color: black; color: black;
} }
ul.tertiarynav {
}
ul.tertiarynav li a {
color: red;
}
.tertiarylinknav-selected a {
font-weight: bold;
}
.aligncenter { .aligncenter {
width: 100%; width: 100%;
text-align: center; text-align: center;