");
$("#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]',"");
+ my $early = '- '.&mt('Submit Early').'';
+ my $pastdue = '- '.&mt('Past Due').'';
+ $output .= <
+ //
+
+
+END
+}
+##
+# 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.
+ return <<"END";
+
+
+
+END
+}
+
############################################################
############################################################
=pod
-=item breadcrumbs
+=item &breadcrumbs()
Compiles the previously registered breadcrumbs into an series of links.
Additionally supports a 'component', which will be displayed on the
@@ -1429,11 +1580,11 @@ Inputs: $component (the text on the righ
when including the text on the right.
Returns a string containing breadcrumbs for the current page.
-=item clear_breadcrumbs
+=item &clear_breadcrumbs()
Clears the previously stored breadcrumbs.
-=item add_breadcrumb
+=item &add_breadcrumb()
Pushes a breadcrumb on the stack of crumbs.
@@ -1453,7 +1604,8 @@ returns: nothing
my %tools = ();
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';
@@ -1491,22 +1643,32 @@ returns: nothing
$last = $menulink;
}
}
- my $links = join "",
+ my $links;
+ if ((&show_return_link) && (!$CourseBreadcrumbs)) {
+ my $alttext = &mt('Go Back');
+ $links=&htmltag( 'a','',
+ { href => '/adm/flip?postdata=return:',
+ title => &mt('Back to most recent content resource'),
+ class => 'LC_menubuttons_link',
+ });
+ $links=&htmltag('li',$links);
+ }
+ $links.= join "",
map {
$faq = $_->{'faq'} if (exists($_->{'faq'}));
$bug = $_->{'bug'} if (exists($_->{'bug'}));
$help = $_->{'help'} if (exists($_->{'help'}));
- my $result = $_->{no_mt} ? $_->{text} : mt($_->{text});
+ my $result = $_->{no_mt} ? $_->{text} : &mt($_->{text});
if ($_->{href}){
- $result = htmltag( 'a', $result,
+ $result = &htmltag( 'a', $result,
{ href => $_->{href},
- title => $_->{no_mt} ? $_->{title} : mt($_->{title}),
+ title => $_->{no_mt} ? $_->{title} : &mt($_->{title}),
target => $_->{target}, });
}
- $result = htmltag( 'li', "$result $crumbsymbol");
+ $result = &htmltag( 'li', "$result $crumbsymbol");
} @Crumbs;
#should the last Element be translated?
@@ -1516,7 +1678,8 @@ returns: nothing
# last breadcrumb is the first order heading of a page
# for course breadcrumbs it's just bold
- $links .= htmltag( 'li', htmltag($CourseBreadcrumbs ? 'b' : 'h1',
+
+ $links .= &htmltag( 'li', htmltag($CourseBreadcrumbs ? 'b' : 'h1',
$lasttext), {title => $lasttext});
my $icons = '';
@@ -1536,31 +1699,39 @@ returns: nothing
$faq,$bug);
}
#
+
unless ($CourseBreadcrumbs) {
- $links = htmltag('ol', $links, { id => "LC_MenuBreadcrumbs" });
+ $links = &htmltag('ol', $links, { id => "LC_MenuBreadcrumbs" });
} else {
- $links = htmltag('ul', $links, { class => "LC_CourseBreadcrumbs" });
+ $links = &htmltag('ul', $links, { class => "LC_CourseBreadcrumbs" });
}
+
if ($component) {
- $links = htmltag('span',
+ $links = &htmltag('span',
( $no_mt ? $component : mt($component) ).
( $icons ? $icons : '' ),
{ class => 'LC_breadcrumbs_component' } )
- .$links;
+ .$links
+;
}
- render_tools(\$links);
- $links = htmltag('div', $links,
+ &render_tools(\$links);
+ $links = &htmltag('div', $links,
{ id => "LC_breadcrumbs" }) unless ($CourseBreadcrumbs) ;
- render_advtools(\$links);
+ &render_advtools(\$links);
# Return the @Crumbs stack to what we started with
push(@Crumbs,$last);
shift(@Crumbs);
+
+
# Return the breadcrumb's line
+
+
+
return "$links";
}
@@ -1573,7 +1744,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.
@@ -1588,7 +1759,7 @@ Currently there are 3 possible values fo
left of breadcrumbs line
=item tools
-right of breadcrumbs line
+remaining items in right of breadcrumbs line
=item advtools
advanced tools shown in a separate box below breadcrumbs line
@@ -1602,7 +1773,7 @@ returns: nothing
sub add_breadcrumb_tool {
my ($category, @html) = @_;
return unless @html;
- if (!defined(%tools)) {
+ if (!keys(%tools)) {
%tools = ( navigation => [], tools => [], advtools => []);
}
@@ -1610,13 +1781,13 @@ returns: nothing
@html = grep {defined $_ && $_ ne ''} @html;
for (@html) {
s/align="(right|left)"//;
- s/// if $category ne 'advtools';
+# s/// if $category ne 'advtools';
}
push @{$tools{$category}}, @html;
}
-=item clear_breadcrumb_tools()
+=item &clear_breadcrumb_tools()
Clears the breadcrumb toolbar container.
@@ -1628,7 +1799,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.
@@ -1637,12 +1808,13 @@ input: \$breadcrumbs - a reference to th
breadcrumbs.
returns: nothing
+
=cut
#TODO might split this in separate functions for each category
sub render_tools {
my ($breadcrumbs) = @_;
- return unless defined %tools;
+ return unless (keys(%tools));
my $navigation = list_from_array($tools{navigation},
{ listattr => { class=>"LC_breadcrumb_tools_navigation" } });
@@ -1652,7 +1824,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.
@@ -1661,6 +1835,7 @@ input: \$breadcrumbs - a reference to th
breadcrumbs (after render_tools call).
returns: nothing
+
=cut
sub render_advtools {
@@ -1734,15 +1909,19 @@ returns: nothing
my @row_count;
sub start_pick_box {
- my ($css_class) = @_;
+ my ($css_class,$id) = @_;
if (defined($css_class)) {
$css_class = 'class="'.$css_class.'"';
} else {
$css_class= 'class="LC_pick_box"';
}
+ my $table_id;
+ if (defined($id)) {
+ $table_id = ' id="'.$id.'"';
+ }
unshift(@row_count,0);
my $output = <<"END";
-
+
END
return $output;
}
@@ -2026,26 +2205,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().
- '
';
+ }
return $return;
-
}
##############################################
@@ -2059,15 +2253,19 @@ sub resource_info_box {
# 1. number to display.
# If input for number is empty only the title will be displayed.
# 2. title text to display.
+# 3. optional id for the
# Outputs - a scalar containing html mark-up for the div.
sub topic_bar {
- my ($num,$title) = @_;
+ my ($num,$title,$id) = @_;
my $number = '';
if ($num ne '') {
$number = ''.$num.'';
}
- return '
'.$number.$title.'
';
+ if ($id ne '') {
+ $id = 'id="'.$id.'"';
+ }
+ return '
'.$number.$title.'
';
}
##############################################
@@ -2104,30 +2302,30 @@ sub echo_form_input {
if ($key =~ /^form\.(.+)$/) {
my $name = $1;
my $match = 0;
- if ((!@{$excluded}) || (!grep/^$name$/,@{$excluded})) {
- if (defined($regexps)) {
- if (@{$regexps} > 0) {
- foreach my $regexp (@{$regexps}) {
- if ($name =~ /\Q$regexp\E/) {
- $match = 1;
- last;
- }
+ if (ref($excluded) eq 'ARRAY') {
+ next if (grep(/^\Q$name\E$/,@{$excluded}));
+ }
+ if (ref($regexps) eq 'ARRAY') {
+ if (@{$regexps} > 0) {
+ foreach my $regexp (@{$regexps}) {
+ if ($name =~ /$regexp/) {
+ $match = 1;
+ last;
}
}
}
- if (!$match) {
- if (ref($env{$key})) {
- foreach my $value (@{$env{$key}}) {
- $value = &HTML::Entities::encode($value,'<>&"');
- $output .= ''."\n";
- }
- } else {
- my $value = &HTML::Entities::encode($env{$key},'<>&"');
- $output .= ''."\n";
- }
+ }
+ next if ($match);
+ if (ref($env{$key}) eq 'ARRAY') {
+ foreach my $value (@{$env{$key}}) {
+ $value = &HTML::Entities::encode($value,'<>&"');
+ $output .= ''."\n";
}
+ } else {
+ my $value = &HTML::Entities::encode($env{$key},'<>&"');
+ $output .= ''."\n";
}
}
}
@@ -2286,6 +2484,515 @@ sub set_form_elements {
##############################################
##############################################
+sub file_submissionchk_js {
+ my ($turninpaths,$multiples) = @_;
+ my $overwritewarn = &mt('File(s) you uploaded for your submission will overwrite existing file(s) submitted for this item').'\\n'.
+ &mt('Continue submission and overwrite the file(s)?');
+ my $delfilewarn = &mt('You have indicated you wish to remove some files previously included in your submission.').'\\n'.
+ &mt('Continue submission with these files removed?');
+ my ($turninpathtext,$multtext,$arrayindexofjs);
+ if (ref($turninpaths) eq 'HASH') {
+ foreach my $key (sort(keys(%{$turninpaths}))) {
+ $turninpathtext .= " if (prefix == '$key') {\n".
+ " return '$turninpaths->{$key}';\n".
+ " }\n";
+ }
+ }
+ $turninpathtext .= " return '';\n";
+ if (ref($multiples) eq 'HASH') {
+ foreach my $key (sort(keys(%{$multiples}))) {
+ $multtext .= " if (prefix == '$key') {\n".
+ " return '$multiples->{$key}';\n".
+ " }\n";
+ }
+ }
+ $multtext .= " return '';\n";
+
+ $arrayindexofjs = &Apache::loncommon::javascript_array_indexof();
+ return <<"ENDSCRIPT";
+
+
+$arrayindexofjs
+
+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 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 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) 'text/javascript'});
};
+=pod
-=item list_from_array( \@array, { listattr =>{}, itemattr =>{} } )
+=item &list_from_array( \@array, { listattr =>{}, itemattr =>{} } )
Constructs a XHTML list from \@array.
@@ -2428,6 +3136,7 @@ returns: XHTML list as String.
# \@items, {listattr => { class => 'abc', id => 'xyx' }, itemattr => {class => 'abc', id => 'xyx'}}
sub list_from_array {
my ($items, $args) = @_;
+ return unless (ref($items) eq 'ARRAY');
return unless scalar @$items;
my ($ul, $li) = inittags( qw(ul li) );
my $listitems = join '', map { $li->($_, $args->{itemattr}) } @$items;
@@ -2479,16 +3188,21 @@ sub generate_menu {
# create the markup for the current $link and push it into @links.
# each entry consists of an image and a text optionally followed
# by a help link.
+ my $src;
+ if ($$link{icon} ne '') {
+ $src = '/res/adm/pages/'.$$link{icon};
+ }
push(@links,$li->(
$a->(
$img->("", {
class => "LC_noBorder LC_middle",
- src => "/res/adm/pages/$$link{icon}",
+ src => $src,
alt => mt(defined($$link{alttext}) ?
$$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},
@@ -2522,7 +3236,7 @@ sub generate_menu {
=pod
-=item &start_funclist
+=item &start_funclist()
Start list of available functions
@@ -2562,7 +3276,7 @@ sub start_funclist {
=pod
-=item &add_item_funclist
+=item &add_item_funclist()
Adds an item to the list of available functions
@@ -2588,7 +3302,7 @@ sub add_item_funclist {
=pod
-=item &end_funclist
+=item &end_funclist()
End list of available functions
@@ -2609,7 +3323,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
@@ -2636,6 +3350,7 @@ returns: XHTML list as string.
sub funclist_from_array {
my ($items, $args) = @_;
+ return unless(ref($items) eq 'ARRAY');
$args->{legend} ||= mt('Functions');
return list_from_array( [$args->{legend}, @$items],
{ listattr => {class => 'LC_funclist'} });