[LON-CAPA-cvs] cvs: loncom(version_2_11_X) /interface loncommon.pm
raeburn
raeburn at source.lon-capa.org
Sun Sep 9 17:30:42 EDT 2018
raeburn Sun Sep 9 21:30:42 2018 EDT
Modified files: (Branch: version_2_11_X)
/loncom/interface loncommon.pm
Log:
- For 2.11
Backport 1.1301, 1.1302
Index: loncom/interface/loncommon.pm
diff -u loncom/interface/loncommon.pm:1.1075.2.129 loncom/interface/loncommon.pm:1.1075.2.130
--- loncom/interface/loncommon.pm:1.1075.2.129 Mon Sep 3 20:43:15 2018
+++ loncom/interface/loncommon.pm Sun Sep 9 21:30:40 2018
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# a pile of common routines
#
-# $Id: loncommon.pm,v 1.1075.2.129 2018/09/03 20:43:15 raeburn Exp $
+# $Id: loncommon.pm,v 1.1075.2.130 2018/09/09 21:30:40 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -8394,8 +8394,9 @@
}
sub LCprogressbar_script {
- my ($id)=@_;
- return(<<ENDPROGRESS);
+ my ($id,$number_to_do)=@_;
+ if ($number_to_do) {
+ return(<<ENDPROGRESS);
<script type="text/javascript">
// <![CDATA[
\$('#progressbar$id').progressbar({
@@ -8408,21 +8409,43 @@
// ]]>
</script>
ENDPROGRESS
+ } else {
+ return(<<ENDPROGRESS);
+<script type="text/javascript">
+// <![CDATA[
+\$('#progressbar$id').progressbar({
+ value: false,
+ create: function(event, ui) {
+ \$('.ui-widget-header', this).css({'background':'#F0F0F0'});
+ \$('.ui-progressbar-overlay', this).css({'margin':'0'});
+ }
+});
+// ]]>
+</script>
+ENDPROGRESS
+ }
}
sub LCprogressbarUpdate_script {
return(<<ENDPROGRESSUPDATE);
<style type="text/css">
.ui-progressbar { position:relative; }
+.progress-label {position: absolute; width: 100%; text-align: center; top: 1px; font-weight: bold; text-shadow: 1px 1px 0 #fff;margin: 0; line-height: 200%; }
.pblabel { position: absolute; width: 100%; text-align: center; line-height: 1.9em; }
</style>
<script type="text/javascript">
// <![CDATA[
var LCprogressTxt='---';
-function LCupdateProgress(percent,progresstext,id) {
+function LCupdateProgress(percent,progresstext,id,maxnum) {
LCprogressTxt=progresstext;
- \$('#progressbar'+id).progressbar('value',percent);
+ if ((maxnum == '') || (maxnum == undefined) || (maxnum == null)) {
+ \$('#progressbar'+id).find('.progress-label').text(LCprogressTxt);
+ } else if (percent === \$('#progressbar'+id).progressbar( "value" )) {
+ \$('#progressbar'+id).find('.pblabel').text(LCprogressTxt);
+ } else {
+ \$('#progressbar'+id).progressbar('value',percent);
+ }
}
// ]]>
</script>
@@ -8434,37 +8457,54 @@
my $LCcurrentid;
sub LCprogressbar {
- my ($r)=(@_);
+ my ($r,$number_to_do,$preamble)=@_;
$LClastpercent=0;
$LCidcnt++;
$LCcurrentid=$$.'_'.$LCidcnt;
- my $starting=&mt('Starting');
- my $content=(<<ENDPROGBAR);
+ my ($starting,$content);
+ if ($number_to_do) {
+ $starting=&mt('Starting');
+ $content=(<<ENDPROGBAR);
+$preamble
<div id="progressbar$LCcurrentid">
<span class="pblabel">$starting</span>
</div>
ENDPROGBAR
- &r_print($r,$content.&LCprogressbar_script($LCcurrentid));
+ } else {
+ $starting=&mt('Loading...');
+ $LClastpercent='false';
+ $content=(<<ENDPROGBAR);
+$preamble
+ <div id="progressbar$LCcurrentid">
+ <div class="progress-label">$starting</div>
+ </div>
+ENDPROGBAR
+ }
+ &r_print($r,$content.&LCprogressbar_script($LCcurrentid,$number_to_do));
}
sub LCprogressbarUpdate {
- my ($r,$val,$text)=@_;
- unless ($val) {
- if ($LClastpercent) {
- $val=$LClastpercent;
- } else {
- $val=0;
- }
+ my ($r,$val,$text,$number_to_do)=@_;
+ if ($number_to_do) {
+ unless ($val) {
+ if ($LClastpercent) {
+ $val=$LClastpercent;
+ } else {
+ $val=0;
+ }
+ }
+ if ($val<0) { $val=0; }
+ if ($val>100) { $val=0; }
+ $LClastpercent=$val;
+ unless ($text) { $text=$val.'%'; }
+ } else {
+ $val = 'false';
}
- if ($val<0) { $val=0; }
- if ($val>100) { $val=0; }
- $LClastpercent=$val;
- unless ($text) { $text=$val.'%'; }
$text=&js_ready($text);
&r_print($r,<<ENDUPDATE);
<script type="text/javascript">
// <![CDATA[
-LCupdateProgress($val,'$text','$LCcurrentid');
+LCupdateProgress($val,'$text','$LCcurrentid','$number_to_do');
// ]]>
</script>
ENDUPDATE
More information about the LON-CAPA-cvs
mailing list