diff --git a/core/modules/toolbar/toolbar.module b/core/modules/toolbar/toolbar.module index 4b4e0d8..379b80a 100644 --- a/core/modules/toolbar/toolbar.module +++ b/core/modules/toolbar/toolbar.module @@ -197,6 +197,16 @@ function template_preprocess_toolbar(&$variables) { } /** + * Implements template_preprocess_HOOK(). + */ +function template_preprocess_toolbar_tab_wrapper(&$variables) { + if (!isset($variables['element']['#attributes'])) { + $variables['element']['#attributes'] = array(); + } + $variables['element']['#attributes']['class'][] = 'tab'; +} + +/** * Returns HTML for wrapping a toolbar tab. * * Toolbar tabs have a common styling and placement with the toolbar's bar area. @@ -207,9 +217,8 @@ function template_preprocess_toolbar(&$variables) { * the tray. Properties used: #children and #attributes. */ function theme_toolbar_tab_wrapper(&$variables) { - $element = $variables['element']; - if (!empty($element['#children'])) { - $element['#attributes']['class'][] = 'tab'; + if (!empty($variables['element']['#children'])) { + $element = $variables['element']; return '' . $element['#children'] . ''; } } @@ -248,6 +257,26 @@ function theme_toolbar_tray_toggle(&$variables) { } /** + * Implements template_preprocess_HOOK(). + */ +function template_preprocess_toolbar_tray_wrapper(&$variables) { + if (!isset($variables['element']['#attributes'])) { + $variables['element']['#attributes'] = array(); + } + if (!empty($variables['element']['#toolbar_identifier'])) { + $group = $variables['element']['#toolbar_identifier']; + $variables['element']['#attributes'] += array( + 'id' => 'toolbar-tray-' . $group, + 'data-toolbar-tray' => $group, + 'aria-owned-by' => 'toolbar-tab-' . $group, + ); + $variables['element']['#attributes']['class'][] = 'tray'; + $variables['element']['#attributes']['class'][] = 'tray-' . $group; + $variables['element']['#attributes']['class'][] = 'overlay-displace-top'; + } +} + +/** * Returns HTML for wrapping a toolbar tray. * * Used in combination with theme_toolbar_tray_toggle() to create an @@ -260,25 +289,11 @@ function theme_toolbar_tray_toggle(&$variables) { * and #heading. */ function theme_toolbar_tray_wrapper(&$variables) { - $element = $variables['element']; - if (!empty($element['#children'])) { - if (!empty($element['#toolbar_identifier'])) { - $group = $element['#toolbar_identifier']; - if (!isset($element['#attributes'])) { - $element['#attributes'] = array(); - } - $element['#attributes'] += array( - 'id' => 'toolbar-tray-' . $group, - 'data-toolbar-tray' => $group, - 'aria-owned-by' => 'toolbar-tab-' . $group, - ); - $element['#attributes']['class'][] = 'tray'; - $element['#attributes']['class'][] = 'tray-' . $group; - $element['#attributes']['class'][] = 'overlay-displace-top'; - } + if (!empty($variables['element']['#children'])) { + $element = $variables['element']; // Print a heading in the tray if one exists. $heading = (isset($element['#heading'])) ? '

' . $element['#heading'] . '

' : ''; - return '
' . $heading . $variables['element']['#children'] . '
'; + return '
' . $heading . $element['#children'] . '
'; } }