Provides markup for associating a tray trigger with a tray element.
A tray is a responsive container that wraps renderable content. Trays present content well on small and large screens alike.
array $element: A renderable array.
A renderable array.
function toolbar_pre_render_item($element) {
// If tray content is present, markup the tray and its associated trigger.
if (!empty($element['tray'])) {
// Trays are associated with their trigger by a unique ID.
$id = drupal_html_id('toolbar-tray');
$element['tab']['#tray_id'] = $id;
// Provide attributes for a tray trigger.
$attributes = array(
'id' => 'toolbar-tab-' . $id,
'data-toolbar-tray' => $id,
'aria-owns' => $id,
'role' => 'button',
'aria-pressed' => 'false',
);
// Merge in module-provided attributes.
$element['tab'] += array(
'#attributes' => array(),
);
$element['tab']['#attributes'] += $attributes;
$element['tab']['#attributes']['class'][] = 'trigger';
// Provide attributes for the tray theme wrapper.
$attributes = array(
'id' => $id,
'data-toolbar-tray' => $id,
'aria-owned-by' => 'toolbar-tab-' . $id,
);
// Merge in module-provided attributes.
if (!isset($element['tray']['#wrapper_attributes'])) {
$element['tray']['#wrapper_attributes'] = array();
}
$element['tray']['#wrapper_attributes'] += $attributes;
$element['tray']['#wrapper_attributes']['class'][] = 'tray';
if (!isset($element['tray']['#theme_wrappers'])) {
$element['tray']['#theme_wrappers'] = array();
}
// Add the standard theme_wrapper for trays.
array_unshift($element['tray']['#theme_wrappers'], 'toolbar_tray_wrapper');
// If a #heading is provided for the tray, provided a #theme_wrapper
// function to append it.
if (!empty($element['tray']['#heading'])) {
array_unshift($element['tray']['#theme_wrappers'], 'toolbar_tray_heading_wrapper');
}
}
return $element;
}