diff -urpN /home/domas/tmp/nice_menus/nice_menus.module ./nice_menus.module --- /home/domas/tmp/nice_menus/nice_menus.module 2008-09-17 21:17:28.000000000 +0300 +++ ./nice_menus.module 2008-10-18 11:10:03.000000000 +0300 @@ -150,10 +150,16 @@ function nice_menus_block($op = 'list', ); $form['nice_menus_type_'. $delta] = array( '#type' => 'select', - '#title' => t('Menu Style'), - '#description' => t('right: menu items are listed on top of each other and expand to the right') .'
'. t('left: menu items are listed on top of each other and expand to the left') .'
'. t('down: menu items are listed side by side and expand down'), + '#title' => t('Menu Tye'), + '#description' => t('right: menu items are listed on top of each other and expand to the right') .'
'. + t('left: menu items are listed on top of each other and expand to the left') .'
'. + t('down: menu items are listed side by side and expand down') .'
'. + t('superfish-* menu types are only available if you have extracted superfish script to a superfish folder in the nice_menu module folder', array('@url' => 'http://users.tpg.com.au/j_birch/plugins/superfish/')), '#default_value' => variable_get('nice_menus_type_'. $delta, 'right'), - '#options' => drupal_map_assoc(array('right', 'left', 'down')), + '#options' => drupal_map_assoc(array( + 'right', 'left', 'down', + 'superfish-horizontal', 'superfish-vertical', 'superfish-navbar') + ), ); return $form; break; @@ -168,9 +174,9 @@ function nice_menus_block($op = 'list', case 'view': // Build the nice menu for the block. list($menu_name, $mlid) = explode(':', variable_get('nice_menus_menu_'. $delta, 'navigation:0')); - $direction = variable_get('nice_menus_type_'. $delta, 'right'); + $type = variable_get('nice_menus_type_'. $delta, 'right'); $depth = variable_get('nice_menus_depth_'.$delta, '-1'); - if ($output = theme('nice_menu', $delta, $menu_name, $mlid, $direction, $depth)) { + if ($output = theme('nice_menu', $delta, $menu_name, $mlid, $type, $depth)) { $block['content'] = $output['content']; if (variable_get('nice_menus_type_'. $delta, 'right') == 'down') { $class = 'nice-menu-hide-title'; @@ -208,16 +214,16 @@ function nice_menus_theme() { 'arguments' => array('menu' => NULL, 'depth' => -1), ), 'nice_menu' => array( - 'arguments' => array('id' => NULL, 'menu_name' => NULL, 'mlid' => NULL, 'direction' => 'right', 'depth' => -1, 'menu' => NULL), + 'arguments' => array('id' => NULL, 'menu_name' => NULL, 'mlid' => NULL, 'type' => 'right', 'depth' => -1, 'menu' => NULL), ), 'nice_menu_primary_links' => array( - 'arguments' => array('direction' => 'down', 'menu' => NULL), + 'arguments' => array('type' => 'down', 'menu' => NULL), ), 'nice_menu' => array( - 'arguments' => array('id' => NULL, 'pid' => NULL, 'direction' => 'right', 'menu' => NULL), + 'arguments' => array('id' => NULL, 'pid' => NULL, 'type' => 'right', 'menu' => NULL), ), 'nice_menu_primary_links' => array( - 'arguments' => array('direction' => 'down', 'depth' => -1, 'menu' => NULL), + 'arguments' => array('type' => 'down', 'depth' => -1, 'menu' => NULL), ), ); } @@ -229,6 +235,8 @@ function nice_menus_theme() { * because when block caching is enabled none of it would get fired * and the menus are unstyled. */ +/* Should not be needed as the caching for nice_menu block is disabled */ +/* function nice_menus_init() { // Add JavaScript, if enabled. if (variable_get('nice_menus_ie', 1) == 1) { @@ -246,6 +254,7 @@ function nice_menus_init() { drupal_add_css(drupal_get_path('module', 'nice_menus') .'/nice_menus_default.css'); } } +*/ /** * Builds the final nice menu. @@ -363,7 +372,7 @@ function theme_nice_menu_build($menu, $d * The top parent menu name from which to build the full menu. * @param $mlid * The menu ID from which to build the displayed menu. - * @param $direction + * @param $type * Optional. The direction the menu expands. Default is 'right'. * @param $menu * Optional. A custom menu array to use for theming -- @@ -372,12 +381,53 @@ function theme_nice_menu_build($menu, $d * @return * An HTML string of nice menu links. */ -function theme_nice_menu($id, $menu_name, $mlid, $direction = 'right', $depth = -1, $menu = NULL) { +function theme_nice_menu($id, $menu_name, $mlid, $type = 'right', $depth = -1, $menu = NULL) { + $classes = ''; + $type_exploded = explode('-', $type); + if ($type_exploded[0] == 'superfish') { + drupal_add_css(drupal_get_path('module', 'nice_menus') .'/superfish/css/superfish.css'); + drupal_add_js(drupal_get_path('module', 'nice_menus') .'/superfish/js/hoverIntent.js'); + drupal_add_js(drupal_get_path('module', 'nice_menus') .'/superfish/js/supersubs.js'); + drupal_add_js(drupal_get_path('module', 'nice_menus') .'/superfish/js/superfish.js'); + $classes .= " sf-menu"; + switch ($type_exploded[1]) { + case 'vertical': + drupal_add_css(drupal_get_path('module', 'nice_menus') .'/superfish/css/superfish-vertical.css'); + $classes .= " sf-vertical"; + break; + case 'navbar': + drupal_add_css(drupal_get_path('module', 'nice_menus') .'/superfish/css/superfish-navbar.css'); + $classes .= " sf-navbar"; + break; + } + $superfish = "jQuery(function(){jQuery('ul.sf-menu').supersubs({minWidth: 12, maxWidth: 27, extraWidth: 1}).superfish();});"; + drupal_add_js($superfish, $type="inline"); + } + + else { + $classes .= ' nice-menu nice-menu-'. $type; + // Add JavaScript, if enabled. + if (variable_get('nice_menus_ie', 1) == 1) { + drupal_add_js(drupal_get_path('module', 'nice_menus') .'/nice_menus.js'); + } + + // Add main CSS functionality. + drupal_add_css(drupal_get_path('module', 'nice_menus') .'/nice_menus.css'); + // Add custom CSS layout if specified. + if ($custom = variable_get('nice_menus_custom_css', '')) { + drupal_add_css($custom); + } + // Fall back to default layout. + else { + drupal_add_css(drupal_get_path('module', 'nice_menus') .'/nice_menus_default.css'); + } + } $output = array(); if ($menu_tree = theme('nice_menu_tree', $menu_name, $mlid, $depth, $menu)) { if ($menu_tree['content']) { - $output['content'] = ''."\n"; + #TODO: pakeisti + $output['content'] = ''."\n"; $output['subject'] = $menu_tree['subject']; } } @@ -387,7 +437,7 @@ function theme_nice_menu($id, $menu_name /** * Theme primary links as nice menus * - * @param $direction + * @param $type * Optional. The direction the menu expands. Default is 'down'. * @param $menu * Optional. A custom menu array to use for theming -- @@ -396,8 +446,8 @@ function theme_nice_menu($id, $menu_name * @return * An HTML string of nice menu primary links. */ -function theme_nice_menu_primary_links($direction = 'down', $depth = -1, $menu = NULL) { +function theme_nice_menu_primary_links($type = 'down', $depth = -1, $menu = NULL) { $menu_name = variable_get('menu_primary_links_source', 'primary-links'); - $output = theme('nice_menu', 0, $menu_name, 0, $direction, $depth, $menu); + $output = theme('nice_menu', 0, $menu_name, 0, $type, $depth, $menu); return $output['content']; } diff -urpN /home/domas/tmp/nice_menus/README.txt ./README.txt --- /home/domas/tmp/nice_menus/README.txt 2007-10-29 18:38:28.000000000 +0200 +++ ./README.txt 2008-10-18 11:17:14.000000000 +0300 @@ -21,6 +21,8 @@ Installation 5. Return to the blocks page and enable the nice menus block(s), e.g. 'Nice Menu 1 (Nice Menu)' by putting it in a region. 6. See below sections on Customization and Advanced Theming as well as the handbook page (http://drupal.org/node/185543) for more tips. +NOTE: if you want to use Superfish enhaced menus you have to extract Superfish script to a superfish folder in the nice_menu module folder. The script as well as some examples of usage are available at http://users.tpg.com.au/j_birch/plugins/superfish/. + Upgrade ------- Please read the UPGRADE.txt file for upgrade information.