Diff for /loncom/interface/lonhtmlcommon.pm between versions 1.280 and 1.281

version 1.280, 2010/07/09 14:40:20 version 1.281, 2010/08/07 19:23:50
Line 1212  sub spelllink { Line 1212  sub spelllink {
 ENDLINK  ENDLINK
 }  }
   
 # ------------------------------------------------- Output headers for HTMLArea  # ------------------------------------------------- Output headers for CKEditor
   
 {  
     my @htmlareafields;  
     sub init_htmlareafields {  
  undef(@htmlareafields);  
     }  
       
     sub add_htmlareafields {  
  my (@newfields) = @_;  
  push(@htmlareafields,@newfields);  
     }  
   
     sub get_htmlareafields {  
  return @htmlareafields;  
     }  
 }  
   
 sub htmlareaheaders {  sub htmlareaheaders {
  my $s="";   my $s="";
Line 1275  sub htmlarea_lang { Line 1259  sub htmlarea_lang {
 # ----------------------------------------- Script to activate only some fields  # ----------------------------------------- Script to activate only some fields
   
 sub htmlareaselectactive {  sub htmlareaselectactive {
     my @fields=@_;      my ($args) = @_; 
     unless (&htmlareabrowser()) { return ''; }      unless (&htmlareabrowser()) { return ''; }
     my $output='<script type="text/javascript" defer="defer">'."\n"      my $output='<script type="text/javascript" defer="defer">'."\n"
               .'// <![CDATA['."\n";                .'// <![CDATA['."\n";
     my $lang = &htmlarea_lang();      my $lang = &htmlarea_lang();
       my $fullpage = 'false';
       my $dragmath_prefix;
       if (ref($args) eq 'HASH') {
           if (exists($args->{'lang'})) {
               if ($args->{'lang'} ne '') {
                   $lang = $args->{'lang'};
               }
           }
           if (exists($args->{'fullpage'})) { 
               if ($args->{'fullpage'} eq 'true') {
                   $fullpage = $args->{'fullpage'};
               }
           }
           if (exists($args->{'dragmath'})) {
               if ($args->{'dragmath'} ne '') {
                   $dragmath_prefix = $args->{'dragmath'};
               }
           }
       }
     $output.='      $output.='
           
     function containsBlockHtml(id) {      function containsBlockHtml(id) {
  var re = $("#"+id).html().search(/(?:\&lt\;|\<)(br|h1|h2|h3|h4|h5|h6|p|ol|ul|table|pre|address|blockquote|center|div)[\s]*((?:\/[\s]*(?:\&gt\;|\>)|(?:\&gt\;|\>)[\s\S]*(?:\&lt\;|\<)\/[\s]*\1[\s]*\(?:\&gt\;|\>))/im);   var re = $("#"+id).html().search(/(?:\&lt\;|\<)(br|h1|h2|h3|h4|h5|h6|p|ol|ul|table|pre|address|blockquote|center|div)[\s]*((?:[\/]*[\s]*(?:\&gt\;|\>)|(?:\&gt\;|\>)[\s\S]*(?:\&lt\;|\<)\/[\s]*\1[\s]*\(?:\&gt\;|\>))/im);
     return (re >= 0);      return (re >= 0);
     }      }
           
     function startRichEditor(id) {      function startRichEditor(id) {
     CKEDITOR.replace(id,       CKEDITOR.replace(id, 
     {      {
     customConfig: "/ckeditor/loncapaconfig.js"      customConfig: "/ckeditor/loncapaconfig.js",
                           language : "'.$lang.'",
                           fullPage : '.$fullpage.',
     }      }
     );      );
     }      }
Line 1301  sub htmlareaselectactive { Line 1306  sub htmlareaselectactive {
           
     function editorHandler(event) {      function editorHandler(event) {
     var rawid = $(this).attr("id");      var rawid = $(this).attr("id");
     var id = new RegExp("LC_rt_(.*)").exec(rawid)[1]      var id = new RegExp("LC_rt_(.*)").exec(rawid)[1];
     event.preventDefault();      event.preventDefault();
     if ($(this).hasClass("LC_enable_rt")) {      var rt_enabled  = $(this).hasClass("LC_enable_rt");
           if (rt_enabled) {
     startRichEditor(id);      startRichEditor(id);
  $("#LC_rt_"+id).html("<b>&laquo; Plain text</b>");   $("#LC_rt_"+id).html("<b>&laquo; Plain text</b>");
  $("#LC_rt_"+id).attr("title", "Disable rich text formatting and edit in plain text");   $("#LC_rt_"+id).attr("title", "Disable rich text formatting and edit in plain text");
Line 1315  sub htmlareaselectactive { Line 1321  sub htmlareaselectactive {
  $("#LC_rt_"+id).attr("title", "Enable rich text formatting (bold, italic, etc.)");   $("#LC_rt_"+id).attr("title", "Enable rich text formatting (bold, italic, etc.)");
  $("#LC_rt_"+id).addClass("LC_enable_rt");   $("#LC_rt_"+id).addClass("LC_enable_rt");
  $("#LC_rt_"+id).removeClass("LC_disable_rt");   $("#LC_rt_"+id).removeClass("LC_disable_rt");
  }   }';
  }      if ($dragmath_prefix ne '') {
               $output .= "\n                 var visible = '';
                                          if (rt_enabled) {
                                              visible = 'none';
                                          }
                                          editmath_visibility(id,visible);\n";
       }
       $output .= '
       }
     $(document).ready(function(){      $(document).ready(function(){
  $(".LC_richAlwaysOn").each(function() {   $(".LC_richAlwaysOn").each(function() {
  startRichEditor($(this).attr("id"));   startRichEditor($(this).attr("id"));
  });   });
  $(".LC_richDetectHtml").each(function() {   $(".LC_richDetectHtml").each(function() {
  var id = $(this).attr("id");   var id = $(this).attr("id");
  if(containsBlockHtml(id)) {                          var rt_enabled = containsBlockHtml(id);
    if(rt_enabled) {
  $(this).before("<div><a href=\"#\" id=\"LC_rt_"+id+"\" title=\"Disable rich text formatting and edit in plain text\" class=\"LC_disable_rt\"><b>&laquo; Plain text</b></a></div>");   $(this).before("<div><a href=\"#\" id=\"LC_rt_"+id+"\" title=\"Disable rich text formatting and edit in plain text\" class=\"LC_disable_rt\"><b>&laquo; Plain text</b></a></div>");
  startRichEditor(id);   startRichEditor(id);
  $("#LC_rt_"+id).click(editorHandler);   $("#LC_rt_"+id).click(editorHandler);
  }   }
  else {   else {
  $(this).before("<div><a href=\"#\" id=\"LC_rt_"+id+"\" title=\"Enable rich text formatting (bold, italic, etc.)\" class=\"LC_enable_rt\"><b>Rich formatting &raquo;</b></a></div>");   $(this).before("<div><a href=\"#\" id=\"LC_rt_"+id+"\" title=\"Enable rich text formatting (bold, italic, etc.)\" class=\"LC_enable_rt\"><b>Rich formatting &raquo;</b></a></div>");
  $("#LC_rt_"+id).click(editorHandler);   $("#LC_rt_"+id).click(editorHandler);
  }   }';
       if ($dragmath_prefix ne '') {
           $output .= "\n                 var visible = '';
                                          if (rt_enabled) {
                                              visible = 'none';
                                          }
                                          editmath_visibility(id,visible);\n";
       }
       $output .= '
  });   });
  $(".LC_richDefaultOn").each(function() {   $(".LC_richDefaultOn").each(function() {
  var id = $(this).attr("id");   var id = $(this).attr("id");
Line 1343  sub htmlareaselectactive { Line 1365  sub htmlareaselectactive {
  $(".LC_richDefaultOff").each(function() {   $(".LC_richDefaultOff").each(function() {
  var id = $(this).attr("id");   var id = $(this).attr("id");
  $(this).before("<div><a href=\"#\" id=\"LC_rt_"+id+"\" title=\"Enable rich text formatting (bold, italic, etc.)\" class=\"LC_enable_rt\"><b>Rich formatting &raquo;</b></a></div>");   $(this).before("<div><a href=\"#\" id=\"LC_rt_"+id+"\" title=\"Enable rich text formatting (bold, italic, etc.)\" class=\"LC_enable_rt\"><b>Rich formatting &raquo;</b></a></div>");
  $("#LC_rt_"+id).click(editorHandler);   $("#LC_rt_"+id).click(editorHandler);
  });   });
   
  });   });
 ';   ';
       if ($dragmath_prefix ne '') {
           $output .= '
   
        function editmath_visibility(id,value) {
   
            if ((id == "") || (id == null)) {
                return;
            }
            var mathid = "'.$dragmath_prefix.'_"+id;
            mathele = document.getElementById(mathid);
            if (mathele == null) {
                return;
            }
            mathele.style.display = value;
        }
   ';
   
       }
     $output.="\nwindow.status='Activated Editfields';\n"      $output.="\nwindow.status='Activated Editfields';\n"
             .'// ]]>'."\n"              .'// ]]>'."\n"
             .'</script><br />';              .'</script>';
     return $output;      return $output;
 }  }
   

Removed from v.1.280  
changed lines
  Added in v.1.281


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>