--- loncom/interface/lonhtmlcommon.pm 2012/01/02 20:38:18 1.299 +++ loncom/interface/lonhtmlcommon.pm 2012/04/18 14:13:29 1.310 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # a pile of common html routines # -# $Id: lonhtmlcommon.pm,v 1.299 2012/01/02 20:38:18 raeburn Exp $ +# $Id: lonhtmlcommon.pm,v 1.310 2012/04/18 14:13:29 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -103,7 +103,7 @@ sub direct_parm_link { ############################################## ############################################## -=item confirm_success +=item &confirm_success() Successful completion of an operation message @@ -129,7 +129,7 @@ sub confirm_success { =pod -=item dragmath_button +=item &dragmath_button() Creates a button that launches a dragmath popup-window, in which an expression can be edited and pasted as LaTeX into a specified textarea. @@ -155,10 +155,11 @@ ENDDRAGMATH =pod -=item dragmath_js +=item &dragmath_js() Javascript used to open pop-up window containing dragmath applet which can be used to paste LaTeX into a textarea. + =cut sub dragmath_js { @@ -177,13 +178,57 @@ sub dragmath_js { 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"; + +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 +} ############################################## ############################################## =pod -=item authorbombs +=item &authorbombs() =cut @@ -317,7 +362,7 @@ sub get_recent_frozen { =pod -=item textbox +=item &textbox() =cut @@ -337,7 +382,7 @@ sub textbox { =pod -=item checkbox +=item &checkbox() =cut @@ -359,7 +404,7 @@ sub checkbox { =pod -=item radiobutton +=item &radiobutton() =cut @@ -383,10 +428,10 @@ sub radio { =pod -=item &date_setter +=item &date_setter() &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 @@ -636,7 +681,7 @@ sub build_url { =pod -=item &get_date_from_form +=item &get_date_from_form() get_date_from_form retrieves the date specified in an &date_setter form. @@ -895,7 +940,7 @@ of items completed and an estimate of th =over 4 -=item &Create_PrgWin +=item &Create_PrgWin() Writes javascript to the client to open a progress window and returns a data structure used for bookkeeping. @@ -926,7 +971,7 @@ Inputs 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. See &Increment_PrgWin. @@ -946,7 +991,7 @@ Inputs: 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. @@ -968,7 +1013,7 @@ Inputs: Returns: none -=item Close_PrgWin +=item &Close_PrgWin() Closes the progress window. @@ -1072,6 +1117,8 @@ sub Close_PrgWin { sub crumbs { 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) { $target = ' target="'. &Apache::loncommon::escape_single($target).'"'; @@ -1109,6 +1156,7 @@ sub crumbs { if ($uri !~ m|/$|) { $output=~s|/$||; } $output.=''; + return $output; } @@ -1170,6 +1218,11 @@ ENDEDITOR + + + + ENDJQUERY return $s; } @@ -1298,8 +1351,58 @@ sub htmlareaselectactive { $(this).before("
Rich formatting »
"); $("#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} - Submit early!') . ''; + $output .= < $lasttext}); + $links .= '
  • '; + my $icons = ''; $faq = $last->{'faq'} if (exists($last->{'faq'})); $bug = $last->{'bug'} if (exists($last->{'bug'})); @@ -1513,6 +1675,7 @@ returns: nothing $faq,$bug); } # + unless ($CourseBreadcrumbs) { @@ -1521,12 +1684,14 @@ returns: nothing $links = &htmltag('ul', $links, { class => "LC_CourseBreadcrumbs" }); } + if ($component) { $links = &htmltag('span', ( $no_mt ? $component : mt($component) ). ( $icons ? $icons : '' ), { class => 'LC_breadcrumbs_component' } ) - .$links; + .$links +; } &render_tools(\$links); @@ -1537,7 +1702,12 @@ returns: nothing # Return the @Crumbs stack to what we started with push(@Crumbs,$last); shift(@Crumbs); + + # Return the breadcrumb's line + + + return "$links"; } @@ -1550,7 +1720,7 @@ returns: nothing push(@Crumbs,@_); } -=item add_breadcrumb_tool($category, $html) +=item &add_breadcrumb_tool($category, $html) Adds $html to $category of the breadcrumb toolbar container. @@ -1593,7 +1763,7 @@ returns: nothing push @{$tools{$category}}, @html; } -=item clear_breadcrumb_tools() +=item &clear_breadcrumb_tools() Clears the breadcrumb toolbar container. @@ -1605,7 +1775,7 @@ returns: nothing undef(%tools); } -=item render_tools(\$breadcrumbs) +=item &render_tools(\$breadcrumbs) Creates html for breadcrumb tools (categories navigation and tools) and inserts \$breadcrumbs at the correct position. @@ -1614,6 +1784,7 @@ input: \$breadcrumbs - a reference to th breadcrumbs. returns: nothing + =cut #TODO might split this in separate functions for each category @@ -1629,7 +1800,9 @@ returns: nothing { 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 at the correct position. @@ -1638,6 +1811,7 @@ input: \$breadcrumbs - a reference to th breadcrumbs (after render_tools call). returns: nothing + =cut sub render_advtools { @@ -2003,26 +2177,41 @@ sub course_custom_roles { sub resource_info_box { - my ($symb,$onlyfolderflag)=@_; + my ($symb,$onlyfolderflag,$stuvcurrent,$stuvdisp)=@_; my $return=''; + if ($stuvcurrent ne '') { + $return = '
    '; + } if ($symb) { - $return=&Apache::loncommon::start_data_table(); + $return.=&Apache::loncommon::start_data_table(); my ($map,$id,$resource)=&Apache::lonnet::decode_symb($symb); my $folder=&Apache::lonnet::gettitle($map); $return.=&Apache::loncommon::start_data_table_row(). - ''.&mt('Folder:').''.$folder.''. + ''.&mt('Folder:').''.$folder.''. &Apache::loncommon::end_data_table_row(); unless ($onlyfolderflag) { $return.=&Apache::loncommon::start_data_table_row(). - ''.&mt('Resource:').''.&Apache::lonnet::gettitle($symb).''. + ''.&mt('Resource:').''.&Apache::lonnet::gettitle($symb).''. + &Apache::loncommon::end_data_table_row(); + } + if ($stuvcurrent ne '') { + $return .= &Apache::loncommon::start_data_table_row(). + ''.&mt("Student's current version:").''.$stuvcurrent.''. + &Apache::loncommon::end_data_table_row(); + } + if ($stuvdisp ne '') { + $return .= &Apache::loncommon::start_data_table_row(). + ''.&mt("Student's version displayed:").''.$stuvdisp.''. &Apache::loncommon::end_data_table_row(); } $return.=&Apache::loncommon::end_data_table(); } else { $return='

    '.&mt('No context provided.').'

    '; } + if ($stuvcurrent ne '') { + $return .= '
    '; + } return $return; - } ############################################## @@ -2623,8 +2812,9 @@ sub scripttag { 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. @@ -2715,7 +2905,8 @@ sub generate_menu { $$link{alttext} : $$link{linktext}) }), { href => $$link{url}, - title => mt($$link{linktitle}) + title => mt($$link{linktitle}), + class => 'LC_menubuttons_link' }). $a->(mt($$link{linktext}), { href => $$link{url}, @@ -2749,7 +2940,7 @@ sub generate_menu { =pod -=item &start_funclist +=item &start_funclist() Start list of available functions @@ -2789,7 +2980,7 @@ sub start_funclist { =pod -=item &add_item_funclist +=item &add_item_funclist() Adds an item to the list of available functions @@ -2815,7 +3006,7 @@ sub add_item_funclist { =pod -=item &end_funclist +=item &end_funclist() End list of available functions @@ -2836,7 +3027,7 @@ sub end_funclist { =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 highlighted and set to the value of legend or 'Functions' if legend is