You are here

function responsive_menu_page_build in Responsive and off-canvas menu 7

Same name and namespace in other branches
  1. 7.3 responsive_menu.module \responsive_menu_page_build()
  2. 7.2 responsive_menu.module \responsive_menu_page_build()

Implements hook_page_build().

File

./responsive_menu.module, line 253

Code

function responsive_menu_page_build(&$page) {
  if (path_is_admin(current_path())) {
    return;
  }
  $menus_variable = variable_get('responsive_menu_off_canvas_menus', 'main-menu');
  $menus = explode(',', $menus_variable);
  $menu_tree = array();
  foreach ($menus as $menu_name) {
    $tree = responsive_menu_tree_block_data(trim($menu_name));
    $menu_tree = array_merge($menu_tree, $tree);
  }

  // Load the superfish library.
  if (variable_get('responsive_menu_superfish', TRUE)) {
    libraries_load('superfish');
  }
  libraries_load('mmenu');
  if (variable_get('responsive_menu_hammer', FALSE)) {
    libraries_load('hammerjs');
  }
  $page['content']['#attached']['js'][] = array(
    'data' => drupal_get_path('module', 'responsive_menu') . '/js/responsive_menu.config.js',
    'type' => 'file',
    'scope' => 'footer',
    'group' => JS_THEME,
    'weight' => 20,
  );
  module_load_include('inc', 'responsive_menu', 'includes/responsive_menu.menu');
  $output = responsive_menu_tree_output($menu_tree, $menu_name);
  $output['#id'] = 'off-canvas-menu';
  $page['page_bottom']['off_canvas'] = array(
    '#prefix' => '<div class="off-canvas-wrapper"><div id="off-canvas">',
    '#suffix' => '</div></div>',
    '#markup' => drupal_render($output),
  );
}