added htmlEqualHeight

This commit is contained in:
Roland Gruber 2013-03-24 11:23:02 +00:00
parent 777392fc7c
commit f5acde465a
2 changed files with 70 additions and 0 deletions

View File

@ -2836,6 +2836,58 @@ class htmlEqualWidth extends htmlElement {
} }
/**
* Sets all given elements to the same height.
*
* @package metaHTML
*/
class htmlEqualHeight extends htmlElement {
/** list of element IDs */
private $elements = array();
/**
* Constructor.
*
* @param array $elements list of element IDs
*/
function __construct($elements) {
foreach ($elements as $element) {
$this->elements[] = htmlspecialchars($element);
}
}
/**
* Prints the HTML code for this element.
*
* @param string $module Name of account module
* @param array $input List of meta-HTML elements
* @param array $values List of values which override the defaults in $input (name => value)
* @param boolean $restricted If true then no buttons will be displayed
* @param integer $tabindex Start value of tabulator index for input fields
* @param string $scope Account type
* @return array List of input field names and their type (name => type)
*/
function generateHTML($module, $input, $values, $restricted, &$tabindex, $scope) {
if (sizeof($this->elements) == 0) {
return array();
}
$return = array();
$listContent = "'#" . $this->elements[0] . "'";
for ($i = 1; $i < sizeof($this->elements); $i++) {
$listContent .= ", '#" . $this->elements[$i] . "'";
}
echo '<script type="text/javascript">';
echo ' jQuery(document).ready(function() {';
echo ' var equalHeightElements = new Array(' . $listContent . ');';
echo ' equalHeight(equalHeightElements);';
echo ' });';
echo '</script>';
return $return;
}
}
/** /**
* Creates a list of elements that can be sorted by the user via drag'n'drop. * Creates a list of elements that can be sorted by the user via drag'n'drop.
* *

View File

@ -85,6 +85,7 @@ function listShowSettingsDialog(title, okText, cancelText) {
/** /**
* Submits the form by clicking on the given button if enter was pressed. * Submits the form by clicking on the given button if enter was pressed.
* Example: SubmitForm('apply_filter', event);
* *
* @param id button ID * @param id button ID
* @param e event * @param e event
@ -333,6 +334,23 @@ function equalWidth(elementIDs) {
} }
} }
/**
* Alines the elements with the given IDs to the same height.
*
* @param elementIDs IDs
*/
function equalHeight(elementIDs) {
var max = 0;
for (var i = 0; i < elementIDs.length; ++i) {
if (jQuery(elementIDs[i]).height() > max) {
max = jQuery(elementIDs[i]).height();
};
}
for (var i = 0; i < elementIDs.length; ++i) {
jQuery(elementIDs[i]).css({'height': max - (jQuery(elementIDs[i]).outerHeight() - jQuery(elementIDs[i]).height())});
}
}
/** /**
* Shows the dialog to change the list settings. * Shows the dialog to change the list settings.
* *