[LON-CAPA-cvs] cvs: loncom /interface loncommon.pm

www www at source.lon-capa.org
Tue Dec 20 18:57:51 EST 2011


www		Tue Dec 20 23:57:51 2011 EDT

  Modified files:              
    /loncom/interface	loncommon.pm 
  Log:
  Saving my work: Bug #6455
  
  
Index: loncom/interface/loncommon.pm
diff -u loncom/interface/loncommon.pm:1.1040 loncom/interface/loncommon.pm:1.1041
--- loncom/interface/loncommon.pm:1.1040	Tue Dec 20 22:43:34 2011
+++ loncom/interface/loncommon.pm	Tue Dec 20 23:57:51 2011
@@ -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 @@
         $result.=&modal_window();
         $result.=&togglebox_script();
         $result.=&wishlist_window();
+        $result.=&LCprogressbarUpdate_script();
     } else {
         if ($args->{'add_modal'}) {
            $result.=&modal_window();
@@ -6749,6 +6750,9 @@
         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 @@
 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).
+           "<a href=\"javascript:$funcname();void(0);\">".$linktext."</a>";
+}
+
+sub modal_adhoc_launch {
+    my ($funcname,$width,$height,$content)=@_;
+    return &modal_adhoc_inner($funcname,$width,$height,$content).(<<ENDLAUNCH);
+<script type="text/javascript">
+// <![CDATA[
+$funcname();
+// ]]>
+</script>
+ENDLAUNCH
+}
+
+sub modal_adhoc_close {
+    return (<<ENDCLOSE);
+<script type="text/javascript">
+// <![CDATA[
+modalWindow.close();
+// ]]>
+</script>
+ENDCLOSE
+}
+
 sub togglebox_script {
    return(<<ENDTOGGLE);
 <script type="text/javascript"> 
@@ -7097,18 +7141,78 @@
     return '</td></tr>'.&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).
-         "<a href=\"javascript:$funcname();void(0);\">".$linktext."</a>";
+sub LCprogressbar_script {
+   return(<<ENDPROGRESS);
+<script type="text/javascript">
+// <![CDATA[
+var LCprogressTxt='---';
+
+\$('#progressbar').progressbar({
+  value: 0,
+  change: function(event, ui) {
+    var newVal = \$(this).progressbar('option', 'value');
+    \$('.pblabel', this).text(LCprogressTxt);
+  }
+});
+// ]]>
+</script>
+ENDPROGRESS
+}
+
+sub LCprogressbarUpdate_script {
+   return(<<ENDPROGRESSUPDATE);
+<style type="text/css">
+.ui-progressbar { position:relative; }
+.pblabel { position: absolute; width: 100%; text-align: center; line-height: 1.9em; }
+</style>
+<script type="text/javascript">
+// <![CDATA[
+function LCupdateProgress(percent,progresstext) {
+   LCprogressTxt=progresstext;
+   \$('#progressbar').progressbar('value',percent);
+}
+// ]]>
+</script>
+ENDPROGRESSUPDATE
+}
+
+sub LCprogressbar {
+    my ($r,$mode)=(@_);
+    my $starting=&mt('Starting');
+    my $content=(<<ENDPROGBAR);
+<p>
+  <div id="progressbar">
+    <span class="pblabel">$starting</span>
+  </div>
+</p>
+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);
+<script type="text/javascript">
+// <![CDATA[
+$function($val,'$text');
+// ]]>
+</script>
+ENDUPDATE
+    $r->rflush();
 }
 
 sub html_encode {




More information about the LON-CAPA-cvs mailing list