By nicxvan on
Change record status:
Published (View all published change records)
Project:
Introduced in branch:
8.0.x
Introduced in version:
8.0-alpha2
Issue links:
Description:
Added
function theme_meter($variables) was added to allow for theming of progress meters in the poll module.
You can edit the following attributes:
- display_value: The textual representation of the meter bar.
- form: A string specifying one or more forms to which the element belongs separated by spaces.
- high: A number specifying the range that is considered to be a high value.
- low: A number specifying the range that is considered to be a low value.
- max: A number specifying the maximum value of the range.
- min: A number specifying the minimum value of the range.
- optimum: A number specifying what value is the optimal value for the gauge.
- value: A number specifying the current value of the gauge.
- percentage: A number specifying the current percentage of the gauge.
- attributes: Associative array of attributes to be placed in the meter tag.
This function was initially designed for the <meter> tag, but due to the lack of browser and styling support for it, we're currently using it's attributes as HTML5 data attributes on a <div>.
All variables except display_value, percentage, and attributes can be added to an array to replace default class attributes.
percentage determines the width of the child div.
display_value is placed in a div class percent for displaying numerical results.
Below is an example theme function that can be used to take advantage of the meter tag:
function mytheme_meter($variables) {
$attributes = $variables['attributes'];
foreach (array('form', 'high', 'low', 'max', 'min', 'optimum', 'value') as $attrib) {
if (!is_null($variables[$attrib])) {
$attributes[$attrib] = $variables[$attrib];
}
}
$output = '<meter' . drupal_attributes($attributes) . '>' . $variables['display_value'] . '</meter>';
return $output;
}
Removed
- template_preprocess_poll_bar(&$variables)
- Default theme implementation for poll results of one question.
- Default block implementation
Impacts:
Themers