Index: nice_menus.js
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/nice_menus/nice_menus.js,v
retrieving revision 1.16
diff -u -p -r1.16 nice_menus.js
--- nice_menus.js 4 Aug 2008 23:45:22 -0000 1.16
+++ nice_menus.js 18 Dec 2008 01:43:01 -0000
@@ -1,5 +1,7 @@
// $Id: nice_menus.js,v 1.16 2008/08/04 23:45:22 add1sun Exp $
+// Minimal JavaScript needed to get IE 6 to function properly.
+
// We need to do some browser sniffing to weed out IE 6 only
// because only IE6 needs this hover hack.
if (document.all && !window.opera && (navigator.appVersion.search("MSIE 6.0") != -1) && $.browser.msie) {
Index: nice_menus.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/nice_menus/nice_menus.module,v
retrieving revision 1.54
diff -u -p -r1.54 nice_menus.module
--- nice_menus.module 4 Dec 2008 00:42:49 -0000 1.54
+++ nice_menus.module 18 Dec 2008 01:43:02 -0000
@@ -83,18 +83,50 @@ function nice_menus_menu() {
* Settings form as implemented by hook_menu
*/
function nice_menus_admin_settings() {
+ // Create JavaScript options.
+ $js_options = array(
+ 'none' => t('None'),
+ 'minimal' => t('Minimal (IE 6 compatiblity)'),
+ 'full' => t('Full (Superfish)'),
+ );
+
$form['nice_menus_number'] = array(
'#type' => 'textfield',
'#description' => t('The total number of independent Nice menus blocks you want. Enter a number between 0 and 99. If you set this to 0, you will have no blocks created but you can still use the Nice menus theme functions directly in your theme.'),
'#default_value' => variable_get('nice_menus_number', '2'),
'#size' => 2,
);
- $form['nice_menus_ie'] = array(
- '#type' => 'checkbox',
- '#title' => t('Enable IE support'),
- '#description' => t('This will add necessary JavaScript for Nice menus to work properly in Internet Explorer.'),
- '#default_value' => variable_get('nice_menus_ie', 1),
+ $form['nice_menus_js'] = array(
+ '#type' => 'radios',
+ '#title' => t('Select the level of JavaScript that Nice menus will use'),
+ '#description' => t('None: no JavaScript will be added. Internet Explorer 6 will not work properly.
Minimal: adds the minimal necessary JavaScript for Nice Menus to work properly in Internet Explorer 6. Other browsers will use CSS-only menus.
Full: adds JavaScript Superfish effects to all browsers in addition to the minimal needed for Internet Explorer 6.'),
+ '#default_value' => variable_get('nice_menus_js', 'full'),
+ '#options' => $js_options,
+ );
+ $form['nice_menus_sf_options'] = array(
+ '#type' => 'fieldset',
+ '#title' => t('Advanced: Superfish options'),
+ '#description' => t('You can change the default Superfish options by filling out the desired values here. these only take effect if your JavaScript settings are set to "Full (Superfish)" above.'),
+ '#collapsible' => TRUE,
+ '#collapsed' => TRUE,
+ );
+ $form['nice_menus_sf_options']['nice_menus_sf_delay'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Mouse delay'),
+ '#description' => t('The delay in milliseconds that the mouse can remain outside a submenu without it closing.'),
+ '#default_value' => variable_get('nice_menus_sf_delay', 800),
+ '#size' => 5,
+ );
+ $form['nice_menus_sf_options']['nice_menus_sf_speed'] = array(
+ '#type' => 'select',
+ '#title' => t('Animation speed'),
+ '#multiple' => FALSE,
+ '#description' => t('Speed of the menu open/close animation.'),
+ '#options' => array(t('slow'), t('normal'), t('fast')),
+ '#default_value' => variable_get('nice_menus_sf_speed', 1),
);
+
+
// Custom validation to make sure the user is entering numbers.
$form['#validate'][] = 'nice_menus_settings_validate';
@@ -231,9 +263,22 @@ function nice_menus_theme() {
* and the menus are unstyled.
*/
function nice_menus_init() {
- // Add JavaScript, if enabled.
- if (variable_get('nice_menus_ie', 1) == 1) {
+ // Add minimal JavaScript, if any JavaScript is enabled.
+ if (variable_get('nice_menus_js', 'full') != 'none') {
drupal_add_js(drupal_get_path('module', 'nice_menus') .'/nice_menus.js');
+ // Add Superfish JavaScript if full JS is enabled.
+ if (variable_get('nice_menus_js', 'full') == 'full') {
+ // The script, from http://users.tpg.com.au/j_birch/plugins/superfish.
+ drupal_add_js(drupal_get_path('module', 'nice_menus') .'/superfish/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),
+ )),'setting');
+ // The Nice menus implementation.
+ drupal_add_js(drupal_get_path('module', 'nice_menus') .'/nice_menus_superfish.js');
+ }
}
// Add main CSS functionality.
Index: nice_menus_superfish.js
===================================================================
RCS file: nice_menus_superfish.js
diff -N nice_menus_superfish.js
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ nice_menus_superfish.js 18 Dec 2008 01:43:02 -0000
@@ -0,0 +1,19 @@
+// $Id:$
+
+// This uses Superfish 1.4.8
+// (http://users.tpg.com.au/j_birch/plugins/superfish)
+// TODO: make options configurable through Drupal settings.
+
+// Add Superfish to all Nice menus with some basic options.
+$(document).ready(function() {
+ $('ul.nice-menu').superfish({
+ // Disable generation of arrow mark-up.
+ autoArrows: false,
+ // Disable drop shadows.
+ dropShadows: false,
+ // Mouse delay.
+ delay: Drupal.settings.nice_menus_options.delay,
+ // Animation speed.
+ speed: Drupal.settings.nice_menus_options.speed
+ });
+});
\ No newline at end of file