[LON-CAPA-cvs] cvs: loncom /interface lonhtmlcommon.pm /xml scripttag.pm

albertel lon-capa-cvs-allow@mail.lon-capa.org
Sat, 17 Nov 2007 01:46:44 -0000


albertel		Fri Nov 16 20:46:44 2007 EDT

  Modified files:              
    /loncom/interface	lonhtmlcommon.pm 
    /loncom/xml	scripttag.pm 
  Log:
  - BUG#5476 add a mime type option to the <window>
  
  
Index: loncom/interface/lonhtmlcommon.pm
diff -u loncom/interface/lonhtmlcommon.pm:1.170 loncom/interface/lonhtmlcommon.pm:1.171
--- loncom/interface/lonhtmlcommon.pm:1.170	Fri Nov 16 01:31:26 2007
+++ loncom/interface/lonhtmlcommon.pm	Fri Nov 16 20:46:03 2007
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # a pile of common html routines
 #
-# $Id: lonhtmlcommon.pm,v 1.170 2007/11/16 06:31:26 albertel Exp $
+# $Id: lonhtmlcommon.pm,v 1.171 2007/11/17 01:46:03 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -645,6 +645,8 @@
 ##############################################
 ##############################################
 sub javascript_docopen {
+    my ($mimetype) = @_;
+    $mimetype ||= 'text/html';
     # safari does not understand document.open() and loads "text/html"
     my $nothing = "''";
     my $user_browser;
@@ -658,7 +660,7 @@
     if ($user_browser eq 'safari' && $user_os =~ 'mac') {
         $nothing = "document.clear()";
     } else {
-	$nothing = "document.open('text/html','replace')";
+	$nothing = "document.open('$mimetype','replace')";
     }
     return $nothing;
 }
Index: loncom/xml/scripttag.pm
diff -u loncom/xml/scripttag.pm:1.145 loncom/xml/scripttag.pm:1.146
--- loncom/xml/scripttag.pm:1.145	Fri Nov 16 20:43:00 2007
+++ loncom/xml/scripttag.pm	Fri Nov 16 20:46:44 2007
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # <script> definiton
 #
-# $Id: scripttag.pm,v 1.145 2007/11/17 01:43:00 albertel Exp $
+# $Id: scripttag.pm,v 1.146 2007/11/17 01:46:44 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -333,11 +333,13 @@
 	$result.=&Apache::edit::text_arg('Text of Link:','linktext',$token,70);
 	$result.=&Apache::edit::text_arg('Height:','height',$token,5);
 	$result.=&Apache::edit::text_arg('Width:','width',$token,5);
+	$result.=&Apache::edit::text_arg('Mime Type:','mimetype',$token,5);
 	$result .=&Apache::edit::end_row().&Apache::edit::start_spanning_row();
     } elsif ($target eq 'modified') {
 	my $constructtag=&Apache::edit::get_new_args($token,$parstack,
 						     $safeeval,'linktext',
-						     'width','height');
+						     'width','height',
+						     'mimetype');
 	if ($constructtag) { $result=&Apache::edit::rebuild_tag($token); }
     }
     return $result;  
@@ -357,19 +359,24 @@
     if (!$width) { $width='500'; }
     my $height= &Apache::lonxml::get_param('height',$parstack,$safeeval);
     if (!$height) { $height='200'; }
+    my $mimetype= &Apache::lonxml::get_param('mimetype',$parstack,$safeeval)
+	          || 'text/html';
 
-    my $start_page =
-	&Apache::loncommon::start_page($linktext, undef,
-				       {'only_body' => 1,
-					'bgcolor'   => '#FFFFFF',
-					'js_ready'  => 1,});
-    my $end_page =
-	&Apache::loncommon::end_page({'js_ready' => 1,});
+    my ($start_page,$end_page);
+    if ($mimetype eq 'text/html') {
+	$start_page =
+	    &Apache::loncommon::start_page($linktext, undef,
+					   {'only_body' => 1,
+					    'bgcolor'   => '#FFFFFF',
+					    'js_ready'  => 1,});
+	$end_page =
+	    &Apache::loncommon::end_page({'js_ready' => 1,});
+    }
     $result = "<script type=\"text/javascript\">
 //<!--
  function LONCAPA_newwindow_$Apache::lonxml::curdepth() {
 newWindow=open(".&Apache::lonhtmlcommon::javascript_nothing().",'new_W','width=$width,height=$height,scrollbars=1');
-newWindow.".&Apache::lonhtmlcommon::javascript_docopen().";
+newWindow.".&Apache::lonhtmlcommon::javascript_docopen($mimetype).";
 newWindow.document.writeln('$start_page $output $end_page');
 newWindow.document.close();}
 //-->