You are here

function nice_menus_init in Nice Menus 6.2

Same name and namespace in other branches
  1. 6 nice_menus.module \nice_menus_init()
  2. 7.2 nice_menus.module \nice_menus_init()

Implements hook_init().

We are adding the JavaScript and CSS here rather than theme_nice_menu because when block caching is enabled none of it would get fired and the menus are unstyled.

File

./nice_menus.module, line 87
Module to enable CSS dropdown and flyout menus.

Code

function nice_menus_init() {

  // Add Superfish JavaScript, if enabled.
  if (variable_get('nice_menus_js', 1) == 1) {

    // The script, from http://users.tpg.com.au/j_birch/plugins/superfish.
    drupal_add_js(drupal_get_path('module', 'nice_menus') . '/js/superfish.js');

    // Add the Superfish options variables.
    drupal_add_js(array(
      'nice_menus_options' => array(
        'delay' => variable_get('nice_menus_sf_delay', 800),
        'speed' => variable_get('nice_menus_sf_speed', 1),
        'hover_intent' => variable_get('nice_menus_hover_intent', 1),
      ),
    ), 'setting');

    // Add the bgIframe plugin.
    drupal_add_js(drupal_get_path('module', 'nice_menus') . '/js/jquery.bgiframe.min.js');

    // Add the HoverIntent plugin.
    drupal_add_js(drupal_get_path('module', 'nice_menus') . '/js/jquery.hoverIntent.minified.js');

    // The Nice menus implementation.
    drupal_add_js(drupal_get_path('module', 'nice_menus') . '/js/nice_menus.js');
  }

  // Add main CSS functionality.
  drupal_add_css(drupal_get_path('module', 'nice_menus') . '/css/nice_menus.css');

  // Add custom CSS layout if specified.
  if ($custom = variable_get('nice_menus_custom_css', '')) {
    drupal_add_css($custom);
  }
  else {
    drupal_add_css(drupal_get_path('module', 'nice_menus') . '/css/nice_menus_default.css');
  }
}