You are here

function responsive_menu_page_build in Responsive and off-canvas menu 7.2

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

Implements hook_page_build().

File

./responsive_menu.module, line 277

Code

function responsive_menu_page_build(&$page) {
  if (path_is_admin(current_path())) {
    return;
  }
  module_load_include('inc', 'responsive_menu', 'includes/responsive_menu.menu');
  $off_canvas_menus = variable_get('responsive_menu_off_canvas_menus', 'main-menu');

  // Allow other modules to modify this configuration.
  drupal_alter('responsive_menu_off_canvas_menu_names', $off_canvas_menus);
  $menus = explode(',', $off_canvas_menus);
  $menu_tree = array();
  foreach ($menus as $menu_name) {
    $tree = responsive_menu_tree_block_data(trim($menu_name));
    $menu_tree = array_merge($menu_tree, $tree);
  }

  // Allow this merged menu tree to be altered.
  drupal_alter('responsive_menu_off_canvas_tree', $menu_tree);
  if (function_exists('libraries_load')) {

    // Load the superfish library.
    if (variable_get('responsive_menu_superfish', TRUE)) {

      // Determine whether to load hoverintent or not. The default is to include
      // it with superfish.
      if (variable_get('responsive_menu_superfish_hoverintent', TRUE)) {
        libraries_load('superfish', 'minified');
      }
      else {
        libraries_load('superfish', 'minified_no_hoverintent');
      }
    }
    libraries_load('mmenu');
    if (variable_get('responsive_menu_hammer', FALSE)) {
      libraries_load('hammerjs');
    }
    $page['page_bottom']['#attached']['js'][] = array(
      'data' => drupal_get_path('module', 'responsive_menu') . '/js/responsive_menu.config.js',
      'type' => 'file',
      'scope' => 'footer',
      'group' => JS_THEME,
      'weight' => 20,
    );
  }

  // Choose the first menu as the menu name.
  $menu_name = reset($menus);
  $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),
  );
}