Issue #2329837 by Cottser | davidhernandez: Move filter classes from preprocess to templates.
parent
e0d3aca108
commit
364c3882a1
|
@ -733,9 +733,6 @@ function _filter_tips($format_id, $long = FALSE) {
|
|||
*/
|
||||
function template_preprocess_filter_guidelines(&$variables) {
|
||||
$format = $variables['format'];
|
||||
$variables['attributes']['class'][] = 'filter-guidelines-item';
|
||||
$variables['attributes']['class'][] = 'filter-guidelines-' . $format->format;
|
||||
|
||||
$variables['tips'] = array(
|
||||
'#theme' => 'filter_tips',
|
||||
'#tips' => _filter_tips($format->format, FALSE),
|
||||
|
@ -752,9 +749,10 @@ function template_preprocess_filter_guidelines(&$variables) {
|
|||
* - attributes: An associative array containing properties of the element.
|
||||
*/
|
||||
function template_preprocess_text_format_wrapper(&$variables) {
|
||||
$variables['aria_description'] = FALSE;
|
||||
// Add element class and id for screen readers.
|
||||
if (isset($variables['attributes']['aria-describedby'])) {
|
||||
$variables['attributes']['class'][] = 'description';
|
||||
$variables['aria_description'] = TRUE;
|
||||
$variables['attributes']['id'] = $variables['attributes']['aria-describedby'];
|
||||
// Remove aria-describedby attribute as it shouldn't be visible here.
|
||||
unset($variables['attributes']['aria-describedby']);
|
||||
|
@ -788,25 +786,14 @@ function template_preprocess_text_format_wrapper(&$variables) {
|
|||
*/
|
||||
function template_preprocess_filter_tips(&$variables) {
|
||||
$tips = $variables['tips'];
|
||||
$long = $variables['long'];
|
||||
|
||||
foreach ($variables['tips'] as $name => $tiplist) {
|
||||
foreach ($tiplist as $tip_key => $tip) {
|
||||
$tiplist[$tip_key]['attributes'] = new Attribute(array());
|
||||
if ($long) {
|
||||
$tiplist[$tip_key]['attributes']['class'] = array('filter-' . str_replace("/", "-", $tip['id']));
|
||||
}
|
||||
$tiplist[$tip_key]['attributes'] = new Attribute();
|
||||
}
|
||||
|
||||
$attributes = array(
|
||||
'class' => array(
|
||||
'filter-type',
|
||||
'filter-' . drupal_html_class($name),
|
||||
),
|
||||
);
|
||||
|
||||
$variables['tips'][$name] = array(
|
||||
'attributes' => new Attribute($attributes),
|
||||
'attributes' => new Attribute(),
|
||||
'name' => String::checkPlain($name),
|
||||
'list' => $tiplist,
|
||||
);
|
||||
|
|
|
@ -19,7 +19,13 @@
|
|||
* @ingroup themeable
|
||||
*/
|
||||
#}
|
||||
<div{{ attributes }}>
|
||||
{%
|
||||
set classes = [
|
||||
'filter-guidelines-item',
|
||||
'filter-guidelines-' ~ format.format,
|
||||
]
|
||||
%}
|
||||
<div{{ attributes.addClass(classes) }}>
|
||||
<h4 class="label">{{ format.name }}</h4>
|
||||
{{ tips }}
|
||||
</div>
|
||||
|
|
|
@ -27,16 +27,27 @@
|
|||
<div class="compose-tips">
|
||||
{% endif %}
|
||||
|
||||
{% for tip in tips %}
|
||||
{% for name, tip in tips %}
|
||||
{% if multiple %}
|
||||
<div{{ tip.attributes }}>
|
||||
{%
|
||||
set tip_classes = [
|
||||
'filter-type',
|
||||
'filter-' ~ name|clean_class,
|
||||
]
|
||||
%}
|
||||
<div{{ tip.attributes.addClass(tip_classes) }}>
|
||||
<h3>{{ tip.name }}</h3>
|
||||
{% endif %}
|
||||
|
||||
{% if tip.list|length %}
|
||||
<ul class="tips">
|
||||
{% for item in tip.list %}
|
||||
<li{{ item.attributes }}>{{ item.tip }}</li>
|
||||
{%
|
||||
set item_classes = [
|
||||
long ? 'filter-' ~ item.id|replace({'/': '-'}),
|
||||
]
|
||||
%}
|
||||
<li{{ item.attributes.addClass(item_classes) }}>{{ item.tip }}</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% endif %}
|
||||
|
|
|
@ -7,6 +7,8 @@
|
|||
* - children: Text format element children.
|
||||
* - description: Text format element description.
|
||||
* - attributes: HTML attributes for the containing element.
|
||||
* - aria_description: Flag for whether or not an ARIA description has been
|
||||
* added to the description container.
|
||||
*
|
||||
* @see template_preprocess_text_format_wrapper()
|
||||
*
|
||||
|
@ -16,6 +18,11 @@
|
|||
<div class="text-format-wrapper form-item">
|
||||
{{ children }}
|
||||
{% if description %}
|
||||
<div{{ attributes }}>{{ description }}</div>
|
||||
{%
|
||||
set classes = [
|
||||
aria_description ? 'description',
|
||||
]
|
||||
%}
|
||||
<div{{ attributes.addClass(classes) }}>{{ description }}</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
|
Loading…
Reference in New Issue