From: tjhunt Date: Tue, 18 Nov 2008 10:17:27 +0000 (+0000) Subject: Let any table have rotated text in its headers. Stolen from sam's activity completion... X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=692103a2a5d7964112106e4302b6f966ca7f7c78;p=moodle.git Let any table have rotated text in its headers. Stolen from sam's activity completion report. --- diff --git a/course/report/progress/index.php b/course/report/progress/index.php index 4a0bfaaed8..264c099fd0 100644 --- a/course/report/progress/index.php +++ b/course/report/progress/index.php @@ -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"); diff --git a/course/report/progress/textrotate.js b/course/report/progress/textrotate.js index 0a93a4833c..1c0a40e7ec 100644 --- a/course/report/progress/textrotate.js +++ b/course/report/progress/textrotate.js @@ -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 2.0)) && !$USER->screenreader;; +} + /** * Hack to find out the GD version by parsing phpinfo output * diff --git a/lib/weblib.php b/lib/weblib.php index 302acd0135..050e79c0ca 100644 --- a/lib/weblib.php +++ b/lib/weblib.php @@ -4841,6 +4841,7 @@ function print_png($url, $sizex, $sizey, $return, $parameters='alt=""') { *
  • $table->rowclass[] - classes to add to particular rows. *
  • $table->summary - Description of the contents for screen readers. *
  • $table->headspan can be used to make a heading span multiple columns. + *
  • $table->rotateheaders - Causes the contents of the heading cells to be rotated 90%. * * @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 = ''; + $wrapperend = ''; + } else { + $wrapperstart = ''; + $wrapperend = ''; + } - $output .= ''. $heading .''; + $output .= ''. + $wrapperstart . $heading . $wrapperend . ''; } $output .= ''."\n"; } @@ -4977,6 +4992,11 @@ function print_table($table, $return=false) { } $output .= ''."\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; } diff --git a/theme/standardwhite/gradients.css b/theme/standardwhite/gradients.css index 8325996b3b..4b4bb703cc 100644 --- a/theme/standardwhite/gradients.css +++ b/theme/standardwhite/gradients.css @@ -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;