Diff for /loncom/homework/inputtags.pm between versions 1.309 and 1.310

version 1.309, 2012/09/14 11:23:58 version 1.310, 2012/09/24 10:34:19
Line 125  sub initialize_inputtags { Line 125  sub initialize_inputtags {
     %Apache::inputtags::submission_display=();      %Apache::inputtags::submission_display=();
 }  }
   
   #
   #  provides the onblur binding for spellchecking.  This could be an
   #  empty string if spellchecking was not enabled.
   #  Jquery selector binding is done rather than setting an onblur
   #  attribute because we'll need to set the element's spellcheck language
   #  option dynamically so we need $(this) to be defined.
   #
   # @param id   - The element id to bind.
   # @param lang - Language in which spellchecking is desired.
   #               if undef, nothing is generated.  
   # @return string - onblur specification to do the requested spellchecking.
   #
   sub spellcheck_onblur {
       my ($id, $lang) = @_;
       my $result = '';
       if ($lang) {
   
    $result = <<JAVASCRIPT;
   <script type="text/javascript">
   \$('\#$id').blur(function() {
       doSpellcheck('\#$id', '$lang');
    });
   </script>
   
   JAVASCRIPT
   
   
       }
       return $result;
   }
   
 sub check_for_duplicate_ids {  sub check_for_duplicate_ids {
     my %check;      my %check;
     foreach my $id (@Apache::inputtags::partlist,      foreach my $id (@Apache::inputtags::partlist,
Line 194  sub start_textfield { Line 225  sub start_textfield {
     if ( $rows eq '') { $rows = 16; }      if ( $rows eq '') { $rows = 16; }
     my $addchars=&Apache::lonxml::get_param('addchars',$parstack,$safeeval);      my $addchars=&Apache::lonxml::get_param('addchars',$parstack,$safeeval);
     $result='';      $result='';
       my $tagident = 'HWVAL_' . $resid;
     if ($addchars) {      if ($addchars) {
  $result.=&addchars('HWVAL_'.$resid,$addchars);   $result.=&addchars($tagident, $addchars);
     }      }
             my $textareaclass = 'class="LC_richDetectHtml spellchecked"';              my $textareaclass = 'class="LC_richDetectHtml spellchecked"';
     $result.= '<textarea wrap="hard" name="HWVAL_'.$resid.'" id="HWVAL_'.$resid.'" ' .      $result.= '<textarea wrap="hard" name="'.$tagident.'" id="'.$tagident.'" ' .
       'rows="'.$rows.'" cols="'.$cols.'" '.$textareaclass        'rows="'.$rows.'" cols="'.$cols.'" '.$textareaclass
       . "onblur='\$(this).spellchecker(\"check\")'"  
       .'>'.        .'>'.
                       &HTML::Entities::encode($oldresponse,'<>&"');                        &HTML::Entities::encode($oldresponse,'<>&"');
     if ($oldresponse ne '') {      if ($oldresponse ne '') {
Line 268  sub end_textfield { Line 299  sub end_textfield {
     my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;      my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
     my $result;      my $result;
     if ($target eq 'web') {      if ($target eq 'web') {
    my $spellcheck = &Apache::lonxml::get_param('spellcheck', $parstack, $safeeval);
  $Apache::lonxml::evaluate++;   $Apache::lonxml::evaluate++;
  if ($Apache::inputtags::status[-1] eq 'CAN_ANSWER') {   if ($Apache::inputtags::status[-1] eq 'CAN_ANSWER') {
     return "</textarea>";      my $resid = $Apache::inputtags::response[-1];
       my $tagident = 'HWVAL_' . $resid;
       my $result =  "</textarea>";
       $result .= &spellcheck_onblur($tagident, $spellcheck);
       return $result;
  }   }
     } elsif ($target eq 'edit') {      } elsif ($target eq 'edit') {
  $result=&Apache::edit::end_table();   $result=&Apache::edit::end_table();
Line 334  sub start_textline { Line 370  sub start_textline {
     my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;      my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
     my $result = "";      my $result = "";
     my $input_id = &start_input($parstack,$safeeval);      my $input_id = &start_input($parstack,$safeeval);
   
       # The spellcheck attribute 
       # 1. enables spellchecking.
       # 2. Provides the language code in which the spellchecking will be performed.
   
       my $spellcheck = &Apache::lonxml::get_param('spellcheck', $parstack, $safeeval);
     if ($target eq 'web') {      if ($target eq 'web') {
  $Apache::lonxml::evaluate--;   $Apache::lonxml::evaluate--;
  my $partid=$Apache::inputtags::part;   my $partid=$Apache::inputtags::part;
Line 384  sub start_textline { Line 426  sub start_textline {
  if ($Apache::inputtags::status[-1] eq 'CANNOT_ANSWER') {   if ($Apache::inputtags::status[-1] eq 'CANNOT_ANSWER') {
     $name = "none";      $name = "none";
  }   }
  $result.= '<input onkeydown="javascript:setSubmittedPart(\''.$partid.'\');" type="text" '.$readonly.' name="'.$name.'" value="'.   $result.= '<input onkeydown="javascript:setSubmittedPart(\''.$partid.'\');"'
     $oldresponse.'" class="spellchecked"  size="'.$size.'"'.$maxlength.'       . ' type="text" '
                     onblur=' . "'\$(this).spellchecker(\"check\")'"  . '/>';       . $readonly.' name="'. $name . '"'
        . ' id="' . $name . '"'
        . ' value="'.  $oldresponse.'"'
        . ' class="spellchecked"  size="'.$size.'"'.$maxlength
        . '/>';
   
    $result .= &spellcheck_onblur($name, $spellcheck);
     }      }
     if ($Apache::lonhomework::type eq 'exam'      if ($Apache::lonhomework::type eq 'exam'
  && &needs_exam_box($tagstack)) {   && &needs_exam_box($tagstack)) {

Removed from v.1.309  
changed lines
  Added in v.1.310


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