function equalheights_init in Equal Heights jQuery 6
Same name and namespace in other branches
- 7 equalheights.module \equalheights_init()
Implementation of hook_init().
File
- ./
equalheights.module, line 31 - Adds a jQuery plugin that sets the elements you specify to the same height.
Code
function equalheights_init() {
$equalheightsclasses = variable_get('equalheights_css_classes', '');
if (!empty($equalheightsclasses)) {
// Using \R to account for the new line delimiter on all systems
$classes = preg_split("/\\R\\s*/", $equalheightsclasses);
$jqueryequalheightsjs = drupal_get_path('module', 'equalheights') . '/jquery.equalheights.js';
drupal_add_js($jqueryequalheightsjs, 'module');
$js = "\$(document).ready(function(){";
foreach ($classes as $class) {
if (!empty($class)) {
// Check if there's a ":" inside the setting string to avoid notices
if (strpos($class, ':') !== false) {
list($class, $height) = explode(":", $class);
}
// Set the overflow value
$overflow_value = variable_get('equalheights_overflow', 'visible');
$js .= "\$('{$class}').equalHeights({$height}).css('overflow', '{$overflow_value}');";
}
}
$js .= "});";
drupal_add_js($js, 'inline');
}
}