equalheights.module in Equal Heights jQuery 7.2
Same filename and directory in other branches
Adds a jQuery plugin that sets the elements you specify to the same height.
This module implements a jQuery plugin that can equalize the height of the user specified elements with the same class. By default, the height of the tallest element is used, but minimum and maximum height can also be set. The format for the admin settings should be 'classname:minheight,maxheight'. To find out more about the plugin, go to http://www.cssnewbie.com/equalheights-jquery-plugin/
File
equalheights.moduleView source
<?php
/**
* @file
* Adds a jQuery plugin that sets the elements you specify to the same height.
*
* This module implements a jQuery plugin that can equalize the height of the
* user specified elements with the same class.
* By default, the height of the tallest element is used, but minimum and
* maximum height can also be set.
* The format for the admin settings should be 'classname:minheight,maxheight'.
* To find out more about the plugin, go to
* http://www.cssnewbie.com/equalheights-jquery-plugin/
*/
/**
* Implements hook_help().
*/
function equalheights_help($path = '', $arg = NULL) {
$output = '';
switch ($path) {
case 'admin/help#equalheights':
case 'admin/config/development/equalheights':
$output = '<p>' . t("Implements a jQuery plugin that makes the height of the elements equal.") . '</p>';
$output .= t("Add elements or CSS classes that you need to be of equal height (with a leading period ('.') ) . <br />");
$output .= t('Note: you can combine multiple selectors, i.e. "header, .wrapper".');
$output .= t('You can optionally set minimum and maximum height, overflow value. ');
$output .= t('(<a href="@about">Read more about the plugin.</a>) ', array(
'@about' => 'http://www.cssnewbie.com/equalheights-jquery-plugin/',
));
break;
}
return $output;
}
/**
* Implements hook_library().
*
* For the file packaged with the module.
*/
function equalheights_library() {
$libraries['jquery-equalheights'] = array(
'title' => "Equalheights jQuery",
'website' => 'http://www.cssnewbie.com/equalheights-jquery-plugin/',
'version' => '1.0',
'js' => array(
drupal_get_path('module', 'equalheights') . '/jquery.equalheights.js' => array(),
),
);
return $libraries;
}
/**
* Implements hook_libraries_info().
*
* For defining external libraries.
*/
function equalheights_libraries_info() {
$libraries['imagesloaded'] = array(
'name' => 'jquery imagesloaded',
'vendor url' => 'https://github.com/desandro/imagesloaded',
'download url' => 'https://github.com/desandro/imagesloaded',
// 2.1.12
'version arguments' => array(
'file' => 'jquery.imagesloaded.js',
'pattern' => '@plugin v([0-9\\.a-z]+)@',
'lines' => 5,
),
'files' => array(
'js' => array(
'jquery.imagesloaded.min.js',
),
),
'variants' => array(
'minified' => array(
'files' => array(
'js' => array(
'jquery.imagesloaded.min.js',
),
),
),
'source' => array(
'files' => array(
'js' => array(
'jquery.imagesloaded.js',
),
),
),
),
);
return $libraries;
}
/**
* Implements hook_page_build().
*/
function equalheights_page_build() {
$equalheightsclasses = variable_get('equalheights_css_classes', array());
if (!empty($equalheightsclasses)) {
// Adding jquery.equalheights.js as a library.
drupal_add_library('equalheights', 'jquery-equalheights', TRUE);
equalheights_load_libraries($equalheightsclasses);
}
}
/**
* Implements hook_menu().
*/
function equalheights_menu() {
$description = t('Add CSS classes that you need to be of equal height, without a leading period (\'.\').<br />');
$description .= t('You can optionally set minimum and maximum height, overflow value. ');
$description .= t('(<a href="@about">Read more about the plugin.</a>) ', array(
'@about' => 'http://www.cssnewbie.com/equalheights-jquery-plugin/',
));
$items = array();
$items['admin/config/development/equalheights'] = array(
'title' => 'Equal Heights',
'description' => 'Configure elements with equal heights.',
'access arguments' => array(
'administer site configuration',
),
'page callback' => 'drupal_get_form',
'page arguments' => array(
'equalheights_admin',
),
'file' => 'equalheights.admin.inc',
);
return $items;
}
/*
* Implements hook_theme().
*/
function equalheights_theme() {
return array(
'equalheights_classes' => array(
'render element' => 'form',
'file' => 'equalheights.admin.inc',
),
);
}
function equalheights_load_libraries($equalheightsclasses) {
// Determine which variant of the script to load depending
// on the config settings.
$imagesloaded_ie8 = variable_get('equalheights_imagesloaded_iele8');
$settings = array(
'classes' => $equalheightsclasses,
'imagesloaded_ie8' => $imagesloaded_ie8,
);
if (variable_get('equalheights_imagesloaded_min')) {
$variant = 'minified';
}
else {
$variant = 'source';
}
$library = libraries_load('imagesloaded', $variant);
if ($library && !empty($library['loaded'])) {
// Only load settings once.
static $loaded = FALSE;
if (!$loaded) {
drupal_add_js(array(
'equalHeightsModule' => $settings,
), 'setting');
$loaded = TRUE;
}
}
else {
$message = t('The imagesloaded library was not found! Please following the instructions from the README.txt to get the plugin.');
drupal_set_message($message, $type = 'error');
}
}
Functions
Name![]() |
Description |
---|---|
equalheights_help | Implements hook_help(). |
equalheights_libraries_info | Implements hook_libraries_info(). |
equalheights_library | Implements hook_library(). |
equalheights_load_libraries | |
equalheights_menu | Implements hook_menu(). |
equalheights_page_build | Implements hook_page_build(). |
equalheights_theme |