function navbar_pre_render_item in Navbar 7
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.
Parameters
array $element: A renderable array.
Return value
A renderable array.
1 string reference to 'navbar_pre_render_item'
- navbar_element_info in ./
navbar.module - Implements hook_element_info().
File
- ./
navbar.module, line 337 - Administration navbar for quick access to top level administration items.
Code
function navbar_pre_render_item($element) {
// Assign each item a unique ID.
$id = drupal_html_id('navbar-item');
// Provide attributes for a navbar item.
$attributes = array(
'id' => $id,
);
// If tray content is present, markup the tray and its associated trigger.
if (!empty($element['tray'])) {
// Provide attributes necessary for trays.
$attributes += array(
'data-navbar-tab-trigger' => '',
'data-navbar-tray' => $id . '-tray',
'aria-owns' => $id,
'role' => 'button',
'aria-pressed' => 'false',
);
// Merge in module-provided attributes.
$element['tab'] += array(
'#attributes' => array(),
);
$element['tab']['#attributes'] += $attributes;
// Provide attributes for the tray theme wrapper.
$attributes = array(
'id' => $id . '-tray',
'data-navbar-tray' => $id . '-tray',
'aria-owned-by' => $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'][] = 'navbar-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'], 'navbar_tray_wrapper');
// If a #heading is provided for the tray, provided a #theme_wrapper
// function to append it.
array_unshift($element['tray']['#theme_wrappers'], 'navbar_tray_heading_wrapper');
}
return $element;
}