diff options
author | Gábor Hojtsy <gabor@hojtsy.hu> | 2008-01-15 10:43:00 +0000 |
---|---|---|
committer | Gábor Hojtsy <gabor@hojtsy.hu> | 2008-01-15 10:43:00 +0000 |
commit | d2a9e857d94a2ca4ae5c9a91d2f11eaa37306f40 (patch) | |
tree | a77df3611e81eb8b94b09fe4155ed56cc7c4ddba /includes | |
parent | ed41a4efec630f675bdfc00f76e8be33c4a765d3 (diff) | |
download | brdo-d2a9e857d94a2ca4ae5c9a91d2f11eaa37306f40.tar.gz brdo-d2a9e857d94a2ca4ae5c9a91d2f11eaa37306f40.tar.bz2 |
#208991 by JirkaRybka: target sticky table headers to Drupal output tables only, so it won't sticky random tables in other site content
Diffstat (limited to 'includes')
-rw-r--r-- | includes/theme.inc | 12 |
1 files changed, 9 insertions, 3 deletions
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 = '<table'. drupal_attributes($attributes) .">\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. |