From d2a9e857d94a2ca4ae5c9a91d2f11eaa37306f40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A1bor=20Hojtsy?= Date: Tue, 15 Jan 2008 10:43:00 +0000 Subject: #208991 by JirkaRybka: target sticky table headers to Drupal output tables only, so it won't sticky random tables in other site content --- includes/theme.inc | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'includes') diff --git a/includes/theme.inc b/includes/theme.inc index cc372afa6..26f1eaa27 100644 --- a/includes/theme.inc +++ b/includes/theme.inc @@ -1228,6 +1228,15 @@ function theme_submenu($links) { * An HTML string representing the table. */ function theme_table($header, $rows, $attributes = array(), $caption = NULL) { + + // Add sticky headers, if applicable. + if (count($header)) { + drupal_add_js('misc/tableheader.js'); + // Add 'sticky-enabled' class to the table to identify it for JS. + // This is needed to target tables constructed by this function. + $attributes['class'] = empty($attributes['class']) ? 'sticky-enabled' : ($attributes['class'] .' sticky-enabled'); + } + $output = '\n"; if (isset($caption)) { @@ -1236,9 +1245,6 @@ function theme_table($header, $rows, $attributes = array(), $caption = NULL) { // Format the table header: if (count($header)) { - // Include JS for sticky headers. - drupal_add_js('misc/tableheader.js'); - $ts = tablesort_init($header); // HTML requires that the thead tag has tr tags in it follwed by tbody // tags. Using ternary operator to check and see if we have any rows. -- cgit v1.2.3