[LON-CAPA-cvs] cvs: doc /loncapafiles loncapafiles.lpml loncom/homework edit.pm inputtags.pm structuretags.pm loncom/html/adm/lonIcons transparent1x1.gif loncom/interface loncommon.pm lonhtmlcommon.pm loncom/xml lonxml.pm

raeburn raeburn@source.lon-capa.org
Sun, 08 Aug 2010 02:01:04 -0000


This is a MIME encoded message

--raeburn1281232864
Content-Type: text/plain

raeburn		Sun Aug  8 02:01:04 2010 EDT

  Added files:                 
    /loncom/html/adm/lonIcons	transparent1x1.gif 

  Modified files:              
    /loncom/interface	loncommon.pm lonhtmlcommon.pm 
    /loncom/xml	lonxml.pm 
    /loncom/homework	inputtags.pm structuretags.pm edit.pm 
    /doc/loncapafiles	loncapafiles.lpml 
  Log:
  - Replacement of user's environment.wysiwygeditor with link to switch to/from
    CKEditor 3 Richtext editor on textareas where needed.
  - Rich text editor link available for Text/HTML block in colorful editor
  - Eliminate duplicate Richtext link for textarea entry fields 
  - "Edit Math" button hidden when richtext editor enabled - use <span> instead
    of <div> for more compact display.
  - Help icon for "Edit Math" hidden by switching img src from help.png to
    transparent gif. Additional arg to loncommon::help_open_topic() is 
    imgid - id of img tag for icon associated with each "Edit Math" button.    
  
  
--raeburn1281232864
Content-Type: text/plain
Content-Disposition: attachment; filename="raeburn-20100808020104.txt"

Index: loncom/interface/loncommon.pm
diff -u loncom/interface/loncommon.pm:1.972 loncom/interface/loncommon.pm:1.973
--- loncom/interface/loncommon.pm:1.972	Sat Aug  7 19:23:50 2010
+++ loncom/interface/loncommon.pm	Sun Aug  8 02:00:38 2010
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # a pile of common routines
 #
-# $Id: loncommon.pm,v 1.972 2010/08/07 19:23:50 raeburn Exp $
+# $Id: loncommon.pm,v 1.973 2010/08/08 02:00:38 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1072,7 +1072,7 @@
 
 =pod
 
-=item * &help_open_topic($topic,$text,$stayOnPage,$width,$height)
+=item * &help_open_topic($topic,$text,$stayOnPage,$width,$height,$imgid)
 
 Returns a string corresponding to an HTML link to the given help
 $topic, where $topic corresponds to the name of a .tex file in
@@ -1090,12 +1090,16 @@
 
 $width and $height are optional numerical parameters that will
 override the width and height of the popped up window, which may
-be useful for certain help topics with big pictures included. 
+be useful for certain help topics with big pictures included.
+
+$imgid is the id of the img tag used for the help icon. This may be
+used in a javascript call to switch the image src.  See 
+lonhtmlcommon::htmlareaselectactive() for an example.
 
 =cut
 
 sub help_open_topic {
-    my ($topic, $text, $stayOnPage, $width, $height) = @_;
+    my ($topic, $text, $stayOnPage, $width, $height, $imgid) = @_;
     $text = "" if (not defined $text);
     $stayOnPage = 0 if (not defined $stayOnPage);
     $width = 350 if (not defined $width);
@@ -1124,10 +1128,13 @@
     # (Always) Add the graphic
     my $title = &mt('Online Help');
     my $helpicon=&lonhttpdurl("/adm/help/help.png");
+    if ($imgid ne '') {
+        $imgid = ' id="'.$imgid.'"';
+    }
     $template.=' <a target="_top" href="'.$link.'" title="'.$title.'">'
               .'<img src="'.$helpicon.'" border="0"'
               .' alt="'.&mt('Help: [_1]',$topic).'"'
-              .' title="'.$title.'" style="vertical-align:middle;"' 
+              .' title="'.$title.'" style="vertical-align:middle;"'.$imgid 
               .' /></a>';
     if ($text ne "") {	
         $template.='</span>';
Index: loncom/interface/lonhtmlcommon.pm
diff -u loncom/interface/lonhtmlcommon.pm:1.281 loncom/interface/lonhtmlcommon.pm:1.282
--- loncom/interface/lonhtmlcommon.pm:1.281	Sat Aug  7 19:23:50 2010
+++ loncom/interface/lonhtmlcommon.pm	Sun Aug  8 02:00:38 2010
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # a pile of common html routines
 #
-# $Id: lonhtmlcommon.pm,v 1.281 2010/08/07 19:23:50 raeburn Exp $
+# $Id: lonhtmlcommon.pm,v 1.282 2010/08/08 02:00:38 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -121,7 +121,7 @@
     my ($textarea,$helpicon) = @_;
     my $help_text; 
     if ($helpicon) {
-        $help_text = &Apache::loncommon::help_open_topic('Authoring_Math_Editor');
+        $help_text = &Apache::loncommon::help_open_topic('Authoring_Math_Editor',undef,undef,undef,undef,'mathhelpicon_'.$textarea);
     }
     my $buttontext=&mt('Edit Math');
     return <<ENDDRAGMATH;
@@ -1231,22 +1231,6 @@
 
 # ----------------------------------------------------------------- Preferences
 
-sub disablelink {
-    my @fields=@_;
-    if (defined($#fields)) {
-	unless ($#fields>=0) { return ''; }
-    }
-    return '<a href="'.&HTML::Entities::encode('/adm/preferences?action=set_wysiwyg&wysiwyg=off&returnurl=','<>&"').&escape($ENV{'REQUEST_URI'}).'">'.&mt('Disable WYSIWYG Editor').'</a>';
-}
-
-sub enablelink {
-    my @fields=@_;
-    if (defined($#fields)) {
-	unless ($#fields>=0) { return ''; }
-    }
-    return '<a href="'.&HTML::Entities::encode('/adm/preferences?action=set_wysiwyg&wysiwyg=on&returnurl=','<>&"').&escape($ENV{'REQUEST_URI'}).'">'.&mt('Enable WYSIWYG Editor').'</a>';
-}
-
 # ------------------------------------------------- lang to use in html editor
 sub htmlarea_lang {
     my $lang='en';
@@ -1265,7 +1249,7 @@
               .'// <![CDATA['."\n";
     my $lang = &htmlarea_lang();
     my $fullpage = 'false';
-    my $dragmath_prefix;
+    my ($dragmath_prefix,$dragmath_helpicon,$dragmath_whitespace);
     if (ref($args) eq 'HASH') {
         if (exists($args->{'lang'})) {
             if ($args->{'lang'} ne '') {
@@ -1280,6 +1264,8 @@
         if (exists($args->{'dragmath'})) {
             if ($args->{'dragmath'} ne '') {
                 $dragmath_prefix = $args->{'dragmath'};
+                $dragmath_helpicon=&Apache::loncommon::lonhttpdurl("/adm/help/help.png");
+                $dragmath_whitespace=&Apache::loncommon::lonhttpdurl("/adm/lonIcons/transparent1x1.gif");
             }
         }
     }
@@ -1383,6 +1369,16 @@
              return;
          }
          mathele.style.display = value;
+         var mathhelpicon = "'.$dragmath_prefix.'helpicon'.'_"+id;
+         mathhelpiconele = document.getElementById(mathhelpicon);
+         if (mathhelpiconele == null) {
+             return;
+         }
+         if (value == "none") {
+             mathhelpiconele.src = "'.$dragmath_whitespace.'";
+         } else {
+             mathhelpiconele.src = "'.$dragmath_helpicon.'";
+         }
      }
 ';
 
Index: loncom/xml/lonxml.pm
diff -u loncom/xml/lonxml.pm:1.512 loncom/xml/lonxml.pm:1.513
--- loncom/xml/lonxml.pm:1.512	Sat Aug  7 19:23:56 2010
+++ loncom/xml/lonxml.pm	Sun Aug  8 02:00:44 2010
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # XML Parser Module 
 #
-# $Id: lonxml.pm,v 1.512 2010/08/07 19:23:56 raeburn Exp $
+# $Id: lonxml.pm,v 1.513 2010/08/08 02:00:44 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1509,7 +1509,7 @@
 FULLPAGE
       }
       if ($filetype eq 'html' || $filetype eq 'tex') {
-              $dragmath_button = '<div id="math_filecont">'.&Apache::lonhtmlcommon::dragmath_button('filecont',1).'</div>';
+              $dragmath_button = '<span id="math_filecont" style="display: block;">'.&Apache::lonhtmlcommon::dragmath_button('filecont',1).'</span>';
               $initialize .= "\n".&Apache::lonhtmlcommon::dragmath_js('EditMathPopup');
       }
 
@@ -1554,15 +1554,14 @@
     <div class="LC_edit_problem_discards">
       <input type="submit" name="discardview" accesskey="d" value="$lt{'dv'}" />
       <input type="submit" name="Undo" accesskey="u" value="$lt{'un'}" />
-      $spelllink $htmlerror
+      $htmlerror $dragmath_button
     </div>
     <div class="LC_edit_problem_saves">
       <input type="submit" name="savethisfile" accesskey="s" value="$lt{'st'}" />
       <input type="submit" name="viewmode" accesskey="v" value="$lt{'vi'}" />
     </div>
   </div>
-$dragmath_button
-  <textarea $textarea_events style="width:100%" cols="80" rows="44" name="filecont" id="filecont" $textareaclass>$filecontents</textarea>
+  <textarea $textarea_events style="width:100%" cols="80" rows="44" name="filecont" id="filecont" $textareaclass>$filecontents</textarea><br />$spelllink
   <div id="LC_aftertextarea">
     <br />
     $titledisplay
Index: loncom/homework/inputtags.pm
diff -u loncom/homework/inputtags.pm:1.266 loncom/homework/inputtags.pm:1.267
--- loncom/homework/inputtags.pm:1.266	Sat Aug  7 19:24:03 2010
+++ loncom/homework/inputtags.pm	Sun Aug  8 02:00:50 2010
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # input  definitons
 #
-# $Id: inputtags.pm,v 1.266 2010/08/07 19:24:03 raeburn Exp $
+# $Id: inputtags.pm,v 1.267 2010/08/08 02:00:50 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -186,7 +186,6 @@
 	    if ($addchars) {
 		$result.=&addchars('HWVAL_'.$resid,$addchars);
 	    }
-            $result .= &Apache::lonhtmlcommon::htmlareaselectactive();
             my $textareaclass = 'class="LC_richDetectHtml"';
 	    $result.= '<textarea wrap="hard" name="HWVAL_'.$resid.'" id="HWVAL_'.$resid.'" '.
 		      'rows="'.$rows.'" cols="'.$cols.'" '.$textareaclass.'>'.
Index: loncom/homework/structuretags.pm
diff -u loncom/homework/structuretags.pm:1.473 loncom/homework/structuretags.pm:1.474
--- loncom/homework/structuretags.pm:1.473	Sat Aug  7 19:24:03 2010
+++ loncom/homework/structuretags.pm	Sun Aug  8 02:00:50 2010
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA 
 # definition of tags that give a structure to a document
 #
-# $Id: structuretags.pm,v 1.473 2010/08/07 19:24:03 raeburn Exp $
+# $Id: structuretags.pm,v 1.474 2010/08/08 02:00:50 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -177,12 +177,13 @@
 					   $parstack,$parser,$safeeval);
     }
 
-    $extra_head .= &homework_js();
-
-    if ($env{'environment.wysiwygeditor'} eq 'on') {
-	$extra_head .= &Apache::lonhtmlcommon::dragmath_js("FCKEditMathPopup");
-    } else {
-        $extra_head .= &Apache::lonhtmlcommon::dragmath_js("EditMathPopup");
+    $extra_head .= &homework_js().
+                   &Apache::lonhtmlcommon::dragmath_js("EditMathPopup");
+    if (&Apache::lonhtmlcommon::htmlareabrowser()) {
+        my %textarea_args = (
+                                dragmath => 'math',
+                              );
+        $extra_head .= &Apache::lonhtmlcommon::htmlareaselectactive(\%textarea_args);
     }
 
     my %body_args;
@@ -2044,17 +2045,15 @@
 	$result.=&Apache::edit::start_table($token)."<tr><td>".&mt('Text Block')."</td>"
                  .'<td><span class="LC_nobreak">'.&mt('Delete?').' '
                  .&Apache::edit::deletelist($target,$token)
-                 .'</span></td>';
-        unless ($env{'environment.wysiwygeditor'} eq 'on') {
-	    $result .= '<td align="left">'
-		.&Apache::lonhtmlcommon::dragmath_button($areaid,1)
-		.'</td>'
-		.'<td>'
-		.&Apache::edit::insertlist($target,$token)
-		.'</td>';
-	}
-	$result.='<td align="right" valign="top">' .
-	    &Apache::loncommon::helpLatexCheatsheet().
+                 .'</span></td>'
+	         .'<td align="left"><span id="math_'.$areaid.'" />'
+		 .&Apache::lonhtmlcommon::dragmath_button($areaid,1)
+		 .'<span></td>'
+		 .'<td>'
+		 .&Apache::edit::insertlist($target,$token)
+		 .'</td>'
+	         .'<td align="right" valign="top">' .
+	         &Apache::loncommon::helpLatexCheatsheet().
 		 &Apache::edit::end_row().
                  &Apache::edit::start_spanning_row()."\n".
 		 &Apache::edit::editfield($token->[1],$text,"",80,8,1);
Index: loncom/homework/edit.pm
diff -u loncom/homework/edit.pm:1.127 loncom/homework/edit.pm:1.128
--- loncom/homework/edit.pm:1.127	Sat Jun  5 19:36:57 2010
+++ loncom/homework/edit.pm	Sun Aug  8 02:00:50 2010
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA 
 # edit mode helpers
 #
-# $Id: edit.pm,v 1.127 2010/06/05 19:36:57 www Exp $
+# $Id: edit.pm,v 1.128 2010/08/08 02:00:50 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -731,19 +731,18 @@
     my ($tag,$data,$description,$minwidth,$minheight,$usehtmlarea)=@_;
 
     my ($rows,$cols)=&textarea_sizes(\$data);
-    if (&Apache::lonhtmlcommon::htmlareabrowser() &&
-	!&Apache::lonhtmlcommon::htmlareablocked()) {
+    my $textareaclass;
+ 
+    if (&Apache::lonhtmlcommon::htmlareabrowser() && $usehtmlarea) { 
 	$rows+=7;      # make room for HTMLarea
 	$minheight+=7; # make room for HTMLarea
+        $textareaclass = ' class="LC_richDefaultOff"';
     }
     if ($cols > 80) { $cols = 80; }
     if ($cols < $minwidth ) { $cols = $minwidth; }
     if ($rows < $minheight) { $rows = $minheight; }
     if ($description) { $description=$description."<br />"; }
-    if ($usehtmlarea) {
-	&Apache::lonhtmlcommon::add_htmlareafields('homework_edit_'.
-						   $Apache::lonxml::curdepth);
-    }
+
     # remove typesetting whitespace from between data and the end tag
     # to make the edit look prettier
     $data =~ s/\n?[ \t]*$//;
@@ -751,7 +750,8 @@
     return $description."\n".'<textarea style="width:100%" rows="'.$rows.
 	'" cols="'.$cols.'" name="homework_edit_'.
 	$Apache::lonxml::curdepth.'" id="homework_edit_'.
-	$Apache::lonxml::curdepth.'" '.&element_change_detection().'>'.
+	$Apache::lonxml::curdepth.'" '.&element_change_detection().
+        $textareaclass.'>'.
 	&HTML::Entities::encode($data,'<>&"').'</textarea>'.
 	($usehtmlarea?&Apache::lonhtmlcommon::spelllink('lonhomework',
 			 'homework_edit_'.$Apache::lonxml::curdepth):'')."\n";
Index: doc/loncapafiles/loncapafiles.lpml
diff -u doc/loncapafiles/loncapafiles.lpml:1.694 doc/loncapafiles/loncapafiles.lpml:1.695
--- doc/loncapafiles/loncapafiles.lpml:1.694	Sun Aug  8 00:21:52 2010
+++ doc/loncapafiles/loncapafiles.lpml	Sun Aug  8 02:01:03 2010
@@ -2,7 +2,7 @@
  "http://lpml.sourceforge.net/DTD/lpml.dtd">
 <!-- loncapafiles.lpml -->
 
-<!-- $Id: loncapafiles.lpml,v 1.694 2010/08/08 00:21:52 raeburn Exp $ -->
+<!-- $Id: loncapafiles.lpml,v 1.695 2010/08/08 02:01:03 raeburn Exp $ -->
 
 <!--
 
@@ -5996,6 +5996,7 @@
 tex_big.gif;
 tth.gif;
 text.gif;
+transparent1x1.gif
 txt.gif;
 txt_big.gif;
 unknown.gif;

--raeburn1281232864--