[LON-CAPA-cvs] cvs: loncom /interface loncommon.pm lonhelpmenu.pm

albertel lon-capa-cvs@mail.lon-capa.org
Thu, 20 Jul 2006 22:44:07 -0000


albertel		Thu Jul 20 18:44:07 2006 EDT

  Modified files:              
    /loncom/interface	loncommon.pm lonhelpmenu.pm 
  Log:
  - target _top to break out of frames (BUG#4925)
  - make the Help link work in more cases by emitting the JS in the h<head> section
  - make the help menu when not in popup mode more flexible
  
  
Index: loncom/interface/loncommon.pm
diff -u loncom/interface/loncommon.pm:1.435 loncom/interface/loncommon.pm:1.436
--- loncom/interface/loncommon.pm:1.435	Thu Jul 20 00:17:55 2006
+++ loncom/interface/loncommon.pm	Thu Jul 20 18:44:04 2006
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # a pile of common routines
 #
-# $Id: loncommon.pm,v 1.435 2006/07/20 04:17:55 albertel Exp $
+# $Id: loncommon.pm,v 1.436 2006/07/20 22:44:04 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -672,14 +672,14 @@
     {
 	$template .= 
   "<table bgcolor='#3333AA' cellspacing='1' cellpadding='1' border='0'><tr>".
-  "<td bgcolor='#5555FF'><a href=\"$link\"><font color='#FFFFFF' size='2'>$text</font></a>";
+  "<td bgcolor='#5555FF'><a target=\"_top\" href=\"$link\"><font color='#FFFFFF' size='2'>$text</font></a>";
     }
 
     # Add the graphic
     my $title = &mt('Online Help');
     my $helpicon=&lonhttpdurl("/adm/help/gif/smallHelp.gif");
     $template .= <<"ENDTEMPLATE";
- <a href="$link" title="$title"><img src="$helpicon" border="0" alt="(Help: $topic)" /></a>
+ <a target="_top" href="$link" title="$title"><img src="$helpicon" border="0" alt="(Help: $topic)" /></a>
 ENDTEMPLATE
     if ($text ne '') { $template.='</td></tr></table>' };
     return $template;
@@ -766,29 +766,35 @@
 sub top_nav_help {
     my ($text) = @_;
 
-    my ($topic,$component_help,$faq,$bug,$stayOnPage,$width,$height);
-   
-    $text = "" if (not defined $text);
-    $stayOnPage = 0 if (not defined $stayOnPage);
-    if ($env{'browser.interface'} eq 'textual' ||
-        $env{'environment.remote'} eq 'off' ) {
-        $stayOnPage=1;
-    }
-    $width = 620 if (not defined $width);
-    $height = 600 if (not defined $height);
-    my $link='';
+    $text = &mt($text);
+
+    my $stayOnPage = 
+	($env{'browser.interface'}  eq 'textual' ||
+	 $env{'environment.remote'} eq 'off' );
+    my $link=  ($stayOnPage) ? "javascript:helpMenu('display')"
+	                     : "javascript:helpMenu('open')";
+    my $banner_link = &update_help_link(undef,undef,undef,undef,$stayOnPage);
+
     my $title = &mt('Get help');
-    if ($stayOnPage) {
-	$link = "javascript:helpMenu('display')";
-    } else {
-        $link = "javascript:helpMenu('open')";
-    }
+
+    return <<"END";
+$banner_link
+ <a href="$link" title="$title">$text</a>
+END
+}
+
+sub help_menu_js {
+    my ($text) = @_;
+
+    my $stayOnPage = 
+	($env{'browser.interface'}  eq 'textual' ||
+	 $env{'environment.remote'} eq 'off' );
+
+    my $width = 620;
+    my $height = 600;
     my $helptopic=&general_help();
-    my $banner_link = &update_help_link($topic,$component_help,$faq,$bug,$stayOnPage);
     my $details_link = '/adm/help/'.$helptopic.'.hlp';
-    my $template;
     my $nothing=&Apache::lonhtmlcommon::javascript_nothing();
-    my $helpicon=&lonhttpdurl("/adm/lonIcons/helpgateway.gif");
     my $start_page =
         &Apache::loncommon::start_page('Help Menu', undef,
 				       {'frameset'    => 1,
@@ -800,8 +806,8 @@
         &Apache::loncommon::end_page({'frameset' => 1,
 				      'js_ready' => 1,});
 
-    $template .= <<"ENDTEMPLATE";
- <script type="text/javascript">
+    my $template .= <<"ENDTEMPLATE";
+<script type="text/javascript">
 // <!-- BEGIN LON-CAPA Internal
 // <![CDATA[
 var banner_link = '';
@@ -830,9 +836,7 @@
 }
 // ]]>
 // END LON-CAPA Internal -->
- </script>
-$banner_link
- <a href="$link" title="$title">$text</a>
+</script>
 ENDTEMPLATE
     return $template;
 }
@@ -868,14 +872,14 @@
     {
 	$template .= 
   "<table bgcolor='#AA3333' cellspacing='1' cellpadding='1' border='0'><tr>".
-  "<td bgcolor='#FF5555'><a href=\"$link\"><font color='#FFFFFF' size='2'>$text</font></a>";
+  "<td bgcolor='#FF5555'><a target=\"_top\" href=\"$link\"><font color='#FFFFFF' size='2'>$text</font></a>";
     }
 
     # Add the graphic
     my $title = &mt('Report a Bug');
     my $bugicon=&lonhttpdurl("/adm/lonMisc/smallBug.gif");
     $template .= <<"ENDTEMPLATE";
- <a href="$link" title="$title"><img src="$bugicon" border="0" alt="(Bug: $topic)" /></a>
+ <a target="_top" href="$link" title="$title"><img src="$bugicon" border="0" alt="(Bug: $topic)" /></a>
 ENDTEMPLATE
     if ($text ne '') { $template.='</td></tr></table>' };
     return $template;
@@ -913,14 +917,14 @@
     {
 	$template .= 
   "<table bgcolor='#337733' cellspacing='1' cellpadding='1' border='0'><tr>".
-  "<td bgcolor='#448844'><a href=\"$link\"><font color='#FFFFFF' size='2'>$text</font></a>";
+  "<td bgcolor='#448844'><a target=\"_top\" href=\"$link\"><font color='#FFFFFF' size='2'>$text</font></a>";
     }
 
     # Add the graphic
     my $title = &mt('View the FAQ');
     my $faqicon=&lonhttpdurl("/adm/lonMisc/smallFAQ.gif");
     $template .= <<"ENDTEMPLATE";
- <a href="$link" title="$title"><img src="$faqicon" border="0" alt="(FAQ: $topic)" /></a>
+ <a target="_top" href="$link" title="$title"><img src="$faqicon" border="0" alt="(FAQ: $topic)" /></a>
 ENDTEMPLATE
     if ($text ne '') { $template.='</td></tr></table>' };
     return $template;
@@ -3693,6 +3697,11 @@
     if ($args->{'force_register'}) {
 	$result .= &Apache::lonmenu::registerurl(1);
     }
+    if (!$args->{'no_nav_bar'} 
+	&& !$args->{'only_body'}
+	&& !$args->{'frameset'}) {
+	$result .= &help_menu_js();
+    }
 
     if (ref($args->{'redirect'})) {
 	my ($time,$url,$inhibit_continue) = @{$args->{'redirect'}};
@@ -3862,7 +3871,7 @@
     #&Apache::lonnet::logthis("start_page ".join(':',caller(0)));
     my %head_args;
     foreach my $arg ('redirect','force_register','domain','function',
-		     'bgcolor') {
+		     'bgcolor','frameset','no_nav_bar','body_only') {
 	if (defined($args->{$arg})) {
 	    $head_args{$arg} = $args->{$arg};
 	}
Index: loncom/interface/lonhelpmenu.pm
diff -u loncom/interface/lonhelpmenu.pm:1.31 loncom/interface/lonhelpmenu.pm:1.32
--- loncom/interface/lonhelpmenu.pm:1.31	Tue Jul 18 17:55:24 2006
+++ loncom/interface/lonhelpmenu.pm	Thu Jul 20 18:44:04 2006
@@ -141,7 +141,7 @@
 					'only_body'   => 1,});
     $r->print($start_page);
 
-    my $width = ($stayOnPage) ? '700' : '600';
+    my $width = ($stayOnPage) ? '95%' : '600';
 
     $r->print('<table id="LC_helpmenu" width="'.$width.'">');