Diff for /loncom/interface/lonhtmlcommon.pm between versions 1.254 and 1.255

version 1.254, 2009/12/11 17:25:01 version 1.255, 2009/12/22 05:33:36
Line 383  dname_hour, dname_min, and dname_sec. Line 383  dname_hour, dname_min, and dname_sec.
   
 The current setting for this time parameter.  A unix format time  The current setting for this time parameter.  A unix format time
 (time in seconds since the beginning of Jan 1st, 1970, GMT.    (time in seconds since the beginning of Jan 1st, 1970, GMT.  
 An undefined value is taken to indicate the value is the current time  An undefined value is taken to indicate the value is the current time.
 unless it is requested to leave it empty. See $includeempty.   
 Also, to be explicit, a value of 'now' also indicates the current time.  Also, to be explicit, a value of 'now' also indicates the current time.
   
 =item $special  =item $special
Line 394  the date_setter.  See lonparmset for exa Line 393  the date_setter.  See lonparmset for exa
   
 =item $includeempty   =item $includeempty 
   
 If it is set (true) and no date/time value is provided,  
 the date/time fields are left empty.  
   
 =item $state  =item $state
   
 Specifies the initial state of the form elements.  Either 'disabled' or empty.  Specifies the initial state of the form elements.  Either 'disabled' or empty.
Line 416  sub date_setter { Line 412  sub date_setter {
     my ($formname,$dname,$currentvalue,$special,$includeempty,$state,      my ($formname,$dname,$currentvalue,$special,$includeempty,$state,
         $no_hh_mm_ss,$defhour,$defmin,$defsec,$nolink) = @_;          $no_hh_mm_ss,$defhour,$defmin,$defsec,$nolink) = @_;
     my $now = time;      my $now = time;
       my $wasdefined=1;
     my $tzname;  
     my ($sec,$min,$hour,$mday,$month,$year) = ('','',undef,'','','');  
     # other potentially useful values:     wkday,yrday,is_daylight_savings  
   
     if (! defined($state) || $state ne 'disabled') {      if (! defined($state) || $state ne 'disabled') {
         $state = '';          $state = '';
     }      }
     if (! defined($no_hh_mm_ss)) {      if (! defined($no_hh_mm_ss)) {
         $no_hh_mm_ss = 0;          $no_hh_mm_ss = 0;
     }      }
       
     if ($currentvalue eq 'now') {      if ($currentvalue eq 'now') {
         $currentvalue = $now;   $currentvalue = $now;
     }      }
               if ((!defined($currentvalue)) || ($currentvalue eq '')) {
     # Default value: Set empty date field to current time   $wasdefined=0;
     # unless empty inclusion is requested   if ($includeempty) {
     if ((!$includeempty) && (!$currentvalue)) {      $currentvalue = 0;
             $currentvalue = $now;   } else {
       $currentvalue = $now;
    }
     }      }
     # Do we have a date? Split it!      # other potentially useful values:     wkday,yrday,is_daylight_savings
       my $tzname;
       my ($sec,$min,$hour,$mday,$month,$year)=('','',undef,'','','');
     if ($currentvalue) {      if ($currentvalue) {
         ($tzname,$sec,$min,$hour,$mday,$month,$year) = &get_timedates($currentvalue);          ($tzname,$sec,$min,$hour,$mday,$month,$year) = &get_timedates($currentvalue); 
       }
         # No values provided for hour, min, sec? Use default 0      unless ($wasdefined) {
         if (($defhour) || ($defmin) || ($defsec)) {          ($tzname,$sec,$min,$hour,$mday,$month,$year) = &get_timedates($now);
             $sec  = ($defsec  ? $defsec  : 0);   if (($defhour) || ($defmin) || ($defsec)) {
             $min  = ($defmin  ? $defmin  : 0);      $sec=($defsec?$defsec:0);
             $hour = ($defhour ? $defhour : 0);      $min=($defmin?$defmin:0);
         }      $hour=($defhour?$defhour:0);
    } elsif (!$includeempty) {
       $sec=0;
       $min=0;
       $hour=0;
    }
     }      }
   
     # Create Output  
     my $result = "\n<!-- $dname date setting form -->\n";      my $result = "\n<!-- $dname date setting form -->\n";
     $result .= <<ENDJS;      $result .= <<ENDJS;
 <script type="text/javascript">  <script type="text/javascript">
Line 1243  ENDLINK Line 1241  ENDLINK
 }  }
   
 sub htmlareaheaders {  sub htmlareaheaders {
     return if (&htmlareablocked());   my $s="";
     return if (!&htmlareabrowser());   if (!&htmlareablocked() && &htmlareabrowser()) {
     return (<<ENDHEADERS);   $s.=(<<ENDEDITOR);
 <script type="text/javascript" src="/fckeditor/fckeditor.js"></script>  <script type="text/javascript" src="/fckeditor/fckeditor.js"></script>
 ENDHEADERS  <script type="text/javascript" src="/ckeditor/ckeditor.js"></script>
   ENDEDITOR
    }
       $s.=(<<ENDJQUERY);
   <script type="text/javascript" src="/adm/jQuery/js/jquery-1.3.2.min.js"></script>
   <script type="text/javascript" src="/adm/jQuery/js/jquery-ui-1.7.2.custom.min.js"></script>
   ENDJQUERY
    return $s;
 }  }
   
 # ----------------------------------------------------------------- Preferences  # ----------------------------------------------------------------- Preferences
Line 1286  sub htmlareaselectactive { Line 1291  sub htmlareaselectactive {
     my $output='<script type="text/javascript" defer="1">'."\n"      my $output='<script type="text/javascript" defer="1">'."\n"
               .'// <![CDATA['."\n";                .'// <![CDATA['."\n";
     my $lang = &htmlarea_lang();      my $lang = &htmlarea_lang();
     foreach my $field (@fields) {      $output.='
  $output.="      
 {      function containsBlockHtml(id) {
     var oFCKeditor = new FCKeditor('$field');   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);
     oFCKeditor.Config['CustomConfigurationsPath'] =       return (re >= 0);
  '/fckeditor/loncapaconfig.js';          }
     oFCKeditor.ReplaceTextarea();      
     oFCKeditor.Config['AutoDetectLanguage'] = false;      function startRichEditor(id) {
     oFCKeditor.Config['DefaultLanguage'] = '$lang';      CKEDITOR.replace(id, 
 }";      {
       customConfig: "/ckeditor/loncapaconfig.js",
       }
       );
     }      }
       
       function destroyRichEditor(id) {
       CKEDITOR.instances[id].destroy();
       }
       
       function editorHandler(event) {
       var rawid = $(this).attr("id");
       var id = new RegExp("LC_rt_(.*)").exec(rawid)[1]
       event.preventDefault();
       if ($(this).hasClass("LC_enable_rt")) {
       startRichEditor(id);
    $("#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).addClass("LC_disable_rt");
    $("#LC_rt_"+id).removeClass("LC_enable_rt");
       } else {
    destroyRichEditor(id);
    $("#LC_rt_"+id).html("<b>Rich formatting &raquo;</b>");
    $("#LC_rt_"+id).attr("title", "Enable rich text formatting (bold, italic, etc.)");
    $("#LC_rt_"+id).addClass("LC_enable_rt");
    $("#LC_rt_"+id).removeClass("LC_disable_rt");
    }
    }
       
       $(document).ready(function(){
    $(".LC_richAlwaysOn").each(function() {
    startRichEditor($(this).attr("id"));
    });
    $(".LC_richDetectHtml").each(function() {
    var id = $(this).attr("id");
    if(containsBlockHtml(id)) {
    $(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);
    $("#LC_rt_"+id).click(editorHandler);
    }
    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>");
    $("#LC_rt_"+id).click(editorHandler);
    }
    });
    $(".LC_richDefaultOn").each(function() {
    var id = $(this).attr("id");
    $(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);
    $("#LC_rt_"+id).click(editorHandler);
    });
    $(".LC_richDefaultOff").each(function() {
    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>");
    $("#LC_rt_"+id).click(editorHandler);
    });
    });
   ';
       
     $output.="\nwindow.status='Activated Editfields';\n"      $output.="\nwindow.status='Activated Editfields';\n"
             .'// ]]>'."\n"              .'// ]]>'."\n"
             .'</script><br />'.              .'</script><br />'.

Removed from v.1.254  
changed lines
  Added in v.1.255


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