[LON-CAPA-cvs] cvs: loncom /homework edit.pm /html/htmlarea/images ed_math.gif ed_math_eqn.gif /interface lonhtmlcommon.pm doc/loncapafiles loncapafiles.lpml

www lon-capa-cvs@mail.lon-capa.org
Fri, 04 Jun 2004 16:05:48 -0000


www		Fri Jun  4 12:05:48 2004 EDT

  Added files:                 
    /loncom/html/htmlarea/images	ed_math.gif ed_math_eqn.gif 

  Modified files:              
    /doc/loncapafiles	loncapafiles.lpml 
    /loncom/homework	edit.pm 
    /loncom/interface	lonhtmlcommon.pm 
  Log:
  Implementing the <m>-tag in HTMLarea - the GIFs are not real yet.
  
  
Index: doc/loncapafiles/loncapafiles.lpml
diff -u doc/loncapafiles/loncapafiles.lpml:1.357 doc/loncapafiles/loncapafiles.lpml:1.358
--- doc/loncapafiles/loncapafiles.lpml:1.357	Tue Jun  1 20:55:16 2004
+++ doc/loncapafiles/loncapafiles.lpml	Fri Jun  4 12:05:47 2004
@@ -2,7 +2,7 @@
  "http://lpml.sourceforge.net/DTD/lpml.dtd">
 <!-- loncapafiles.lpml -->
 
-<!-- $Id: loncapafiles.lpml,v 1.357 2004/06/02 00:55:16 www Exp $ -->
+<!-- $Id: loncapafiles.lpml,v 1.358 2004/06/04 16:05:47 www Exp $ -->
 
 <!--
 
@@ -1210,6 +1210,8 @@
 ed_indent_less.gif;
 ed_cut.gif;
 ed_indent_more.gif;
+ed_math.gif;
+ed_math_eqn.gif;
 </filenames>
 </fileglob>
 <fileglob>
Index: loncom/homework/edit.pm
diff -u loncom/homework/edit.pm:1.82 loncom/homework/edit.pm:1.83
--- loncom/homework/edit.pm:1.82	Thu Jun  3 12:42:02 2004
+++ loncom/homework/edit.pm	Fri Jun  4 12:05:47 2004
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA 
 # edit mode helpers
 #
-# $Id: edit.pm,v 1.82 2004/06/03 16:42:02 www Exp $
+# $Id: edit.pm,v 1.83 2004/06/04 16:05:47 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -487,7 +487,7 @@
     my ($tag,$data,$description,$minwidth,$minheight,$usehtmlarea)=@_;
 
     my ($rows,$cols)=&textarea_sizes(\$data);
-    $rows+=3; # make room for HTMLarea
+    $rows+=5; # make room for HTMLarea
     if ($cols > 80) { $cols = 80; }
     if ($cols < $minwidth ) { $cols = $minwidth; }
     if ($rows < $minheight) { $rows = $minheight; }
Index: loncom/interface/lonhtmlcommon.pm
diff -u loncom/interface/lonhtmlcommon.pm:1.73 loncom/interface/lonhtmlcommon.pm:1.74
--- loncom/interface/lonhtmlcommon.pm:1.73	Thu Jun  3 12:42:02 2004
+++ loncom/interface/lonhtmlcommon.pm	Fri Jun  4 12:05:47 2004
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # a pile of common html routines
 #
-# $Id: lonhtmlcommon.pm,v 1.73 2004/06/03 16:42:02 www Exp $
+# $Id: lonhtmlcommon.pm,v 1.74 2004/06/04 16:05:47 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -882,13 +882,36 @@
 ENDHEADERS
 }
 
+# ------------------------------------------------- Activate additional buttons
+
+sub htmlareaaddbuttons {
+    if (&htmlareablocked()) { return ''; }
+    return (<<ENDADDBUTTON);
+    var config=new HTMLArea.Config();
+    config.registerButton('ed_math','LaTeX Inline',
+			  '/htmlarea/images/ed_math.gif',false,
+			    function(editor,id) {
+			      editor.surroundHTML('<m>\$','\$</m>');
+			    }
+			  );
+    config.registerButton('ed_math_eqn','LaTeX Equation',
+			  '/htmlarea/images/ed_math_eqn.gif',false,
+			    function(editor,id) {
+			      editor.surroundHTML('<br /><m>\\\\[','\\\\]</m><br />');
+			    }
+			  );
+    config.toolbar.push(['ed_math','ed_math_eqn']);
+ENDADDBUTTON
+}
 # ---------------------------------------------------------- Script to activate
 
 sub htmlareaactive {
     if (&htmlareablocked()) { return ''; }
+    my $addbuttons=&htmlareaaddbuttons();
     return (<<ENDSCRIPT);
 <script type="text/javascript" defer="1">
-    HTMLArea.replaceAll();
+    $addbuttons
+    HTMLArea.replaceAll(config);
 </script>
 ENDSCRIPT
 }
@@ -898,9 +921,10 @@
 sub htmlareaselectactive {
     my @fields=@_;
     if (&htmlareablocked()) { return ''; }
-    my $output='<script type="text/javascript" defer="1">';
+    my $output='<script type="text/javascript" defer="1">'.
+	&htmlareaaddbuttons();
     foreach(@fields) {
-	$output.="\nHTMLArea.replace('$_');";
+	$output.="\nHTMLArea.replace('$_',config);";
     }
     $output.="\nwindow.status='Activated Editfields';\n</script>";
     return $output;