From f5acde465ab5a59ae3c5eac0a76e2d3f7cee4f42 Mon Sep 17 00:00:00 2001 From: Roland Gruber Date: Sun, 24 Mar 2013 11:23:02 +0000 Subject: [PATCH] added htmlEqualHeight --- lam/lib/html.inc | 52 ++++++++++++++++++++++++++++++++++++ lam/templates/lib/500_lam.js | 18 +++++++++++++ 2 files changed, 70 insertions(+) diff --git a/lam/lib/html.inc b/lam/lib/html.inc index 58a5854a..9c97d4a8 100644 --- a/lam/lib/html.inc +++ b/lam/lib/html.inc @@ -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 ''; + return $return; + } + +} + /** * Creates a list of elements that can be sorted by the user via drag'n'drop. * diff --git a/lam/templates/lib/500_lam.js b/lam/templates/lib/500_lam.js index 5a32275f..33650fe1 100644 --- a/lam/templates/lib/500_lam.js +++ b/lam/templates/lib/500_lam.js @@ -85,6 +85,7 @@ function listShowSettingsDialog(title, okText, cancelText) { /** * Submits the form by clicking on the given button if enter was pressed. + * Example: SubmitForm('apply_filter', event); * * @param id button ID * @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. *