]> git.mjollnir.org Git - moodle.git/commitdiff
Some fixes so that navmenus don't jump out of frames any more.
authormoodler <moodler>
Tue, 26 Aug 2003 06:01:13 +0000 (06:01 +0000)
committermoodler <moodler>
Tue, 26 Aug 2003 06:01:13 +0000 (06:01 +0000)
The navmenu function now takes a third parameter that specifies
the window to change location of (default 'self', but could be "parent" or "top")

lib/weblib.php
mod/resource/view.php

index 0cecd60315a3e88f154b627ca57ad983d08daebd..b8bb95dbc337c2854b7aefd95c03acfcdb53331f 100644 (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);
 }   
 
 
index ae339f968190451884e6809f5c83ee3855422755..61a89e932613eab91f6ba52ff5ec77fc2a64dbc2 100644 (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 {
             // (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");
             }