Diff for /loncom/interface/lonhtmlcommon.pm between versions 1.294 and 1.314

version 1.294, 2011/10/23 00:27:10 version 1.314, 2012/05/28 13:09:17
Line 72  sub java_not_enabled { Line 72  sub java_not_enabled {
 sub coursepreflink {  sub coursepreflink {
    my ($text,$category)=@_;     my ($text,$category)=@_;
    if (&Apache::lonnet::allowed('opa',$env{'request.course.id'})) {     if (&Apache::lonnet::allowed('opa',$env{'request.course.id'})) {
       return '<a href="'.&HTML::Entities::encode("/adm/courseprefs?phase=display&actions=$category",'<>&"').'"><span class="LC_setting">'.$text.'</span></a>';        return '<a target="_top" href="'.&HTML::Entities::encode("/adm/courseprefs?phase=display&actions=$category",'<>&"').'"><span class="LC_setting">'.$text.'</span></a>';
    } else {     } else {
       return '';        return '';
    }     }
Line 95  sub direct_parm_link { Line 95  sub direct_parm_link {
     $filter=&entity_encode($filter);      $filter=&entity_encode($filter);
     $part=&entity_encode($part);      $part=&entity_encode($part);
     if (($symb) && (&Apache::lonnet::allowed('opa')) && ($target ne 'tex')) {      if (($symb) && (&Apache::lonnet::allowed('opa')) && ($target ne 'tex')) {
        return "<a href='/adm/parmset?symb=$symb&filter=$filter&part=$part'><span class='LC_setting'>$linktext</span></a>";         return "<a target='_top' href='/adm/parmset?symb=$symb&filter=$filter&part=$part'><span class='LC_setting'>$linktext</span></a>";
     } else {      } else {
        return $linktext;         return $linktext;
     }      }
Line 103  sub direct_parm_link { Line 103  sub direct_parm_link {
 ##############################################  ##############################################
 ##############################################  ##############################################
   
 =item confirm_success  =item &confirm_success()
   
 Successful completion of an operation message  Successful completion of an operation message
   
Line 129  sub confirm_success { Line 129  sub confirm_success {
   
 =pod  =pod
   
 =item dragmath_button  =item &dragmath_button()
   
 Creates a button that launches a dragmath popup-window, in which an   Creates a button that launches a dragmath popup-window, in which an 
 expression can be edited and pasted as LaTeX into a specified textarea.   expression can be edited and pasted as LaTeX into a specified textarea. 
Line 155  ENDDRAGMATH Line 155  ENDDRAGMATH
   
 =pod  =pod
   
 =item dragmath_js  =item &dragmath_js()
   
 Javascript used to open pop-up window containing dragmath applet which   Javascript used to open pop-up window containing dragmath applet which 
 can be used to paste LaTeX into a textarea.  can be used to paste LaTeX into a textarea.
   
 =cut  =cut
   
 sub dragmath_js {  sub dragmath_js {
Line 177  sub dragmath_js { Line 178  sub dragmath_js {
 ENDDRAGMATHJS  ENDDRAGMATHJS
 }  }
   
   ##############################################
   ##############################################
   
   =pod
   
   =item &dependencies_button()
   
   Creates a button that launches a popup-window, in which dependencies  
   for the web page in the main window can be added to, replaced or deleted.  
   
   =cut
   
   sub dependencies_button {
       my $buttontext=&mt('Manage Dependencies');
       return <<"END";
                   <input type="button" value="$buttontext" onclick="javascript:dependencycheck();" />
   END
   }
   
   ##############################################
   
   =pod
   
   =item &dependencycheck_js()
   
   Javascript used to open pop-up window containing interface to manage 
   dependencies for a web page uploaded diretcly to a course.
   
   =cut
   
   sub dependencycheck_js {
       my ($symb,$title) = @_;
       my $link = '/adm/dependencies?symb='.&HTML::Entities::encode($symb,'<>&"').
                  '&title='.&HTML::Entities::encode($title,'<>&"');
       return <<ENDJS;
                   <script type="text/javascript">
                   // <![CDATA[
                     function dependencycheck() {
                        depwin  = window.open("$link","","width=750,height=500,resizable,scrollbars=yes");
                     }
                   // ]]>
                   </script>
   ENDJS
   }
   
 ##############################################  ##############################################
 ##############################################  ##############################################
   
 =pod  =pod
   
 =item authorbombs  =item &authorbombs()
   
 =cut  =cut
   
Line 317  sub get_recent_frozen { Line 362  sub get_recent_frozen {
   
 =pod  =pod
   
 =item textbox  =item &textbox()
   
 =cut  =cut
   
Line 337  sub textbox { Line 382  sub textbox {
   
 =pod  =pod
   
 =item checkbox  =item &checkbox()
   
 =cut  =cut
   
Line 359  sub checkbox { Line 404  sub checkbox {
   
 =pod  =pod
   
 =item radiobutton  =item &radiobutton()
   
 =cut  =cut
   
Line 383  sub radio { Line 428  sub radio {
   
 =pod  =pod
   
 =item &date_setter  =item &date_setter()
   
 &date_setter returns html and javascript for a compact date-setting form.  &date_setter returns html and javascript for a compact date-setting form.
 To retrieve values from it, use &get_date_from_form().  To retrieve values from it, use &get_date_from_form.
   
 Inputs  Inputs
   
Line 636  sub build_url { Line 681  sub build_url {
   
 =pod  =pod
   
 =item &get_date_from_form  =item &get_date_from_form()
   
 get_date_from_form retrieves the date specified in an &date_setter form.  get_date_from_form retrieves the date specified in an &date_setter form.
   
Line 748  parameter setting wizard. Line 793  parameter setting wizard.
 sub pjump_javascript_definition {  sub pjump_javascript_definition {
     my $Str = <<END;      my $Str = <<END;
     function pjump(type,dis,value,marker,ret,call,hour,min,sec) {      function pjump(type,dis,value,marker,ret,call,hour,min,sec) {
         parmwin=window.open("/adm/rat/parameter.html?type="+escape(type)          openMyModal("/adm/rat/parameter.html?type="+escape(type)
                  +"&value="+escape(value)+"&marker="+escape(marker)                   +"&value="+escape(value)+"&marker="+escape(marker)
                  +"&return="+escape(ret)                   +"&return="+escape(ret)
                  +"&call="+escape(call)+"&name="+escape(dis)                   +"&call="+escape(call)+"&name="+escape(dis)
                  +"&defhour="+escape(hour)+"&defmin="+escape(min)                   +"&defhour="+escape(hour)+"&defmin="+escape(min)
                  +"&defsec="+escape(sec),"LONCAPAparms",                   +"&defsec="+escape(sec)+"&modal=1",350,350,'no');
                  "height=350,width=350,scrollbars=no,menubar=no");  
     }      }
 END  END
     return $Str;      return $Str;
Line 896  of items completed and an estimate of th Line 940  of items completed and an estimate of th
 =over 4  =over 4
   
   
 =item &Create_PrgWin  =item &Create_PrgWin()
   
 Writes javascript to the client to open a progress window and returns a  Writes javascript to the client to open a progress window and returns a
 data structure used for bookkeeping.  data structure used for bookkeeping.
Line 907  Inputs Line 951  Inputs
   
 =item $r Apache request  =item $r Apache request
   
 =item $title The title of the progress window  
   
 =item $heading A description (usually 1 line) of the process being initiated.  
   
 =item $number_to_do The total number of items being processed.  =item $number_to_do The total number of items being processed.
   
 =item $type Either 'popup' or 'inline' (popup is assumed if nothing is  
        specified)  
   
 =item $width Specify the width in charaters of the input field.  
   
 =item $formname Only useful in the inline case, if a form already exists, this needs to be used and specfiy the name of the form, otherwise the Progress line will be created in a new form of it's own  
   
 =item $inputname Only useful in the inline case, if a form and an input of type text exists, use this to specify the name of the input field   
   
 =back  =back
   
 Returns a hash containing the progress state data structure.  Returns a hash containing the progress state data structure.
   
   
 =item &Update_PrgWin  =item &Update_PrgWin()
   
 Updates the text in the progress indicator.  Does not increment the count.  Updates the text in the progress indicator.  Does not increment the count.
 See &Increment_PrgWin.  See &Increment_PrgWin.
Line 947  Inputs: Line 978  Inputs:
 Returns: none  Returns: none
   
   
 =item Increment_PrgWin  =item Increment_PrgWin()
   
 Increment the count of items completed for the progress window by $step or 1 if no step is provided.  Increment the count of items completed for the progress window by $step or 1 if no step is provided.
   
Line 969  Inputs: Line 1000  Inputs:
 Returns: none  Returns: none
   
   
 =item Close_PrgWin  =item &Close_PrgWin()
   
 Closes the progress window.  Closes the progress window.
   
Line 992  Returns: none Line 1023  Returns: none
 ########################################################  ########################################################
 ########################################################  ########################################################
   
 my $uniq=0;  
 sub get_uniq_name {  
     $uniq++;  
     return 'uniquename'.$uniq;  
 }  
   
 # Create progress  # Create progress
 sub Create_PrgWin {  sub Create_PrgWin {
     my ($r, $title, $heading, $number_to_do,$type,$width,$formname,      my ($r,$number_to_do)=@_;
  $inputname)=@_;  
     if (!defined($type)) { $type='popup'; }  
     if (!defined($width)) { $width=55; }  
     my %prog_state;      my %prog_state;
     $prog_state{'type'}=$type;  
     if ($type eq 'popup') {  
  $prog_state{'window'}='popwin';  
  my $start_page =  
     &Apache::loncommon::start_page($title,undef,  
    {'only_body' => 1,  
     'bgcolor'   => '#88DDFF',  
     'js_ready'  => 1});  
  my $end_page = &Apache::loncommon::end_page({'js_ready'  => 1});  
   
  #the whole function called through timeout is due to issues  
  #in mozilla Read BUG #2665 if you want to know the whole story  
  &r_print($r,&Apache::lonhtmlcommon::scripttag(  
         "var popwin;  
          function openpopwin () {  
          popwin=open(\'\',\'popwin\',\'width=400,height=100\');".  
         "popwin.document.writeln(\'".$start_page.  
               "<h4>".&mt("$heading")."<\/h4>".  
               "<form action=\"\" name=\"popremain\" method=\"post\">".  
               '<input type="text" size="'.$width.'" name="remaining" value="'.  
       &mt('Starting').'" /><\\/form>'.$end_page.  
               "\');".  
         "popwin.document.close();}".  
         "\nwindow.setTimeout(openpopwin,0)"  
     ));  
  $prog_state{'formname'}='popremain';  
  $prog_state{'inputname'}="remaining";  
     } elsif ($type eq 'inline') {  
  $prog_state{'window'}='window';  
  if (!$formname) {  
     $prog_state{'formname'}=&get_uniq_name();  
     &r_print($r,'<form action="" name="'.$prog_state{'formname'}.'">');  
  } else {  
     $prog_state{'formname'}=$formname;  
  }  
  if (!$inputname) {  
     $prog_state{'inputname'}=&get_uniq_name();  
     &r_print($r,&mt("$heading [_1]",' <input type="text" name="'.$prog_state{'inputname'}.'" size="'.$width.'" />'));  
  } else {  
     $prog_state{'inputname'}=$inputname;  
       
  }  
  if (!$formname) { &r_print($r,'</form>'); }  
  &Update_PrgWin($r,\%prog_state,&mt('Starting'));  
     }  
   
     $prog_state{'done'}=0;      $prog_state{'done'}=0;
     $prog_state{'firststart'}=&Time::HiRes::time();      $prog_state{'firststart'}=&Time::HiRes::time();
     $prog_state{'laststart'}=&Time::HiRes::time();      $prog_state{'laststart'}=&Time::HiRes::time();
     $prog_state{'max'}=$number_to_do;      $prog_state{'max'}=$number_to_do;
           &Apache::loncommon::LCprogressbar($r); 
     return %prog_state;      return %prog_state;
 }  }
   
 # update progress  # update progress
 sub Update_PrgWin {  sub Update_PrgWin {
     my ($r,$prog_state,$displayString)=@_;      my ($r,$prog_state,$displayString)=@_;
     &r_print($r,&Apache::lonhtmlcommon::scripttag(      &Apache::loncommon::LCprogressbarUpdate($r,undef,$displayString);
         $$prog_state{'window'}.'.document.'.  
         $$prog_state{'formname'}.'.'.  
         $$prog_state{'inputname'}.'.value="'.  
         $displayString.'";'  
     ));  
     $$prog_state{'laststart'}=&Time::HiRes::time();      $$prog_state{'laststart'}=&Time::HiRes::time();
 }  }
   
Line 1113  sub Increment_PrgWin { Line 1085  sub Increment_PrgWin {
             $min,              $min,
             $sec,              $sec,
             $lasttime);              $lasttime);
       my $percent=0;
     &r_print($r,&Apache::lonhtmlcommon::scripttag(      if ($$prog_state{'max'}) {
         $$prog_state{'window'}.'.document.'.         $percent=int(100.*$current/$$prog_state{'max'});
         $$prog_state{'formname'}.'.'.      }
         $$prog_state{'inputname'}.'.value="'.$timeinfo.'";'      &Apache::loncommon::LCprogressbarUpdate($r,$percent,$timeinfo);
     ));  
     $$prog_state{'laststart'}=&Time::HiRes::time();      $$prog_state{'laststart'}=&Time::HiRes::time();
 }  }
   
 # close Progress Line  # close Progress Line
 sub Close_PrgWin {  sub Close_PrgWin {
     my ($r,$prog_state)=@_;      my ($r,$prog_state)=@_;
     if ($$prog_state{'type'} eq 'popup') {      &Apache::loncommon::LCprogressbarClose($r);
         &r_print($r,&Apache::lonhtmlcommon::scripttag(  
             'popwin.close()'  
         ));  
     } elsif ($$prog_state{'type'} eq 'inline') {  
  &Update_PrgWin($r,$prog_state,&mt('Done'));  
     }  
     undef(%$prog_state);      undef(%$prog_state);
 }  }
   
 sub r_print {  
     my ($r,$to_print)=@_;  
     if ($r) {  
  $r->print($to_print);  
  $r->rflush();  
     } else {  
  print($to_print);  
     }  
 }  
   
 # ------------------------------------------------------- Puts directory header  # ------------------------------------------------------- Puts directory header
   
 sub crumbs {  sub crumbs {
     my ($uri,$target,$prefix,$form,$skiplast)=@_;      my ($uri,$target,$prefix,$form,$skiplast)=@_;
   # You cannot crumbnify uploaded or adm resources
       if ($uri=~/^\/*(uploaded|adm)\//) { return &mt('(Internal Course/Group Content)'); }
     if ($target) {      if ($target) {
         $target = ' target="'.          $target = ' target="'.
                   &Apache::loncommon::escape_single($target).'"';                    &Apache::loncommon::escape_single($target).'"';
Line 1186  sub crumbs { Line 1143  sub crumbs {
     if ($uri !~ m|/$|) { $output=~s|/$||; }      if ($uri !~ m|/$|) { $output=~s|/$||; }
     $output.='</span>';      $output.='</span>';
   
   
     return $output;      return $output;
 }  }
   
Line 1247  ENDEDITOR Line 1205  ENDEDITOR
 <script type="text/javascript" src="/adm/jQuery/js/jquery-1.6.2.min.js"></script>  <script type="text/javascript" src="/adm/jQuery/js/jquery-1.6.2.min.js"></script>
 <script type="text/javascript" src="/adm/jQuery/js/jquery-ui-1.8.16.custom.min.js"></script>  <script type="text/javascript" src="/adm/jQuery/js/jquery-ui-1.8.16.custom.min.js"></script>
 <link rel="stylesheet" type="text/css" href="/adm/jQuery/css/smoothness/jquery-ui-1.8.16.custom.css" />  <link rel="stylesheet" type="text/css" href="/adm/jQuery/css/smoothness/jquery-ui-1.8.16.custom.css" />
   <script type="text/javascript" src="/adm/jpicker/js/jpicker-1.1.6.min.js" >
   </script>
   <link rel="stylesheet" type="text/css" href="/adm/jpicker/css/jPicker-1.1.6.min.css" />
   <script type="text/javascript" src="/adm/countdown/js/jquery.countdown.js"></script>
   <link rel="stylesheet" type="text/css" href="/adm/countdown/css/jquery.countdown.css" />
 ENDJQUERY  ENDJQUERY
  return $s;   return $s;
 }  }
Line 1375  sub htmlareaselectactive { Line 1338  sub htmlareaselectactive {
  $(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);
  });   });
                   $.fn.jPicker.defaults.images.clientPath="/adm/jpicker/images/";
                   $(".colorchooser").jPicker();
   
   
  });   });
 ';  ';
       # Code to put a due date countdown in 'duedatecountdown' span.
       # This is currently located in the breadcrumb headers.
       # note that the dueDateLayout is internatinoalized below.
       # Here document is used to support the substitution into the javascript below.
       # ..which unforunately necessitates escaping the $'s in the javascript.
       # There are several times of importance
       #
       # serverDueDate -  The absolute time at which the problem expires.
       # serverTime    -  The server's time when the problem finished computing.
       # clientTime    -  The client's time...as close to serverTime as possible.
       #                  The clientTime will be slightly later due to
       #                  1. The latency between problem computation and 
       #                     the first network action.
       #                  2. The time required between the page load-start and the actual
       #                     initial javascript execution that got clientTime.
       # These are used as follows:
       #   The difference between clientTime and serverTime are used to 
       #   correct for differences in clock settings between the browser's system and the
       #   server's.
       #
       #   The difference between clientTime and the time at which the ready() method
       #   starts executing is used to estimate latencies for page load and submission.
       #   Since this is an estimate, it is doubled.  The latency estimate + one minute
       #   is used to determine when the countdown timer turns red to warn the user
       #   to think about submitting.
   
       my $dueDateLayout = &mt('Due in: {dn} {dl} {hnn}{sep}{mnn}{sep}{snn} [_1]',"<span id='submitearly'></span>");
       my $early = '- <b>'.&mt('Submit Early').'</b>';
       my $pastdue = '- <b>'.&mt('Past Due').'</b>';
       $output .= <<JAVASCRIPT;
   
       var documentReadyTime;
   
   \$(document).ready(function() {
      if (typeof(dueDate) != "undefined") {
          documentReadyTime = (new Date()).getTime();
         \$("#duedatecountdown").countdown({until: dueDate, compact: true, 
            layout: "$dueDateLayout",
            onTick: function (periods) {
       var latencyEstimate = (documentReadyTime - clientTime) * 2;
               if(\$.countdown.periodsToSeconds(periods) < (300 + latencyEstimate)) {
                  \$("#submitearly").html("$early");
                  if (\$.countdown.periodsToSeconds(periods) < 1) {
                       \$("#submitearly").html("$pastdue");
                  }
               }
               if(\$.countdown.periodsToSeconds(periods) < (60 + latencyEstimate)) {
                  \$(this).css("color", "red");   //Highlight last minute.
               }
            }
         });
      }
   });
   JAVASCRIPT
     if ($dragmath_prefix ne '') {      if ($dragmath_prefix ne '') {
         $output .= '          $output .= '
   
Line 1452  sub show_return_link { Line 1473  sub show_return_link {
 }  }
   
   
   ##
   #   Set the dueDate variable...note this is done in the timezone
   #   of the browser.
   #
   # @param epoch relative time at which the problem is due.
   #
   # @return the javascript fragment to set the date:
   #
   sub set_due_date {
       my $dueStamp = shift;
       my $duems    = $dueStamp * 1000; # Javascript Date object needs ms not seconds.
   
       my $now = time()*1000;
   
       # This slightly obscure bit of javascript sets the dueDate variable
       # to the time in the browser at which the problem was due.  
       # The code should correct for gross differences between the server
       # and client's time setting
   
       my $js = "
   <script type='text/javascript'>
     //<![CDATA[
   var serverDueDate = $duems;
   var serverTime    = $now;
   var clientTime    = (new Date()).getTime();
   var dueDate       = new Date(serverDueDate + (clientTime - serverTime));
   
     //]]>
   </script>
   ";
   
       return $js;
   }
   ##
   # Sets the time at which the problem finished computing.
   # This just updates the serverTime and clientTime variables above.
   # Calling this in e.g. end_problem provides a better estimate of the
   # difference beetween the server and client time setting as 
   # the difference contains less of the latency/problem compute time.
   #
   sub set_compute_end_time {
   
       my $now = time()*1000; # Javascript times are in ms.
       my $js = "
   <script type='text/javascript'>
   //<![CDATA[
   serverTime = $now;
   clientTime = (new Date()).getTime();
   //]]>
   </script>
   
   ";
       return $js;
       
   }
   
 ############################################################  ############################################################
 ############################################################  ############################################################
   
 =pod  =pod
   
 =item breadcrumbs  =item &breadcrumbs()
   
 Compiles the previously registered breadcrumbs into an series of links.  Compiles the previously registered breadcrumbs into an series of links.
 Additionally supports a 'component', which will be displayed on the  Additionally supports a 'component', which will be displayed on the
Line 1475  Inputs: $component (the text on the righ Line 1552  Inputs: $component (the text on the righ
            when including the text on the right.             when including the text on the right.
 Returns a string containing breadcrumbs for the current page.  Returns a string containing breadcrumbs for the current page.
   
 =item clear_breadcrumbs  =item &clear_breadcrumbs()
   
 Clears the previously stored breadcrumbs.  Clears the previously stored breadcrumbs.
   
 =item add_breadcrumb  =item &add_breadcrumb()
   
 Pushes a breadcrumb on the stack of crumbs.  Pushes a breadcrumb on the stack of crumbs.
   
Line 1499  returns: nothing Line 1576  returns: nothing
     my %tools = ();      my %tools = ();
           
     sub breadcrumbs {      sub breadcrumbs {
         my ($component,$component_help,$menulink,$helplink,$css_class,$no_mt, $CourseBreadcrumbs) = @_;          my ($component,$component_help,$menulink,$helplink,$css_class,$no_mt, 
               $CourseBreadcrumbs) = @_;
         #          #
         $css_class ||= 'LC_breadcrumbs';          $css_class ||= 'LC_breadcrumbs';
   
Line 1539  returns: nothing Line 1617  returns: nothing
         }          }
         my $links;          my $links;
         if ((&show_return_link) && (!$CourseBreadcrumbs)) {          if ((&show_return_link) && (!$CourseBreadcrumbs)) {
            $links=&htmltag( 'a',"<img src='/res/adm/pages/reload.png' border='0' style='vertical-align:middle;' />",              my $alttext = &mt('Go Back');
               $links=&htmltag( 'a',"<img src='/res/adm/pages/reload.png' border='0' style='vertical-align:middle;' alt='$alttext' />",
                             { href => '/adm/flip?postdata=return:',                              { href => '/adm/flip?postdata=return:',
                               title => &mt("Back to most recent content resource") });                                title => &mt("Back to most recent content resource") });
               $links=&htmltag('li',$links);
         }          }
         $links.= join "",           $links.= join "", 
              map {               map {
Line 1568  returns: nothing Line 1648  returns: nothing
   
         # last breadcrumb is the first order heading of a page          # last breadcrumb is the first order heading of a page
         # for course breadcrumbs it's just bold          # for course breadcrumbs it's just bold
   
         $links .= &htmltag( 'li', htmltag($CourseBreadcrumbs ? 'b' : 'h1',          $links .= &htmltag( 'li', htmltag($CourseBreadcrumbs ? 'b' : 'h1',
                 $lasttext), {title => $lasttext});                  $lasttext), {title => $lasttext});
   
Line 1588  returns: nothing Line 1669  returns: nothing
                                                          $faq,$bug);                                                           $faq,$bug);
         }          }
         #          #
   
   
   
         unless ($CourseBreadcrumbs) {          unless ($CourseBreadcrumbs) {
Line 1596  returns: nothing Line 1678  returns: nothing
             $links = &htmltag('ul',  $links, { class => "LC_CourseBreadcrumbs" });              $links = &htmltag('ul',  $links, { class => "LC_CourseBreadcrumbs" });
         }          }
   
   
         if ($component) {          if ($component) {
             $links = &htmltag('span',               $links = &htmltag('span', 
                              ( $no_mt ? $component : mt($component) ).                               ( $no_mt ? $component : mt($component) ).
                              ( $icons ? $icons : '' ),                               ( $icons ? $icons : '' ),
                              { class => 'LC_breadcrumbs_component' } )                               { class => 'LC_breadcrumbs_component' } )
                              .$links;                               .$links 
   ;
         }          }
                   
         &render_tools(\$links);          &render_tools(\$links);
Line 1612  returns: nothing Line 1696  returns: nothing
         # Return the @Crumbs stack to what we started with          # Return the @Crumbs stack to what we started with
         push(@Crumbs,$last);          push(@Crumbs,$last);
         shift(@Crumbs);          shift(@Crumbs);
   
   
         # Return the breadcrumb's line          # Return the breadcrumb's line
   
       
   
         return "$links";          return "$links";
     }      }
   
Line 1625  returns: nothing Line 1714  returns: nothing
         push(@Crumbs,@_);          push(@Crumbs,@_);
     }      }
           
 =item add_breadcrumb_tool($category, $html)  =item &add_breadcrumb_tool($category, $html)
   
 Adds $html to $category of the breadcrumb toolbar container.  Adds $html to $category of the breadcrumb toolbar container.
   
Line 1640  Currently there are 3 possible values fo Line 1729  Currently there are 3 possible values fo
 left of breadcrumbs line  left of breadcrumbs line
   
 =item tools   =item tools 
 right of breadcrumbs line  remaining items in right of breadcrumbs line
   
 =item advtools   =item advtools 
 advanced tools shown in a separate box below breadcrumbs line   advanced tools shown in a separate box below breadcrumbs line 
Line 1668  returns: nothing Line 1757  returns: nothing
         push @{$tools{$category}}, @html;          push @{$tools{$category}}, @html;
     }      }
   
 =item clear_breadcrumb_tools()  =item &clear_breadcrumb_tools()
   
 Clears the breadcrumb toolbar container.  Clears the breadcrumb toolbar container.
   
Line 1680  returns: nothing Line 1769  returns: nothing
         undef(%tools);          undef(%tools);
     }      }
   
 =item render_tools(\$breadcrumbs)  =item &render_tools(\$breadcrumbs)
   
 Creates html for breadcrumb tools (categories navigation and tools) and inserts   Creates html for breadcrumb tools (categories navigation and tools) and inserts 
 \$breadcrumbs at the correct position.  \$breadcrumbs at the correct position.
Line 1689  input: \$breadcrumbs - a reference to th Line 1778  input: \$breadcrumbs - a reference to th
 breadcrumbs.  breadcrumbs.
   
 returns: nothing  returns: nothing
   
 =cut  =cut
   
 #TODO might split this in separate functions for each category  #TODO might split this in separate functions for each category
Line 1704  returns: nothing Line 1794  returns: nothing
                    { listattr => { class=>'LC_breadcrumb_tools_outerlist' } });                     { listattr => { class=>'LC_breadcrumb_tools_outerlist' } });
     }      }
   
 =item render_advtools(\$breadcrumbs)  =pod
   
   =item &render_advtools(\$breadcrumbs)
   
 Creates html for advanced tools (category advtools) and inserts \$breadcrumbs   Creates html for advanced tools (category advtools) and inserts \$breadcrumbs 
 at the correct position.  at the correct position.
Line 1713  input: \$breadcrumbs - a reference to th Line 1805  input: \$breadcrumbs - a reference to th
 breadcrumbs (after render_tools call).  breadcrumbs (after render_tools call).
   
 returns: nothing  returns: nothing
   
 =cut  =cut
   
     sub render_advtools {      sub render_advtools {
Line 1786  returns: nothing Line 1879  returns: nothing
 my @row_count;  my @row_count;
   
 sub start_pick_box {  sub start_pick_box {
     my ($css_class) = @_;      my ($css_class,$id) = @_;
     if (defined($css_class)) {      if (defined($css_class)) {
  $css_class = 'class="'.$css_class.'"';   $css_class = 'class="'.$css_class.'"';
     } else {      } else {
  $css_class= 'class="LC_pick_box"';   $css_class= 'class="LC_pick_box"';
     }      }
       my $table_id;
       if (defined($id)) {
           $table_id = ' id="'.$id.'"';
       }
     unshift(@row_count,0);      unshift(@row_count,0);
     my $output = <<"END";      my $output = <<"END";
  <table $css_class>   <table $css_class $table_id>
 END  END
     return $output;      return $output;
 }  }
Line 2078  sub course_custom_roles { Line 2175  sub course_custom_roles {
   
   
 sub resource_info_box {  sub resource_info_box {
    my ($symb,$onlyfolderflag)=@_;     my ($symb,$onlyfolderflag,$stuvcurrent,$stuvdisp)=@_;
    my $return='';     my $return='';
      if ($stuvcurrent ne '') {
          $return = '<div class="LC_left_float">';
      }
    if ($symb) {     if ($symb) {
        $return=&Apache::loncommon::start_data_table();         $return.=&Apache::loncommon::start_data_table();
        my ($map,$id,$resource)=&Apache::lonnet::decode_symb($symb);         my ($map,$id,$resource)=&Apache::lonnet::decode_symb($symb);
        my $folder=&Apache::lonnet::gettitle($map);         my $folder=&Apache::lonnet::gettitle($map);
        $return.=&Apache::loncommon::start_data_table_row().         $return.=&Apache::loncommon::start_data_table_row().
                     '<th>'.&mt('Folder:').'</th><td>'.$folder.'</td>'.                      '<th align="left">'.&mt('Folder:').'</th><td>'.$folder.'</td>'.
                     &Apache::loncommon::end_data_table_row();                      &Apache::loncommon::end_data_table_row();
        unless ($onlyfolderflag) {         unless ($onlyfolderflag) {
           $return.=&Apache::loncommon::start_data_table_row().            $return.=&Apache::loncommon::start_data_table_row().
                     '<th>'.&mt('Resource:').'</th><td>'.&Apache::lonnet::gettitle($symb).'</td>'.                      '<th align="left">'.&mt('Resource:').'</th><td>'.&Apache::lonnet::gettitle($symb).'</td>'.
                       &Apache::loncommon::end_data_table_row();
          }
          if ($stuvcurrent ne '') {
              $return .= &Apache::loncommon::start_data_table_row().
                       '<th align="left">'.&mt("Student's current version:").'</th><td>'.$stuvcurrent.'</td>'.
                       &Apache::loncommon::end_data_table_row();
          }
          if ($stuvdisp ne '') {
              $return .= &Apache::loncommon::start_data_table_row().
                       '<th align="left">'.&mt("Student's version displayed:").'</th><td>'.$stuvdisp.'</td>'.
                     &Apache::loncommon::end_data_table_row();                      &Apache::loncommon::end_data_table_row();
        }         }
        $return.=&Apache::loncommon::end_data_table();         $return.=&Apache::loncommon::end_data_table();
     } else {      } else {
        $return='<p><span class="LC_error">'.&mt('No context provided.').'</span></p>';         $return='<p><span class="LC_error">'.&mt('No context provided.').'</span></p>';
     }      }
       if ($stuvcurrent ne '') {
           $return .= '</div>';
       }
     return $return;      return $return;
   
 }  }
   
 ##############################################  ##############################################
Line 2111  sub resource_info_box { Line 2223  sub resource_info_box {
 # 1. number to display.  # 1. number to display.
 #    If input for number is empty only the title will be displayed.   #    If input for number is empty only the title will be displayed. 
 # 2. title text to display.  # 2. title text to display.
   # 3. optional id for the <div>
 # Outputs - a scalar containing html mark-up for the div.  # Outputs - a scalar containing html mark-up for the div.
   
 sub topic_bar {  sub topic_bar {
     my ($num,$title) = @_;      my ($num,$title,$id) = @_;
     my $number = '';      my $number = '';
     if ($num ne '') {      if ($num ne '') {
         $number = '<span>'.$num.'</span>';          $number = '<span>'.$num.'</span>';
     }      }
     return '<div class="LC_topic_bar">'.$number.$title.'</div>';      if ($id ne '') {
           $id = 'id="'.$id.'"';
       }
       return '<div class="LC_topic_bar" '.$id.'>'.$number.$title.'</div>';
 }  }
   
 ##############################################  ##############################################
Line 2583  ENDSCRIPT Line 2699  ENDSCRIPT
 ##############################################  ##############################################
 ##############################################  ##############################################
   
   sub resize_scrollbox_js {
       my ($context,$tabidstr) = @_;
       my (%names,$paddingwfrac,$offsetwfrac,$offsetv,$minw,$minv);
       if ($context eq 'docs') {
           %names = (
                      boxw   => 'contenteditor',
                      item   => 'contentlist',
                      header => 'uploadfileresult',
                      scroll => 'contentscroll',
                      boxh   => 'contenteditor',
                    );
           $paddingwfrac = 0.09; 
           $offsetwfrac = 0.015;
           $offsetv = 20;
           $minw = 250;
           $minv = 200;
       } elsif ($context eq 'params') {
           %names = (
                      boxw   => 'parameditor',
                      item   => 'mapmenuinner',
                      header => 'parmstep1',
                      scroll => 'mapmenuscroll',
                      boxh   => 'parmlevel',
                    );
           $paddingwfrac = 0.2;
           $offsetwfrac = 0.015;
           $offsetv = 80;
           $minw = 100;
           $minv = 100; 
       }
       my $viewport_js = &Apache::loncommon::viewport_geometry_js();
       my $output = '
   
   window.onresize=callResize;
   
   ';
       if ($context eq 'docs') {
           $output .= '
   var activeTab;
   ';
       }
       $output .=  <<"FIRST";
   
   $viewport_js
   
   function resize_scrollbox(scrollboxname,chkw,chkh) {
       var scrollboxid = 'div_'+scrollboxname;
       var scrolltableid = 'table_'+scrollboxname;
       var scrollbox;
       var scrolltable;
   
       if (document.getElementById("$names{'boxw'}") == null) {
           return;
       }
   
       if (document.getElementById(scrollboxid) == null) {
           return;
       } else {
           scrollbox = document.getElementById(scrollboxid);
       }
   
   
       if (document.getElementById(scrolltableid) == null) {
           return;
       } else {
           scrolltable = document.getElementById(scrolltableid);
       }
   
       init_geometry();
       var vph = Geometry.getViewportHeight();
       var vpw = Geometry.getViewportWidth();
   
   FIRST
       if ($context eq 'docs') {
           $output .= "
       var alltabs = ['$tabidstr'];
   ";
       } elsif ($context eq 'params') {
           $output .= "
       if (document.getElementById('$names{'boxh'}') == null) {
           return;
       }
   ";
       }
       $output .= <<"SECOND";
       var listwchange;
       if (chkw == 1) {
           var boxw = document.getElementById("$names{'boxw'}").offsetWidth;
           var itemw;
           var itemid = document.getElementById("$names{'item'}");
           if (itemid != null) {
               itemw = itemid.offsetWidth;
           }
           var itemwstart = itemw;
   
           var scrollboxw = scrollbox.offsetWidth;
           var scrollboxscrollw = scrollbox.scrollWidth;
   
           var offsetw = parseInt(vpw * $offsetwfrac);
           var paddingw = parseInt(vpw * $paddingwfrac);
   
           var minscrollboxw = $minw;
           var maxcolw = 0;
   SECOND
       if ($context eq 'docs') {
           $output .= <<"DOCSONE";
           var actabw = 0;
           for (var i=0; i<alltabs.length; i++) {
               if (activeTab == alltabs[i]) {
                   actabw = document.getElementById(alltabs[i]).offsetWidth;
                   if (actabw > maxcolw) {
                       maxcolw = actabw;
                   }
               } else {
                   if (document.getElementById(alltabs[i]) != null) {
                       var thistab = document.getElementById(alltabs[i]);
                       thistab.style.visibility = 'hidden';
                       thistab.style.display = 'block';
                       var tabw = document.getElementById(alltabs[i]).offsetWidth;
                       thistab.style.display = 'none';
                       thistab.style.visibility = '';
                       if (tabw > maxcolw) {
                           maxcolw = tabw;
                       }
                   }
               }
           }
   DOCSONE
       } elsif ($context eq 'params') {
           $output .= <<"PARAMSONE";
           var parmlevelrows = new Array();
           var mapmenucells = new Array();
           parmlevelrows = document.getElementById("$names{'boxh'}").rows;
           var numrows = parmlevelrows.length;
           if (numrows > 1) {
               mapmenucells = parmlevelrows[2].getElementsByTagName('td');
           }
           maxcolw = mapmenucells[0].offsetWidth;
   PARAMSONE
       }
       $output .= <<"THIRD";
           if (maxcolw > 0) {
               var newscrollboxw;
               if (maxcolw+paddingw+scrollboxscrollw<boxw) {
                   newscrollboxw = boxw-paddingw-maxcolw;
                   if (newscrollboxw < minscrollboxw) {
                       newscrollboxw = minscrollboxw;
                   }
                   scrollbox.style.width = newscrollboxw+"px";
                   if (newscrollboxw != scrollboxw) {
                       var newitemw = newscrollboxw-offsetw;
                       itemid.style.width = newitemw+"px";
                   }
               } else {
                   newscrollboxw = boxw-paddingw-maxcolw;
                   if (newscrollboxw < minscrollboxw) {
                       newscrollboxw = minscrollboxw;
                   }
                   scrollbox.style.width = newscrollboxw+"px";
                   if (newscrollboxw != scrollboxw) {
                       var newitemw = newscrollboxw-offsetw;
                       itemid.style.width = newitemw+"px";
                   }
               }
   
               if (newscrollboxw != scrollboxw) {
                   var newscrolltablew = newscrollboxw+offsetw;
                   scrolltable.style.width = newscrolltablew+"px";
               }
           }
   
           if (itemid.offsetWidth != itemwstart) {
               listwchange = 1;
           }
   THIRD
       if ($context eq 'docs') {
           $output .= <<"DOCSTWO";
           if (activeTab == 'cc1') {
               if (document.getElementById('cc_hrule') != null) {
                   document.getElementById('cc_hrule').style.width=actabw+"px";
               }
           } else {
               if (activeTab == 'bb1') {
                   if (document.getElementById('bb_hrule') != null) {
                       document.getElementById('bb_hrule').style.width=actabw+"px";
                   }
               } else {
                   if (activeTab == 'ee2') {
                       if (document.getElementById('ee_hrule') != null) {
                           document.getElementById('ee_hrule').style.width=actabw+"px";
                       }
                   }
               }
           }
   DOCSTWO
       }
       $output .= <<"FOURTH";
       }
       if ((chkh == 1) || (listwchange)) {
           var primaryheight = document.getElementById('LC_nav_bar').offsetHeight;
           var secondaryheight = document.getElementById('LC_secondary_menu').offsetHeight;
           var crumbsheight = document.getElementById('LC_breadcrumbs').offsetHeight;
           var dccidheight = 0;
           if (document.getElementById('dccid') != null) {
               dccidheight = document.getElementById('dccid').offsetHeight;
           }
           var headerheight = 0;
           if (document.getElementById("$names{'header'}") != null) {
               headerheight = document.getElementById("$names{'header'}").offsetHeight;
           }
           var tabbedheight = document.getElementById("tabbededitor").offsetHeight;
           var boxheight = document.getElementById("$names{'boxh'}").offsetHeight;
           var freevspace = vph-(primaryheight+secondaryheight+crumbsheight+dccidheight+headerheight+tabbedheight+boxheight);
   
           var scrollboxheight = scrollbox.offsetHeight;
           var scrollboxscrollheight = scrollbox.scrollHeight;
   
           var minvscrollbox = $minv;
           var offsetv = $offsetv;
           var newscrollboxheight;
           if (freevspace < 0) {
               newscrollboxheight = scrollboxheight+freevspace-offsetv;
               if (newscrollboxheight < minvscrollbox) {
                   newscrollboxheight = minvscrollbox;
               }
               scrollbox.style.height = newscrollboxheight + "px";
           } else {
               if (scrollboxscrollheight > scrollboxheight) {
                   if (freevspace > offsetv) {
                       newscrollboxheight = scrollboxheight+freevspace-offsetv;
                       if (newscrollboxheight < minvscrollbox) {
                           newscrollboxheight = minvscrollbox;
                       }
                       scrollbox.style.height = newscrollboxheight+"px";
                   }
               }
           }
           scrollboxheight = scrollbox.offsetHeight;
           var itemh = document.getElementById("$names{'item'}").offsetHeight;
   
           if (scrollboxscrollheight <= scrollboxheight) {
               if ((itemh+offsetv)<scrollboxheight) {
                   newscrollheight = itemh+offsetv;
                   scrollbox.style.height = newscrollheight+"px";
               }
           }
       }
       return;
   }
   
   function callResize() {
       var timer;
       clearTimeout(timer);
       timer=setTimeout('resize_scrollbox("$names{'scroll'}","1","1")',500);
   }
   
   FOURTH
       return $output;
   }
   
   
   ##############################################
   ##############################################
   
 # javascript_valid_email  # javascript_valid_email
 #  #
 # Generates javascript to validate an e-mail address.  # Generates javascript to validate an e-mail address.
Line 2698  sub scripttag { Line 3078  sub scripttag {
     return htmltag('script', $content, {type => 'text/javascript'});      return htmltag('script', $content, {type => 'text/javascript'});
 };  };
   
   =pod
   
 =item list_from_array( \@array, { listattr =>{}, itemattr =>{} } )  =item &list_from_array( \@array, { listattr =>{}, itemattr =>{} } )
   
 Constructs a XHTML list from \@array.  Constructs a XHTML list from \@array.
   
Line 2790  sub generate_menu { Line 3171  sub generate_menu {
                                 $$link{alttext} : $$link{linktext})                                  $$link{alttext} : $$link{linktext})
                             }), {                              }), {
                             href  => $$link{url},                              href  => $$link{url},
                             title => mt($$link{linktitle})                              title => mt($$link{linktitle}),
                               class => 'LC_menubuttons_link'
                             }).                              }).
                         $a->(mt($$link{linktext}), {                          $a->(mt($$link{linktext}), {
                             href  => $$link{url},                              href  => $$link{url},
Line 2824  sub generate_menu { Line 3206  sub generate_menu {
   
 =pod  =pod
   
 =item &start_funclist  =item &start_funclist()
   
 Start list of available functions  Start list of available functions
   
Line 2864  sub start_funclist { Line 3246  sub start_funclist {
   
 =pod  =pod
   
 =item &add_item_funclist  =item &add_item_funclist()
   
 Adds an item to the list of available functions  Adds an item to the list of available functions
   
Line 2890  sub add_item_funclist { Line 3272  sub add_item_funclist {
   
 =pod  =pod
   
 =item &end_funclist  =item &end_funclist()
   
 End list of available functions  End list of available functions
   
Line 2911  sub end_funclist { Line 3293  sub end_funclist {
   
 =pod  =pod
   
 =item funclist_from_array( \@array, {legend => 'text for legend'} )  =item &funclist_from_array( \@array, {legend => 'text for legend'} )
   
 Constructs a XHTML list from \@array with the first item being visually  Constructs a XHTML list from \@array with the first item being visually
 highlighted and set to the value of legend or 'Functions' if legend is  highlighted and set to the value of legend or 'Functions' if legend is

Removed from v.1.294  
changed lines
  Added in v.1.314


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