diff --git a/core/modules/contextual/contextual.module b/core/modules/contextual/contextual.module index d9d20b5..4543237 100644 --- a/core/modules/contextual/contextual.module +++ b/core/modules/contextual/contextual.module @@ -33,6 +33,7 @@ function contextual_toolbar() { } $tab['contextual'] = array( + '#type' => 'toolbar_item', 'tab' => array( '#type' => 'html_tag', '#tag' => 'button', @@ -43,7 +44,6 @@ function contextual_toolbar() { 'aria-pressed' => 'false', ), ), - '#theme_wrappers' => array('toolbar_tab_wrapper'), '#wrapper_attributes' => array( 'class' => array('hidden', 'contextual-toolbar-tab'), ), diff --git a/core/modules/toolbar/templates/toolbar.html.twig b/core/modules/toolbar/templates/toolbar.html.twig new file mode 100644 index 0000000..25430d0 --- /dev/null +++ b/core/modules/toolbar/templates/toolbar.html.twig @@ -0,0 +1,43 @@ +{# +/** + * @file + * Default theme implementation for the administrative toolbar. + * + * Available variables: + * - attributes: HTML attributes for the wrapper. + * - toolbar_attributes: HTML attributes to apply to the toolbar. + * - toolbar_heading: The heading or label for the toolbar. + * - tabs: List of tabs for the toolbar. + * - attributes: HTML Attributes for the tab container. + * - link: Link or button for the menu tab. + * - trays: Toolbar tray list, each associated with a tab. Each tray in trays + * contains: + * - attributes: HTML attributes to apply to the tray. + * - label: The tray's label. + * - links: The tray menu links. + * + * @see template_preprocess_toolbar() + * + * @ingroup themeable + */ +#} + + + {{ toolbar_heading }} + {% for tab in tabs %} + {{ tab.link }} + {% endfor %} + + {% for tray in trays %} + {% spaceless %} + + + {% if tray.label %} + {{ tray.label }} + {% endif %} + {{ tray.links }} + + + {% endspaceless %} + {% endfor %} + diff --git a/core/modules/toolbar/toolbar.module b/core/modules/toolbar/toolbar.module index b8b0dcb..ca87198 100644 --- a/core/modules/toolbar/toolbar.module +++ b/core/modules/toolbar/toolbar.module @@ -48,6 +48,7 @@ function toolbar_permission() { function toolbar_theme($existing, $type, $theme, $path) { $items['toolbar'] = array( 'render element' => 'element', + 'template' => 'toolbar', ); $items['toolbar_item'] = array( 'render element' => 'element', @@ -97,9 +98,7 @@ function toolbar_element_info() { ); // A toolbar item is wrapped in markup for common styling. The 'tray' - // property contains a renderable array. theme_toolbar_tab() is a light - // wrapper around the l() function. The contents of tray are rendered in - // theme_toolbar_tab(). + // property contains a renderable array. $elements['toolbar_item'] = array( '#pre_render' => array('toolbar_pre_render_item'), '#theme' => 'toolbar_item', @@ -220,6 +219,8 @@ function ($object) { /** * Returns HTML that wraps the administration toolbar. * + * Default template: toolbar.html.twig. + * * @param array $variables * An associative array containing: * - element: An associative array containing the properties and children of @@ -230,7 +231,26 @@ function theme_toolbar(&$variables) { $element = $variables['element']; $trays = ''; foreach (element_children($element) as $key) { + // Add the tray. + if (isset($element[$key]['tray'])) { + $variables['trays'][$key] = array( + 'links' => $element[$key]['tray'], + 'attributes' => new Attribute($element[$key]['tray']['#wrapper_attributes']), + ); $trays .= drupal_render($element[$key]['tray']); + $variables['trays'][$key]['label'] = $element[$key]['tray']['#heading']; + } + // Unset the tray so it doesn't render twice in the template. + unset($element[$key]['tray']); + } + + // Pass the wrapper attributes along. + if (array_key_exists('#wrapper_attributes', $element[$key])) { + $element[$key]['#wrapper_attributes']['class'][] = 'toolbar-tab'; + $attributes = $element[$key]['#wrapper_attributes']; + } + else { + $attributes = array('class' => array('toolbar-tab')); } return '' . ''