Index: jump.info
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/jump/jump.info,v
retrieving revision 1.1.4.2
diff -u -p -r1.1.4.2 jump.info
--- jump.info	11 Jul 2008 22:41:07 -0000	1.1.4.2
+++ jump.info	19 Jan 2011 08:09:41 -0000
@@ -2,3 +2,4 @@
 name = "Jump"
 description = "Turns a menu into a pick list"
 core = 6.x
+dependencies[] = ahah_helper
Index: jump.install
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/jump/Attic/jump.install,v
retrieving revision 1.1.2.2
diff -u -p -r1.1.2.2 jump.install
--- jump.install	29 Sep 2009 20:34:02 -0000	1.1.2.2
+++ jump.install	19 Jan 2011 08:09:41 -0000
@@ -2,10 +2,30 @@
 // $Id: jump.install,v 1.1.2.2 2009/09/29 20:34:02 marcp Exp $
 
 /**
+ * Utility function to deletes a set of variables set by a module.
+ *
+ * @global array $conf
+ * @param string $name 
+ *   The variables' namespace for which to delete.
+ */
+function _jump_variable_del_all($name) {
+  global $conf;
+  db_query("DELETE FROM {variable} WHERE name LIKE '%s%%'", $name);
+  cache_clear_all('variables', 'cache');
+  unset($conf[$name]);
+}
+
+/**
  * Implementation of hook_uninstall().
  */
 function jump_uninstall() {
-  db_query("DELETE from {variable} WHERE name LIKE 'jump_activepageinmenu%'");
+  // normally we would delete all in one swoop like ...del_all('jump_') but I 
+  // fear the possibility of deleting other modules' settings who may use the
+  // word jump at the beginning of their names.
+  _jump_variable_del_all('jump_activepageinmenu');
+  _jump_variable_del_all('jump_use_js_');
+  _jump_variable_del_all('jump_add_select_');
+  _jump_variable_del_all('jump_add_select_text_');
 }
 
 /**
Index: jump.js
===================================================================
RCS file: jump.js
diff -N jump.js
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ jump.js	19 Jan 2011 08:09:41 -0000
@@ -0,0 +1,17 @@
+// $Id$
+Drupal.behaviors.jumpJumpOnClick = function(context) {
+  // Match "<protocol>://".
+  var protocol_re = /^[a-z]+:\/\/.*/;
+  // We watch the whole select field here because ie and safari do not do
+  // well with binding click handlers on option elements.
+  $('form.jump-quickly.js-enabled select').change(function() {
+    // Don't jump if clicking on the title option, when enabled.
+    if ($(this).hasClass('first-no-jump') && $('option:selected:first-child', this).attr('value') == '') return false;
+    // Create destination,
+    //   if it is an absolute url use as is
+    //   else concatenate base path and value.
+    var dest = (protocol_re.test(dest)) ? $(this).attr('value') : Drupal.settings.basePath + $(this).attr('value');
+    window.location = dest;
+    return false;
+  });
+};
Index: jump.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/jump/jump.module,v
retrieving revision 1.1.4.5
diff -u -p -r1.1.4.5 jump.module
--- jump.module	30 Oct 2009 22:08:19 -0000	1.1.4.5
+++ jump.module	19 Jan 2011 08:09:42 -0000
@@ -8,6 +8,13 @@
  */
 
 /**
+ * Implementation of hook_init().
+ */
+function jump_init() {
+  drupal_add_js(drupal_get_path('module', 'jump') . '/jump.js');
+}
+
+/**
  * Implementation of hook_menu().
  */
 function jump_menu() {
@@ -44,61 +51,70 @@ function jump_settings() {
  * Implementation of hook_block().
  */
 function jump_block($op = 'list', $delta = 0, $edit = array()) {
-  if ($op == 'list') {
-    $blocks = array();
-    foreach (menu_get_menus() as $name => $title) {
-      $blocks['menu-'. $name] = array(
-        'info' => t('Jump menu: !menu', array('!menu' => $name))
-      );
-    }
-
-    $vocs = taxonomy_get_vocabularies();
-    foreach ($vocs as $vid => $vocabulary) {
-      $blocks['taxo-'. $vid] = array(
-        'info' => t('Jump menu: !voc', array('!voc' => $vocabulary->name))
+  switch ($op):
+    case 'list':
+      $blocks = array();
+      foreach (menu_get_menus() as $name => $title) {
+        $blocks['menu-'. $name] = array(
+          'info' => t('Jump menu: !menu', array('!menu' => $name))
+        );
+      }
+
+      $vocs = taxonomy_get_vocabularies();
+      foreach ($vocs as $vid => $vocabulary) {
+        $blocks['taxo-'. $vid] = array(
+          'info' => t('Jump menu: !voc', array('!voc' => $vocabulary->name))
+        );
+      }
+      return $blocks;
+    case 'configure':
+      $form = array();
+      $form['block_settings']['jump_activepageinmenu_'. $delta] = array(
+        '#type' => 'checkbox',
+        '#title' => t('Show active page in jump menu.'),
+        '#default_value' => variable_get('jump_activepageinmenu_'. $delta, 1),
+        '#description' => t('This setting will force the jump menu to show the current page as the default selection in this block\'s jump menu.'),
       );
-    }
-    return $blocks;
-  }
-  else if ($op == 'view') {
-    // The first 5 characters of $delta should be one of:
-    //    menu-
-    //    taxo-
-    $subject = '';
-    $jumpmenu_type = substr($delta, 0, 4);
-    $jumpmenu_name = substr($delta, 5);
-    $active = jump_get_active_setting($delta);
-    if ($jumpmenu_type == 'menu') {
-      $form = jump_quickly($jumpmenu_name, 'menu', $active);
-
-      // Use the menu label as the default block subject
-      $menus = menu_get_menus();
-      $subject = $menus[$jumpmenu_name];
-    }
-    else if ($jumpmenu_type == 'taxo') {
-      $form = jump_quickly($jumpmenu_name, 'taxo', $active);
-
-      // Use the vocabulary name as the default block subject
-      $vocab = taxonomy_vocabulary_load($jumpmenu_name);
-      $subject = $vocab->name;
-    }
-
-    return array('subject' => $subject, 'content' => $form);
-  }
-  else if ($op == 'configure') {
-    $form = array();
-    $form['jump_activepageinmenu_'. $delta] = array(
-      '#type' => 'checkbox',
-      '#title' => t('Show active page in jump menu.'),
-      '#default_value' => variable_get('jump_activepageinmenu_'. $delta, 1),
-      '#description' => t('This setting will force the jump menu to show the current page as the default selection in this block\'s jump menu.'),
-    );
-    return $form;
-  }
-  else if ($op == 'save') {
-    variable_set('jump_activepageinmenu_'. $delta, $edit['jump_activepageinmenu_'. $delta]);
-    return;
-  }
+      // Do the rest of the form additions in hook_form_alter() since we can't do ahah here.
+      return $form;
+    case 'save':
+      variable_set('jump_activepageinmenu_' . $delta, $edit['jump_activepageinmenu_'. $delta]);
+      variable_set('jump_use_js_' . $delta, $edit['jump_use_js_' . $delta]);
+      variable_set('jump_add_select_' . $delta, $edit['jump_add_select_' . $delta]);
+      variable_set('jump_add_select_text_' . $delta, $edit['jump_add_select_text_' . $delta]);
+      break;
+    case 'delete':
+      variable_del('jump_activepageinmenu_' . $delta);
+      variable_del('jump_use_js_' . $safe_delta);
+      variable_del('jump_add_select_' . $safe_delta);
+      variable_del('jump_add_select_text_' . $safe_delta);
+      break;
+    case 'view':
+      // The first 5 characters of $delta should be one of:
+      //    menu-
+      //    taxo-
+      $subject = '';
+      $jumpmenu_type = substr($delta, 0, 4);
+      $jumpmenu_name = substr($delta, 5);
+      $active = jump_get_active_setting($delta);
+      if ($jumpmenu_type == 'menu') {
+        $form = jump_quickly($jumpmenu_name, 'menu', $active);
+
+        // Use the menu label as the default block subject
+        $menus = menu_get_menus();
+        $subject = $menus[$jumpmenu_name];
+      }
+      else if ($jumpmenu_type == 'taxo') {
+        $form = jump_quickly($jumpmenu_name, 'taxo', $active);
+
+        // Use the vocabulary name as the default block subject
+        $vocab = taxonomy_vocabulary_load($jumpmenu_name);
+        $subject = $vocab->name;
+      }
+
+      return array('subject' => $subject, 'content' => $form);
+      break;
+  endswitch;
 }
 
 /**
@@ -113,9 +129,15 @@ function jump_block($op = 'list', $delta
  * be an array that contains the options.
  */
 function jump_quickly($name = 'navigation', $type = 'menu', $active = -1) {
+  // Reconstruct the $delta
+  $delta = $type . '-' . $name;
   if ($active === -1) {
     $active = variable_get('jump_activepageinmenu', 1);
   }
+  $menu_state = array(
+    'delta' => $delta,
+    'active' => $active,
+  );
 
   if (is_array($name)) {
     $options = $name;
@@ -125,7 +147,7 @@ function jump_quickly($name = 'navigatio
     if ($type == 'menu') {
       jump_menu_get_menu_options($options, $name);
     }
-    else if ($type = 'taxo') {
+    else if ($type == 'taxo') {
       jump_menu_get_taxo_options($options, $name);
     }
   }
@@ -135,12 +157,12 @@ function jump_quickly($name = 'navigatio
   static $num_jump_forms = 0;
   $num_jump_forms++;
 
-  return drupal_get_form('jump_quickly_form_'. $num_jump_forms, $options, $active);
+  return drupal_get_form('jump_quickly_form_' . $num_jump_forms, $options, $menu_state);
 }
 
-function jump_quickly_form(&$form_state, $options, $active) {
+function jump_quickly_form(&$form_state, $options, $menu_state) {
   $default = '';
-  if ($active) {
+  if ($menu_state['active'] === 1) {
     if (isset($options[$_GET['q']])) {
       $default = $_GET['q'];
     }
@@ -159,6 +181,20 @@ function jump_quickly_form(&$form_state,
     '#type' => 'submit',
     '#value' => t('Go')
   );
+  if (variable_get('jump_use_js_' . $menu_state['delta'], 0) === 1) {
+    // Give each menu a unique name.
+    $form['#attributes']['name'] = 'jumpquickly' . $menu_state['delta'];
+    $form['#attributes']['class'] .= ' js-enabled';
+    unset($form['submit']);
+    if (variable_get('jump_add_select_' . $menu_state['delta'], 0) === 1) {
+      $form['jump_goto']['#attributes']['class'] = 'first-no-jump';
+      // Add the extra empty select option to the top of the array.
+      $options = array_reverse($form['jump_goto']['#options'], TRUE);
+      $options[''] = variable_get('jump_add_select_text_' . $menu_state['delta'], t('Select Option'));
+      $form['jump_goto']['#options'] = array_reverse($options, TRUE);
+      $form['jump_goto']['#default_value'] = (array_key_exists($default, $options)) ? $default : '';
+    }
+  }
 
   return $form;
 }
@@ -180,9 +216,11 @@ function theme_jump_quickly_form($form) 
 
 function jump_menu_get_menu_options(&$options, $name) {
   $tree = menu_tree_page_data($name);
+  $front = variable_get('site_frontpage', 'node');
   foreach ($tree as $data) {
     if (!$data['link']['hidden']) {
-      $options[$data['link']['href']] = $data['link']['title'];
+      $href = ($data['link']['href'] == '<front>') ? $front : $data['link']['href'];
+      $options[$href] = $data['link']['title'];
     }
   }
 }
@@ -221,12 +259,75 @@ function jump_theme() {
 }
 
 /**
+ * Implementation of hook_form_alter().
+ *   We add in all our ahah sensitive block settings here since they can't be
+ *   added via hook_block().
+ * @param array $form
+ * @param array $form_state
+ * @param string $form_id
+ */
+function jump_form_alter(&$form, $form_state, $form_id) {
+  switch ($form_id) {
+    case 'block_admin_configure':
+      if ($form['module']['#value'] === 'jump' && function_exists('ahah_helper_register')) {
+        $delta = $form['delta']['#value'];
+        ahah_helper_register($form, $form_state);
+        $default_jump_use_js = (!isset($form_state['storage']['jump_use_js_' . $delta])) ? variable_get('jump_use_js_' . $delta, 0) : $form_state['storage']['jump_use_js_' . $delta];
+        $default_jump_add_select = (!isset($form_state['storage']['jump_add_select_' . $delta])) ? variable_get('jump_add_select_' . $delta, 0) : $form_state['storage']['jump_add_select_' . $delta];
+
+        $form['block_settings']['jump_use_js_' . $delta] = array(
+          '#type' => 'checkbox',
+          '#title' => t('Hide the submit button and use Javascript to automatically jump to the selected menu item'),
+          '#default_value' => $default_jump_use_js,
+          '#ahah' => array(
+            'event' => 'change',
+            'path' => ahah_helper_path(array('block_settings', 'jump_dependent')),
+            'wrapper' => 'jump-dependent',
+          ),
+        );
+        $form['block_settings']['jump_dependent'] = array(
+          '#prefix' => '<div id="jump-dependent">',
+          '#suffix' => '</div>',
+          '#type' => 'fieldset'
+        );
+        $form['block_settings']['jump_dependent']['jump_dependent2'] = array(
+          '#prefix' => '<div id="jump-dependent2">',
+          '#suffix' => '</div>',
+          '#type' => 'fieldset',
+          '#weight' => 2
+        );
+        if ($default_jump_use_js === 1) {
+          $form['block_settings']['jump_dependent']['jump_add_select_' . $delta] = array(
+            '#type' => 'checkbox',
+            '#title' => t('Add an empty select option into the list of options'),
+            '#default_value' => $default_jump_add_select,
+            '#weight' => 1,
+            '#ahah' => array(
+              'event' => 'change',
+              'path' => ahah_helper_path(array('block_settings', 'jump_dependent', 'jump_dependent2')),
+              'wrapper' => 'jump-dependent2',
+            ),
+          );
+          if ($default_jump_add_select === 1) {
+            $form['block_settings']['jump_dependent']['jump_dependent2']['jump_add_select_text_' . $delta] = array(
+              '#type' => 'textfield',
+              '#title' => t('Text to use for the empty select option'),
+              '#default_value' => variable_get('jump_add_select_text_' . $delta, t('Select Option'))
+            );
+          }
+        }
+      }
+      break;
+  }
+}
+
+/**
  * For the given block delta, get the setting that determines whether
  * or not to show the active page as the default value for the jump menu.
  */
 function jump_get_active_setting($delta) {
   $active_site_default = variable_get('jump_activepageinmenu', 1);
-  $active = variable_get('jump_activepageinmenu_'. $delta, $active_site_default);
+  $active = variable_get('jump_activepageinmenu_' . $delta, $active_site_default);
   return $active;
 }
 
