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

raeburn raeburn at source.lon-capa.org
Thu Jul 11 14:24:31 EDT 2013


raeburn		Thu Jul 11 18:24:31 2013 EDT

  Modified files:              
    /loncom/interface	loncommon.pm 
  Log:
  - jquery.nicescroll used for scrolling in div scrollboxes on mobile devices
    - Additional (optional) sixth arg for loncommon::start_scrollbox():
      ref to hash of options to pass to niceScroll()
    - javascript function resize_scrollbox() includes call to
      getNiceScroll().onResize() for scrollbox div, if size changed and
      browser.mobile set.  
  
  
Index: loncom/interface/loncommon.pm
diff -u loncom/interface/loncommon.pm:1.1137 loncom/interface/loncommon.pm:1.1138
--- loncom/interface/loncommon.pm:1.1137	Wed Jul 10 22:07:37 2013
+++ loncom/interface/loncommon.pm	Thu Jul 11 18:24:31 2013
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # a pile of common routines
 #
-# $Id: loncommon.pm,v 1.1137 2013/07/10 22:07:37 raeburn Exp $
+# $Id: loncommon.pm,v 1.1138 2013/07/11 18:24:31 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -7928,7 +7928,7 @@
 
 
 sub start_scrollbox {
-    my ($outerwidth,$width,$height,$id,$bgcolor)=@_;
+    my ($outerwidth,$width,$height,$id,$bgcolor,$cursor) = @_;
     unless ($outerwidth) { $outerwidth='520px'; }
     unless ($width) { $width='500px'; }
     unless ($height) { $height='200px'; }
@@ -7942,12 +7942,49 @@
     }
     my $nicescroll_js;
     if ($env{'browser.mobile'}) {
+        my %options;
+        if (ref($cursor) eq 'HASH') {
+            %options = %{$cursor};
+        }
+        unless ($options{'railalign'} =~ /^left|right$/) {
+            $options{'railalign'} = 'left';
+        }
+        unless ($options{'cursorcolor'} =~ /^\#\w+$/) {
+            my $function  = &get_users_function();
+            $options{'cursorcolor'} = &designparm($function.'.sidebg',$env{'request.role.domain'});
+            unless ($options{'cursorcolor'} =~ /^\#\w+$/) {
+                $options{'cursorcolor'} = '#00F';
+            }
+        }
+        if ($options{'cursoropacity'} =~ /^[\d.]+$/) {
+            unless ($options{'cursoropacity'} >= 0.0 && $options{'cursoropacity'} <=1.0) {
+                $options{'cursoropacity'}='1.0';
+            }
+        } else {
+            $options{'cursoropacity'}='1.0';
+        }
+        if ($options{'cursorfixedheight'} eq 'none') {
+            delete($options{'cursorfixedheight'});
+        } else {
+            unless ($options{'cursorfixedheight'} =~ /^\d+$/) { $options{'cursorfixedheight'}='50'; }
+        }
+        unless ($options{'railoffset'} =~ /^{[\w\:\d]+}$/) {
+            delete($options{'railoffset'});
+        } 
+        my @niceoptions;
+        while (my($key,$value) = each(%options)) {
+            if ($value =~ /^\{.+\}$/) {
+                push(@niceoptions,$key.':'.$value);
+            } else {
+                push(@niceoptions,$key.':"'.$value.'"');
+            }
+        }
         $nicescroll_js = '
 <script type="text/javascript">
 // <![CDATA[ 
 $(document).ready(
   function() {  
-      $("#div_'.$id.'").niceScroll({cursorcolor:"#00F"});
+      $("#div_'.$id.'").niceScroll({'.join(',', at niceoptions).'});
   }
 );
 




More information about the LON-CAPA-cvs mailing list