]> git.mjollnir.org Git - moodle.git/commitdiff
Let any table have rotated text in its headers. Stolen from sam's activity completion...
authortjhunt <tjhunt>
Tue, 18 Nov 2008 10:17:27 +0000 (10:17 +0000)
committertjhunt <tjhunt>
Tue, 18 Nov 2008 10:17:27 +0000 (10:17 +0000)
course/report/progress/index.php
course/report/progress/textrotate.js
lib/moodlelib.php
lib/weblib.php
theme/standardwhite/gradients.css

index 4a0bfaaed8bc7e29e308facacaf005097b762dae..264c099fd0171d9b62488bf09c6a5ec3a6f6c11d 100644 (file)
@@ -77,7 +77,7 @@ if($csv) {
     }
 } else {
     // Use SVG to draw sideways text if supported
-    $svgcleverness=ajaxenabled(array('Firefox'=>2.0)) && !$USER->screenreader;
+    $svgcleverness=can_use_rotated_text();
 
     // Navigation and header
     $strreports = get_string("reports");
index 0a93a4833ccf7c3d62236da0c3eb12611b403304..1c0a40e7ece12aee4fab4310c990635b6374d35b 100644 (file)
@@ -67,7 +67,18 @@ function textrotate_init() {
     parent.insertBefore(el,parent.firstChild);
     textrotate_make_svg(el.firstChild);
   }
-  
+
+  elements=YAHOO.util.Dom.getElementsByClassName('rotateheaders', 'table');
+  for(var i=0;i<elements.length;i++)
+  {
+    var table=elements[i];
+    var headercells = YAHOO.util.Dom.getElementsByClassName('header', 'th', table);
+    for(var j=0;j<headercells.length;j++)
+    {
+      var el=headercells[j];
+      textrotate_make_svg(el.firstChild);
+    }
+  }
 }
 
 YAHOO.util.Event.onDOMReady(textrotate_init); 
index c6fc0fcee00bcd5acf5dcd1e9fc05ccd6d05e249..caecaff33b4ef2f8f65e63df1e37c622fdbbd1e6 100644 (file)
@@ -6436,6 +6436,14 @@ function can_use_html_editor() {
     return false;
 }
 
+/**
+ * Can handle rotated text. Whether it is safe to use the trickery in textrotate.js.
+ */
+function can_use_rotated_text() {
+    global $USER;
+    return ajaxenabled(array('Firefox' => 2.0)) && !$USER->screenreader;;
+}
+
 /**
  * Hack to find out the GD version by parsing phpinfo output
  *
index 302acd0135b5e8438756268ba7810e9d56dd3137..050e79c0ca94792a76d25e03332d9ffdfba07bbf 100644 (file)
@@ -4841,6 +4841,7 @@ function print_png($url, $sizex, $sizey, $return, $parameters='alt=""') {
  *     <li>$table->rowclass[] - classes to add to particular rows.
  *     <li>$table->summary - Description of the contents for screen readers.
  *     <li>$table->headspan can be used to make a heading span multiple columns.
+ *     <li>$table->rotateheaders - Causes the contents of the heading cells to be rotated 90%.
  * </ul>
  * @param bool $return whether to return an output string or echo now
  * @return boolean or $string
@@ -4896,6 +4897,11 @@ function print_table($table, $return=false) {
     if (empty($table->class)) {
         $table->class = 'generaltable';
     }
+    if (!empty($table->rotateheaders)) {
+        $table->class .= ' rotateheaders';
+    } else {
+        $table->rotateheaders = false; // Makes life easier later.
+    }
 
     $tableid = empty($table->id) ? '' : 'id="'.$table->id.'"';
 
@@ -4930,8 +4936,17 @@ function print_table($table, $return=false) {
             } else {
                 $extraclass = '';
             }
+            if ($table->rotateheaders) {
+                $wrapperstart = '<span>';
+                $wrapperend = '</span>';
+            } else {
+                $wrapperstart = '';
+                $wrapperend = '';
+            }
 
-            $output .= '<th style="vertical-align:top;'. $align[$key].$size[$key] .';white-space:nowrap;" class="header c'.$key.$extraclass.'" scope="col"' . $colspan . '>'. $heading .'</th>';
+            $output .= '<th style="vertical-align:top;'. $align[$key].$size[$key] .
+                    ';white-space:nowrap;" class="header c'.$key.$extraclass.'" scope="col"' . $colspan . '>'.
+                    $wrapperstart . $heading . $wrapperend . '</th>';
         }
         $output .= '</tr>'."\n";
     }
@@ -4977,6 +4992,11 @@ function print_table($table, $return=false) {
     }
     $output .= '</table>'."\n";
 
+    if ($table->rotateheaders && can_use_rotated_text()) {
+        require_js(array('yui_yahoo','yui_event','yui_dom'));
+        require_js('course/report/progress/textrotate.js');
+    }
+
     if ($return) {
         return $output;
     }
index 8325996b3b0d10d3e3608558b490bc45545e355f..4b4bb703cc11d3dffffe883a5dfcc05470d58af2 100644 (file)
@@ -13,7 +13,9 @@ div.header {
     background-position:top;    
     background-repeat:repeat-x;     
 }
-
+table.rotateheaders th.header {
+    background-image: none;
+}
 .navbar {
     background-image:url(gradient.jpg);     
     background-position:top;