[LON-CAPA-cvs] cvs: loncom /homework lonhomework.pm /interface lonhtmlcommon.pm

foxr lon-capa-cvs-allow@mail.lon-capa.org
Mon, 07 Jul 2008 11:02:26 -0000


foxr		Mon Jul  7 07:02:26 2008 EDT

  Modified files:              
    /loncom/interface	lonhtmlcommon.pm 
    /loncom/homework	lonhomework.pm 
  Log:
  Factor out generation of dragmath -> text area, so that this can
  be re-used in the multicolored monster/editor.
  
  
Index: loncom/interface/lonhtmlcommon.pm
diff -u loncom/interface/lonhtmlcommon.pm:1.175 loncom/interface/lonhtmlcommon.pm:1.176
--- loncom/interface/lonhtmlcommon.pm:1.175	Sat May 31 20:04:39 2008
+++ loncom/interface/lonhtmlcommon.pm	Mon Jul  7 07:02:05 2008
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # a pile of common html routines
 #
-# $Id: lonhtmlcommon.pm,v 1.175 2008/06/01 00:04:39 raeburn Exp $
+# $Id: lonhtmlcommon.pm,v 1.176 2008/07/07 11:02:05 foxr Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -62,6 +62,41 @@
 use Apache::lonnet;
 use LONCAPA;
 
+
+##############################################
+##############################################
+
+=pod
+
+=item dragmath
+
+Creates a button that will allow dragmath to edit an equation into 
+a specified textbox.
+
+  textarea - Name of the text area to edit.
+=cut
+
+##############################################
+# TODO: Figure out a way to only emit the mathedit function once.
+#       per html output document.
+#
+##############################################
+
+sub dragmath {
+    my ($textarea) = @_;
+
+    return <<ENDDRAGMATH;
+                <script language="JavaScript">
+                  function mathedit(textarea, doc) {
+                     targetEntry = textarea;
+		     targetDoc   = doc;
+                     newwin  = window.open("/adm/dragmath/applet/EditMathPopup.html","","width=565,height=500,resizable");
+                  }
+                </script>
+                <input type="button" value="Edit Math", onclick="javascript:mathedit('$textarea',document)" />
+ENDDRAGMATH
+}
+
 ##############################################
 ##############################################
 
@@ -1922,6 +1957,8 @@
     return $scripttag;
 }
 
+
+
 1;
 
 __END__
Index: loncom/homework/lonhomework.pm
diff -u loncom/homework/lonhomework.pm:1.294 loncom/homework/lonhomework.pm:1.295
--- loncom/homework/lonhomework.pm:1.294	Tue Jul  1 07:01:30 2008
+++ loncom/homework/lonhomework.pm	Mon Jul  7 07:02:25 2008
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # The LON-CAPA Homework handler
 #
-# $Id: lonhomework.pm,v 1.294 2008/07/01 11:01:30 foxr Exp $
+# $Id: lonhomework.pm,v 1.295 2008/07/07 11:02:25 foxr Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -937,16 +937,7 @@
 	    &Apache::loncommon::resize_textarea_js().
             &Apache::structuretags::setmode_javascript();
 	my $only_body =  ($env{'environment.remote'} eq 'off')? 0 : 1;
-	my $dragmath = <<ENDDRAGMATH;
-                <script language="JavaScript">
-                  function mathedit(textarea, doc) {
-                     targetEntry = textarea;
-		     targetDoc   = doc;
-                     newwin  = window.open("/adm/dragmath/applet/EditMathPopup.html","","width=565,height=500,resizable");
-                  }
-                </script>
-                <input type="button" value="Edit Math", onclick="javascript:mathedit('LC_editxmltext',document)" />
-ENDDRAGMATH
+	my $dragmath = &Apache::lonhtmlcommon::dragmath("LC_editxmltext");
 	my $start_page = 
 	    &Apache::loncommon::start_page(&mt("EditXML [_1]",$file),$js,
 					   {'no_auto_mt_title' => 1,