Some fixes so that navmenus don't jump out of frames any more.

The navmenu function now takes a third parameter that specifies
the window to change location of (default 'self', but could be "parent" or "top")
This commit is contained in:
moodler
2003-08-26 06:01:13 +00:00
parent 2ae0cc7759
commit 16ef5e7812
2 changed files with 13 additions and 6 deletions
+5 -4
View File
@@ -326,7 +326,7 @@ function choose_from_menu ($options, $name, $selected="", $nothing="choose", $sc
}
}
function popup_form ($common, $options, $formname, $selected="", $nothing="choose", $help="", $helptext="", $return=false) {
function popup_form ($common, $options, $formname, $selected="", $nothing="choose", $help="", $helptext="", $return=false, $targetwindow="self") {
/// Implements a complete little popup form
/// $common = the URL up to the point of the variable that changes
/// $options = A list of value-label pairs for the popup list
@@ -343,7 +343,7 @@ function popup_form ($common, $options, $formname, $selected="", $nothing="choos
}
$startoutput = "<form target=\"{$CFG->framename}\" name=$formname>";
$output = "<select name=popup onchange=\"top.location=document.$formname.popup.options[document.$formname.popup.selectedIndex].value\">\n";
$output = "<select name=popup onchange=\"$targetwindow.location=document.$formname.popup.options[document.$formname.popup.selectedIndex].value\">\n";
if ($nothing != "") {
$output .= " <option value=\"javascript:void(0)\">$nothing</option>\n";
@@ -1291,7 +1291,7 @@ function update_categories_button() {
}
}
function navmenu($course, $cm=NULL) {
function navmenu($course, $cm=NULL, $targetwindow="self") {
// Given a course and a (current) coursemodule
// This function returns a small popup menu with all the
// course activity modules in it, as a navigation menu
@@ -1337,7 +1337,8 @@ function navmenu($course, $cm=NULL) {
}
}
return popup_form("$CFG->wwwroot/mod/", $menu, "navmenu", $selected, get_string("jumpto"), "", "", true);
return popup_form("$CFG->wwwroot/mod/", $menu, "navmenu", $selected, get_string("jumpto"),
"", "", true, $targetwindow);
}
+8 -2
View File
@@ -64,7 +64,7 @@
print_header($pagetitle, "$course->fullname",
"$navigation <a target=\"{$CFG->framename}\" href=\"$resource->reference\"
title=\"$resource->reference\">$resource->name</a>", "", "", true,
update_module_button($cm->id, $course->id, $strresource), navmenu($course, $cm));
update_module_button($cm->id, $course->id, $strresource), navmenu($course, $cm, "parent"));
echo "<center><font size=-1>".text_to_html($resource->summary, true, false)."</font></center>";
} else {
@@ -98,10 +98,16 @@
// (could check for more embeddable media here...)
if ($frameset == "top" or $embedded) {
if ($frameset == "top") {
$targetwindow = "parent";
} else {
$targetwindow = "self";
}
print_header($pagetitle, "$course->fullname",
"$navigation <a target=\"$CFG->framename\" HREF=\"$fullurl\">$resource->name</A>",
"", "", true, update_module_button($cm->id, $course->id, $strresource),
navmenu($course, $cm));
navmenu($course, $cm, $targetwindow));
echo "<center><font size=-1>".text_to_html($resource->summary, true, false)."</font></center>";
add_to_log($course->id, "resource", "view", "view.php?id=$cm->id", "$resource->id");
}