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

albertel lon-capa-cvs@mail.lon-capa.org
Tue, 18 Apr 2006 19:18:17 -0000


albertel		Tue Apr 18 15:18:17 2006 EDT

  Modified files:              
    /loncom/interface	loncommon.pm 
  Log:
  - making the accessility enhancement ideas apply globally
  
  
Index: loncom/interface/loncommon.pm
diff -u loncom/interface/loncommon.pm:1.338 loncom/interface/loncommon.pm:1.339
--- loncom/interface/loncommon.pm:1.338	Fri Apr 14 17:09:51 2006
+++ loncom/interface/loncommon.pm	Tue Apr 18 15:18:17 2006
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # a pile of common routines
 #
-# $Id: loncommon.pm,v 1.338 2006/04/14 21:09:51 albertel Exp $
+# $Id: loncommon.pm,v 1.339 2006/04/18 19:18:17 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -2770,21 +2770,24 @@
 sub bodytag {
     my ($title,$function,$addentries,$bodyonly,$domain,$forcereg,$customtitle,
 	$notopbar,$bgcolor,$notitle)=@_;
+
     $title=&mt($title);
+
     $function = &get_users_function() if (!$function);
-    my $img=&designparm($function.'.img',$domain);
-    my $pgbg= $bgcolor || &designparm($function.'.pgbg',$domain);
-    my $tabbg=&designparm($function.'.tabbg',$domain);
-    my $font=&designparm($function.'.font',$domain);
-    my $link=&designparm($function.'.link',$domain);
-    my $alink=&designparm($function.'.alink',$domain);
-    my $vlink=&designparm($function.'.vlink',$domain);
-    my $sidebg=&designparm($function.'.sidebg',$domain);
-# Accessibility font enhance
-    my $addstyle='';
-    if ($env{'browser.fontenhance'} eq 'on') {
-	$addstyle=' font-size: x-large;';
-    }
+    my $img =    &designparm($function.'.img',$domain);
+    my $tabbg =  &designparm($function.'.tabbg',$domain);
+    my $font =   &designparm($function.'.font',$domain);
+    my $sidebg = &designparm($function.'.sidebg',$domain);
+    my $pgbg   = $bgcolor || &designparm($function.'.pgbg',$domain);
+
+    my %design = ( 'style'   => 'margin-top: 0px',
+		   'bgcolor' => $pgbg,
+		   'text'    => $font,
+                   'alink'   => &designparm($function.'.alink',$domain),
+		   'vlink'   => &designparm($function.'.vlink',$domain),
+		   'link'    => &designparm($function.'.link',$domain),);
+    @$addentries{keys(%design)} = @design{keys(%design)};
+
  # role and realm
     my ($role,$realm)
        =&Apache::lonnet::plaintext((split(/\./,$env{'request.role'}))[0]);
@@ -2813,8 +2816,7 @@
 .center { text-align: center; }
 .filename {font-family: monospace;}
 </style>
-<body bgcolor="$pgbg" text="$font" alink="$alink" vlink="$vlink" link="$link"
-style="margin-top: 0px;$addstyle" $extra_body_attr>
+<body $extra_body_attr>
 END
 
     $bodytag .= &Apache::lontexconvert::init_math_support();
@@ -2968,11 +2970,44 @@
     }
 
     if ($register) {
-	$attr_ref->{'onload'}   = &Apache::lonmenu::loadevents().
-	    $attr_ref->{'onload'};
-	$attr_ref->{'onunload'} = &Apache::lonmenu::unloadevents().
-	    $attr_ref->{'onunload'};
+	my ($on_load,$on_unload);
+	foreach my $key (keys(%{$attr_ref})) {
+	    if      (lc($key) eq 'onload') {
+		$on_load.=$attr_ref->{$key}.';';
+		delete($attr_ref->{$key});
+
+	    } elsif (lc($key) eq 'onunload') {
+		$on_unload.=$attr_ref->{$key}.';';
+		delete($attr_ref->{$key});
+	    }
+	}
+	$attr_ref->{'onload'}  =
+	    &Apache::lonmenu::loadevents().  $on_load;
+	$attr_ref->{'onunload'}=
+	    &Apache::lonmenu::unloadevents().$on_unload;
+    }
+
+# Accessibility font enhance
+    if ($env{'browser.fontenhance'} eq 'on') {
+	my $style;
+	foreach my $key (keys(%{$attr_ref})) {
+	    if (lc($key) eq 'style') {
+		$style.=$attr_ref->{$key}.';';
+		delete($attr_ref->{$key});
+	    }
+	}
+	$attr_ref->{'style'}=$style.'; font-size: x-large;';
     }
+
+    if ($env{'browser.blackwhite'} eq 'on') {
+	delete($attr_ref->{'font'});
+	delete($attr_ref->{'link'});
+	delete($attr_ref->{'alink'});
+	delete($attr_ref->{'vlink'});
+	delete($attr_ref->{'bgcolor'});
+	delete($attr_ref->{'background'});
+    }
+
     my $attr_string;
     foreach my $attr (keys(%$attr_ref)) {
 	$attr_string .= " $attr=\"".$attr_ref->{$attr}.'" ';