You are here

function acquia_lift_navbar_ui_pre_render 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()

Builds the unified navbar as a structured array ready for drupal_render().

Parameters

array $element: A renderable array

Return value

A renderable array.

See also

navbar_pre_render().

acquia_lift_page_build().

1 call to acquia_lift_navbar_ui_pre_render()
acquia_lift_navbar_pre_render in ./acquia_lift.module
Pre-render function for Acquia Lift unified navbar element.

File

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

Code

function acquia_lift_navbar_ui_pre_render($element) {

  // Define the breakpoints to switch from vertical to horizontal
  // navbar presentation.
  $breakpoints = array(
    'narrow' => 'only screen and (min-width: 16.5em)',
    'standard' => 'only screen and (min-width: 38.125em)',
    'wide' => 'only screen and (min-width: 50em)',
  );

  // Allow for altering of the breakpoints.
  drupal_alter('acquia_lift_breakpoints', $breakpoints);
  if (!empty($breakpoints)) {
    $element['#attached']['js'][] = array(
      'data' => array(
        'acquia_lift' => array(
          'unified_navbar' => array(
            'breakpoints' => $breakpoints,
          ),
        ),
      ),
      'type' => 'setting',
    );
  }

  // Get the navigation items as defined for the navbar implementation.
  $items = acquia_lift_navbar();

  // Sort the children.
  uasort($items, 'element_sort');

  // Merge in the original navbar values.
  $element = array_merge($element, $items);

  // Render the children.
  $element['#children'] = drupal_render_children($element);
  return $element;
}