Index: jquery_update.inc
===================================================================
RCS file: jquery_update.inc
diff -N jquery_update.inc
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ jquery_update.inc	27 Jun 2010 17:05:48 -0000
@@ -0,0 +1,132 @@
+<?php
+// $Id$
+
+/**
+ * @file
+ * Helper functions
+ */
+
+/**
+ * Return the version of jQuery that is installed.
+ *
+ * This can be used by other modules' hook_requirements() to ensure that the
+ * proper version of jQuery is installed.
+ *
+ * @see version_compare
+ */
+function jquery_update_get_version($jquery_path = NULL) {
+  if (is_null($jquery_path)) {
+    // No file is passed in so default to the file included with this module.
+    $jquery_path = jquery_update_jquery_path();
+  }
+
+  if (!$jquery_path) {
+    return 0;
+  }
+
+  $jquery = file_get_contents($jquery_path);
+
+  $patterns = array(
+    '#^ \* jQuery JavaScript Library v([0-9\.a-z]+)$#m' => 1,
+    '#^ \* jQuery ([0-9\.a-z]+) - New Wave Javascript#m' => 1,
+  );
+
+  $matches = array();
+  foreach ($patterns as $pattern => $group) {
+    // Return the version provided by jQuery Update.
+    if (preg_match($pattern, $jquery, $matches)) {
+      return $matches[$group];
+    }
+  }
+
+  return 0;
+}
+
+/**
+ * FAPI form builder callback
+ * Admin settings form.
+ */
+function jquery_update_settings() {
+  $form['jquery_update_library_path'] = array(
+    '#type' => 'textfield',
+    '#title' => t('Library path'),
+    '#required' => TRUE,
+    '#default_value' => variable_get('jquery_update_library_path', 'sites/all/libraries/jquery'),
+  );
+
+  $form['jquery_update_compression_type'] = array(
+    '#type' => 'radios',
+    '#title' => t('Choose jQuery compression level'),
+    '#options' => array(
+      'min' => t('Production (Minified)'),
+      'none' => t('Development (Uncompressed Code)'),
+    ),
+    '#default_value' => variable_get('jquery_update_compression_type', 'min'),
+  );
+  
+  // Clear the javascript cache when the setting is updated and check version of jquery file.
+  $form['#submit'][] = 'drupal_clear_js_cache';
+  $form['#submit'][] = 'jquery_update_flush_caches';
+  return system_settings_form($form);
+}
+
+/**
+ * FAPI form validate callback
+ * Admin settings form.
+ */
+function jquery_update_settings_validate($form, &$form_state) {
+  $form_state['values']['jquery_update_library_path'] = rtrim($form_state['values']['jquery_update_library_path'], '/');
+  $result = jquery_update_validate_library_path(
+    $form_state['values']['jquery_update_library_path'],
+    $form_state['values']['jquery_update_compression_type']
+  );
+
+  if ($result['severity'] != REQUIREMENT_OK) {
+    form_set_error('jquery_update_library_path', $result['value']);
+  }
+}
+
+/**
+ * Validate the settings variables
+ * jquery_update_library_path and jquery_update_compression_type
+ * This function called by the jquery_update_settings_validate()
+ * and hook_requirements()
+ * 
+ * @param string $path
+ *    jquery_update_library_path
+ *    Filesystem path where the library must be.
+ *    If not specified the stored value will be used
+ *
+ * @param string $type
+ *    jquery_update_compression_type
+ *    The compression type
+ *    If not specified the stored value will be used
+ *
+ * @return array
+ *    The key 'severity' store the validation result.
+ *    The key 'value' store the error message.
+ */
+function jquery_update_validate_library_path($path = NULL, $type = NULL) {
+  if ($path === NULL) {
+    $path = variable_get('jquery_update_library_path', 'sites/all/libraries/jquery');
+  }
+
+  if ($type === NULL) {
+    $type = variable_get('jquery_update_compression_type', 'min');
+  }
+
+  $return = array(
+    'severity' => REQUIREMENT_OK,
+    'value' => '',
+  );
+
+  $t = get_t();
+
+  $filename = $path .'/jquery'. ($type == 'min' ? '.min.js' : '.js');
+  if (!file_exists($filename)) {
+    $return['severity'] = REQUIREMENT_ERROR;
+    $return['value'] = $t('The file %file does not exist.', array('%file' => $filename));
+  }
+
+  return $return;
+}
Index: jquery_update.install
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/jquery_update/jquery_update.install,v
retrieving revision 1.3.4.1
diff -u -p -r1.3.4.1 jquery_update.install
--- jquery_update.install	23 Apr 2009 18:15:57 -0000	1.3.4.1
+++ jquery_update.install	27 Jun 2010 17:05:48 -0000
@@ -14,11 +14,12 @@ function jquery_update_requirements($pha
   $t = get_t();
 
   if ($phase == 'runtime') {
-    $requirements['jquery_update'] = array(
-      'title' => $t('jQuery Update'),
-      'severity' => REQUIREMENT_OK,
-      'value' => jquery_update_get_version(),
-    );
+    module_load_include('inc', 'jquery_update');
+    $requirements['jquery_update'] = jquery_update_validate_library_path();
+    $requirements['jquery_update']['title'] = $t('jQuery Update');
+    if ($requirements['jquery_update']['severity'] == REQUIREMENT_OK) {
+      $requirements['jquery_update']['value'] = jquery_update_get_version();
+    }
   }
 
   return $requirements;
@@ -58,5 +59,6 @@ function jquery_update_update_6200() {
  */
 function jquery_update_uninstall() {
   variable_del('jquery_update_replace');
+  variable_del('jquery_update_library_path');
   variable_del('jquery_update_compression_type');
 }
Index: jquery_update.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/jquery_update/jquery_update.module,v
retrieving revision 1.5.2.2.2.8
diff -u -p -r1.5.2.2.2.8 jquery_update.module
--- jquery_update.module	23 Apr 2010 16:34:39 -0000	1.5.2.2.2.8
+++ jquery_update.module	27 Jun 2010 17:05:48 -0000
@@ -56,66 +56,40 @@ function jquery_update_theme_registry_al
  */
 function jquery_update_preprocess_page(&$variables) {
   // Only do this for pages that have JavaScript on them.
-  if (!empty($variables['scripts'])) {
-
-    // Perform the logic if either jQuery Update's jquery.js is newer than core's.
-    if (variable_get('jquery_update_replace', TRUE)) {
-      // Get an array of all the JavaScript files loaded by Drupal on this page.
-      $scripts = drupal_add_js();
-
-      // Replace jquery.js first.
-      $new_jquery = array(jquery_update_jquery_path() => $scripts['core']['misc/jquery.js']);
-      $scripts['core'] = array_merge($new_jquery, $scripts['core']);
-      unset($scripts['core']['misc/jquery.js']);
-
-      // Loop through each of the required replacements.
-      foreach (jquery_update_get_replacements() as $type => $replacements) {
-        foreach ($replacements as $find => $replace) {
-          // If the file to replace is loaded on this page...
-          if (isset($scripts[$type][$find])) {
-            // Create a new entry for the replacement file, and unset the original one.
-            $replace = JQUERY_UPDATE_REPLACE_PATH .'/'. $replace;
-            $scripts[$type][$replace] = $scripts[$type][$find];
-            unset($scripts[$type][$find]);
-          }
-        }
-      }
-
-      $variables['scripts'] = drupal_get_js('header', $scripts);
-    }
+  // Perform the logic if either jQuery Update's jquery.js is newer than core's.
+  if (empty($variables['scripts']) OR !variable_get('jquery_update_replace', TRUE)) {
+    return;
   }
-}
 
-/**
- * Return the version of jQuery that is installed.
- *
- * This can be used by other modules' hook_requirements() to ensure that the
- * proper version of jQuery is installed.
- *
- * @see version_compare
- */
-function jquery_update_get_version($jquery_path = NULL) {
-  $version = 0;
-  $pattern = '# * jQuery JavaScript Library v([0-9\.a-z]+)#';
-
-  // No file is passed in so default to the file included with this module.
-  if (is_null($jquery_path)) {
-    $jquery_path = jquery_update_jquery_path();
-  }
+  // Get an array of all the JavaScript files loaded by Drupal on this page.
+  $scripts = drupal_add_js();
 
-  // Return the version provided by jQuery Update.
-  $jquery = file_get_contents($jquery_path);
-  if (preg_match($pattern, $jquery, $matches)) {
-    $version = $matches[1];
+  // Replace jquery.js first.
+  $new_jquery = array(jquery_update_jquery_path() => $scripts['core']['misc/jquery.js']);
+  $scripts['core'] = array_merge($new_jquery, $scripts['core']);
+  unset($scripts['core']['misc/jquery.js']);
+
+  // Loop through each of the required replacements.
+  foreach (jquery_update_get_replacements() as $type => $replacements) {
+    foreach ($replacements as $find => $replace) {
+      // If the file to replace is loaded on this page...
+      if (isset($scripts[$type][$find])) {
+        // Create a new entry for the replacement file, and unset the original one.
+        $replace = JQUERY_UPDATE_REPLACE_PATH .'/'. $replace;
+        $scripts[$type][$replace] = $scripts[$type][$find];
+        unset($scripts[$type][$find]);
+      }
+    }
   }
 
-  return $version;
+  $variables['scripts'] = drupal_get_js('header', $scripts);
 }
 
 /**
  * Implementation of hook_flush_caches().
  */
 function jquery_update_flush_caches() {
+  module_load_include('inc', 'jquery_update');
   // Find the versions of jQuery provided by core and this module.
   $jquery_update_version = jquery_update_get_version();
   $jquery_core_version = jquery_update_get_version('misc/jquery.js');
@@ -135,35 +109,16 @@ function jquery_update_menu() {
     'page callback' => 'drupal_get_form',
     'page arguments' => array('jquery_update_settings'),
     'access arguments' => array('administer site configuration'),
+    'file' => 'jquery_update.inc',
   );
   return $items;
 }
 
 /**
- * Admin settings form.
- */
-function jquery_update_settings() {
-  // Clear the javascript cache when the setting is updated and check version of jquery file.
-  $form['#submit'][] = 'drupal_clear_js_cache';
-  $form['#submit'][] = 'jquery_update_flush_caches';
-
-  $form['jquery_update_compression_type'] = array(
-    '#type' => 'radios',
-    '#title' => t('Choose jQuery compression level'),
-    '#options' => array(
-      'min' => t('Production (Minified)'),
-      'none' => t('Development (Uncompressed Code)'),
-    ),
-    '#default_value' => variable_get('jquery_update_compression_type', 'min'),
-  );
-
-  return system_settings_form($form);
-}
-
-/**
  * Return the path to the jQuery file.
  */
 function jquery_update_jquery_path() {
-  $jquery_file = array('none' => 'jquery.js', 'min' => 'jquery.min.js');
-  return JQUERY_UPDATE_REPLACE_PATH .'/'. $jquery_file[variable_get('jquery_update_compression_type', 'min')];
+  $path = variable_get('jquery_update_library_path', 'sites/all/libraries/jquery');
+  $type = variable_get('jquery_update_compression_type', 'min');
+  return $path .'/jquery'. ($type == 'min' ? '.min.js' : '.js');
 }
