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);
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
*
* <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
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.'"';
} 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";
}
}
$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;
}