You are here

function acquia_lift_navbar_ui_pre_render_item in Acquia Lift Connector 7.2

Same name and namespace in other branches
  1. 7 acquia_lift.ui.inc \acquia_lift_navbar_ui_pre_render_item()

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.

See also

navbar_pre_render_item().

1 call to acquia_lift_navbar_ui_pre_render_item()
acquia_lift_navbar_pre_render_item in ./acquia_lift.module
Pre-render function for an item within the unified navbar element.

File

./acquia_lift.ui.inc, line 288
acquia_lift.ui.inc Provides functions needed for the front-end UI.

Code

function acquia_lift_navbar_ui_pre_render_item($element) {

  // Assign each item a unique ID.
  $id = drupal_html_id('navbar-item');

  // If tray content is present, markup the tray and its associated trigger.
  if (!empty($element['tray'])) {

    // 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'], 'acquia_lift_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'], 'acquia_lift_navbar_tray_heading_wrapper');
  }
  return $element;
}