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

raeburn raeburn at source.lon-capa.org
Mon Aug 15 11:58:28 EDT 2011


raeburn		Mon Aug 15 15:58:28 2011 EDT

  Modified files:              
    /loncom/interface	loncommon.pm 
  Log:
  - Additional (optional) arguments for &start_scrollbox() and &start_datatable().
  - Arguments will provide an id for the corresponding element (<div> or <table>).
    - Developers using these should ensure use of a unique id, each time routine
      is called to create mark-up for a single web page.
  
  
Index: loncom/interface/loncommon.pm
diff -u loncom/interface/loncommon.pm:1.1017 loncom/interface/loncommon.pm:1.1018
--- loncom/interface/loncommon.pm:1.1017	Mon Aug 15 05:16:30 2011
+++ loncom/interface/loncommon.pm	Mon Aug 15 15:58:28 2011
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # a pile of common routines
 #
-# $Id: loncommon.pm,v 1.1017 2011/08/15 05:16:30 raeburn Exp $
+# $Id: loncommon.pm,v 1.1018 2011/08/15 15:58:28 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -633,7 +633,7 @@
 }
 
 sub javascript_array_indexof {
-    return <<ENDJS; 
+    return <<ENDJS;
 <script type="text/javascript" language="JavaScript">
 // <![CDATA[
 
@@ -6940,11 +6940,15 @@
 
 
 sub start_scrollbox {
-    my ($outerwidth,$width,$height)=@_;
+    my ($outerwidth,$width,$height,$id)=@_;
     unless ($outerwidth) { $outerwidth='520px'; }
     unless ($width) { $width='500px'; }
     unless ($height) { $height='200px'; }
-    return "<table style='width: $outerwidth; border: 1px solid black;'><tr><td style='width: $width;' bgcolor='#FFFFFF'><div style='overflow:auto; width:$width; height: $height;'>";
+    my $div_id;
+    if ($id ne '') {
+        $div_id = " id='$id'";
+    }
+    return "<table style='width: $outerwidth; border: 1px solid black;'><tr><td style='width: $width;' bgcolor='#FFFFFF'><div style='overflow:auto; width:$width; height: $height;'$div_id>";
 }
 
 sub end_scrollbox {
@@ -6978,10 +6982,14 @@
     }
 
     sub start_data_table {
-	my ($add_class) = @_;
+	my ($add_class,$id) = @_;
 	my $css_class = (join(' ','LC_data_table',$add_class));
+        my $table_id;
+        if (defined($id)) {
+            $table_id = ' id="'.$id.'"';
+        }
 	&start_data_table_count();
-	return '<table class="'.$css_class.'">'."\n";
+	return '<table class="'.$css_class.'"'.$table_id.'>'."\n";
     }
 
     sub end_data_table {




More information about the LON-CAPA-cvs mailing list