--- loncom/interface/loncommon.pm 2011/12/20 22:43:34 1.1040 +++ loncom/interface/loncommon.pm 2011/12/20 23:57:51 1.1041 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # a pile of common routines # -# $Id: loncommon.pm,v 1.1040 2011/12/20 22:43:34 raeburn Exp $ +# $Id: loncommon.pm,v 1.1041 2011/12/20 23:57:51 www Exp $ # # Copyright Michigan State University Board of Trustees # @@ -6739,6 +6739,7 @@ sub headtag { $result.=&modal_window(); $result.=&togglebox_script(); $result.=&wishlist_window(); + $result.=&LCprogressbarUpdate_script(); } else { if ($args->{'add_modal'}) { $result.=&modal_window(); @@ -6749,6 +6750,9 @@ sub headtag { if ($args->{'add_togglebox'}) { $result.=&togglebox_script(); } + if ($args->{'add_progressbar'}) { + $result.=&LCprogressbarUpdate_script(); + } } if (ref($args->{'redirect'})) { my ($time,$url,$inhibit_continue) = @{$args->{'redirect'}}; @@ -7057,6 +7061,46 @@ sub modal_adhoc_script { ENDADHOC } +sub modal_adhoc_inner { + my ($funcname,$width,$height,$content)=@_; + my $innerwidth=$width-20; + $content=&js_ready( + &start_page('Dialog',undef,{'only_body'=>1,'add_progressbar'=>1,'bgcolor'=>'#FFFFFF'}). + &start_scrollbox($width.'px',$innerwidth.'px',$height.'px'). + $content. + &end_scrollbox(). + &end_page() + ); + return &modal_adhoc_script($funcname,$width,$height,$content); +} + +sub modal_adhoc_window { + my ($funcname,$width,$height,$content,$linktext)=@_; + return &modal_adhoc_inner($funcname,$width,$height,$content). + "".$linktext.""; +} + +sub modal_adhoc_launch { + my ($funcname,$width,$height,$content)=@_; + return &modal_adhoc_inner($funcname,$width,$height,$content).(< +// + +ENDLAUNCH +} + +sub modal_adhoc_close { + return (< +// + +ENDCLOSE +} + sub togglebox_script { return(< @@ -7097,18 +7141,78 @@ sub end_togglebox { return ''.&end_data_table(); } -sub modal_adhoc_window { - my ($funcname,$width,$height,$content,$linktext)=@_; - my $innerwidth=$width-20; - $content=&js_ready( - &start_page('Dialog',undef,{'only_body'=>1,'bgcolor'=>'#FFFFFF'}). - &start_scrollbox($width.'px',$innerwidth.'px',$height.'px'). - $content. - &end_scrollbox(). - &end_page() - ); - return &modal_adhoc_script($funcname,$width,$height,$content). - "".$linktext.""; +sub LCprogressbar_script { + return(< +// + +ENDPROGRESS +} + +sub LCprogressbarUpdate_script { + return(< +.ui-progressbar { position:relative; } +.pblabel { position: absolute; width: 100%; text-align: center; line-height: 1.9em; } + + +ENDPROGRESSUPDATE +} + +sub LCprogressbar { + my ($r,$mode)=(@_); + my $starting=&mt('Starting'); + my $content=(< +
+ $starting +
+

+ENDPROGBAR + $content.=&LCprogressbar_script(); + if ($mode eq 'popup') { + $r->print(&modal_adhoc_launch('LCprogwin',500,50,$content)); + } else { + $r->print($content); + } + $r->rflush(); +} + +sub LCprogressbarUpdate { + my ($r,$val,$text,$mode)=@_; + unless ($val) { $val=0; } + if ($val<0) { $val=0; } + if ($val>100) { $val=0; } + unless ($text) { $text=$val.'%'; } + my $function=''; + if ($mode eq 'popup') { $function='modalWindow.'; } + $function.='LCupdateProgress'; + $text=&js_ready($text); + $r->print(< +// + +ENDUPDATE + $r->rflush(); } sub html_encode {