You are here

mobile_navigation.module in Mobile Navigation 8

Same filename and directory in other branches
  1. 7.2 mobile_navigation.module
  2. 7 mobile_navigation.module

Mobile Navigation primary module file.

File

mobile_navigation.module
View source
<?php

/**
 * @file
 * Mobile Navigation primary module file.
 */

/* defaults */
define('MOBILE_NAVIGATION_BREAKPOINT', 'all and (min-width: 740px) and (min-device-width: 740px), (max-device-width: 800px) and (min-width: 740px) and (orientation:landscape)');
define('MOBILE_NAVIGATION_MENUSELECTOR', '#main-menu-links');
define('MOBILE_NAVIGATION_PLUGIN', 'basic');
define('MOBILE_NAVIGATION_SHOWEFFECT', 'expand_down');
define('MOBILE_NAVIGATION_SHOWITEMS', 'all');
define('MOBILE_NAVIGATION_TABHANDLER', TRUE);
define('MOBILE_NAVIGATION_WIDTH', 65);
define('MOBILE_NAVIGATION_SPECIAL_CLASSES', FALSE);
define('MOBILE_NAVIGATION_PAGESELECTOR', '#page');
define('MOBILE_NAVIGATION_USE_MASK', TRUE);
define('MOBILE_NAVIGATION_MENU_LABEL', 'Menú');
define('MOBILE_NAVIGATION_EXPAND_ACTIVE_TRAIL', FALSE);

/**
 * Helper function for getting Mobile navigation effects.
 */
function mobile_navigation_get_effects() {
  return array(
    'expand_down' => t('Expand Down right where the menu button is located.'),
    'fixed_top' => t('Top Fixed: Menu shows up over the document, comming from the top.'),
    'fixed_left' => t('Left Fixed: Menu shows up over the document, comming from the left.'),
    'fixed_right' => t('Right Fixed: Menu shows up over the document, comming from the right.'),
    'fixed_bottom' => t('Bottom Fixed: Menu shows up over the document, comming from the bottom.'),
    'drawer_left' => t('Left Drawer: Menu shows up pushing the document, comming from the left.'),
    'drawer_right' => t('Right Drawer: Menu shows up pushing the document, comming from the right.'),
    'drawer_top' => t('Top Drawer: Menu shows up pushing down the document, comming from the top.'),
  );
}

/**
 * Helper function for getting Mobile navigation plugin options.
 */
function mobile_navigation_get_plugins() {
  return array(
    'basic' => t('<strong>Basic:</strong> Simply slide showing the menu, without any special behavior on its contents.'),
    'accordion' => t('<strong>Accordion:</strong> Show menu and its submenus in a organized accordion structure. (Aplies only when the markup for the complete menu is displayed, including submenus.)'),
    'slideMenu' => t('<strong>Slide Menu to the left:</strong> Show submenus using a slide effect when opening submenus. Only current submenu items are shown, with a go back option at the top.'),
  );
}

/**
 * Implements hook_premission().
 */
function mobile_navigation_permission() {
  return array(
    'administer mobile navigation' => array(
      'title' => t('administer mobile navigation'),
      'description' => t('Administer mobile navigation.'),
    ),
  );
}

/**
 * Implements hook_page_build().
 */
function mobile_navigation_page_build() {
  global $theme_key;
  $current_theme = variable_get('theme_default', 'none');
  if ($current_theme == $theme_key) {
    drupal_add_js(drupal_get_path('module', 'mobile_navigation') . '/js/mobile_menu.js', array(
      'preprocess' => FALSE,
    ));
    drupal_add_js(drupal_get_path('module', 'mobile_navigation') . '/mobile_navigation.js', array(
      'preprocess' => FALSE,
    ));
    drupal_add_css(drupal_get_path('module', 'mobile_navigation') . '/mobile_navigation.css');
    $settings = array(
      'breakpoint' => variable_get('mobile_navigation_breakpoint', MOBILE_NAVIGATION_BREAKPOINT),
      'menuSelector' => variable_get('mobile_navigation_menuselector', MOBILE_NAVIGATION_MENUSELECTOR),
      'menuPlugin' => variable_get('mobile_navigation_plugin', MOBILE_NAVIGATION_PLUGIN),
      'showEffect' => variable_get('mobile_navigation_showEffect', MOBILE_NAVIGATION_SHOWEFFECT),
      'showItems' => variable_get('mobile_navigation_showitems', MOBILE_NAVIGATION_SHOWITEMS),
      'tabHandler' => variable_get('mobile_navigation_tabhandler', MOBILE_NAVIGATION_TABHANDLER),
      'menuWidth' => variable_get('mobile_navigation_width', MOBILE_NAVIGATION_WIDTH),
      'specialClasses' => variable_get('mobile_navigation_special_classes', MOBILE_NAVIGATION_SPECIAL_CLASSES),
      'mainPageSelector' => variable_get('mobile_navigation_mainPageSelector', MOBILE_NAVIGATION_PAGESELECTOR),
      'useMask' => variable_get('mobile_navigation_useMask', MOBILE_NAVIGATION_USE_MASK),
      'menuLabel' => t(variable_get('mobile_navigation_menu_label', MOBILE_NAVIGATION_MENU_LABEL)),
      'expandActive' => variable_get('mobile_navigation_expand_active_trail', MOBILE_NAVIGATION_EXPAND_ACTIVE_TRAIL),
    );
    drupal_add_js(array(
      'mobile_navigation' => $settings,
    ), 'setting');
  }
}

/**
 * Implements hook_menu().
 */
function mobile_navigation_menu() {
  $items['admin/config/user-interface/mobile-navigation'] = array(
    'title' => 'Mobile Navigation',
    'description' => 'Mobile Navigation configuration.',
    'page callback' => 'drupal_get_form',
    'page arguments' => array(
      'mobile_navigation_configuration_form',
    ),
    'access arguments' => array(
      'administer mobile navigation',
    ),
    'file' => 'mobile_navigation.admin.inc',
  );
  return $items;
}