Index: README.txt
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/jquery_update/README.txt,v
retrieving revision 1.5
diff -u -r1.5 README.txt
--- README.txt	9 Sep 2010 17:58:22 -0000	1.5
+++ README.txt	11 Dec 2010 00:13:49 -0000
@@ -1,4 +1,4 @@
-// $Id: README.txt,v 1.5 2010/09/09 17:58:22 robloach Exp $
+// $Id:
 
 CONTENTS OF THIS FILE
 ---------------------
@@ -26,7 +26,30 @@
 
 1. Copy the jquery_update directory to your sites/SITENAME/modules directory.
 
-2. Enable the module at Administer >> Site building >> Modules.
+2. Create a jquery directory in your sites/SITENAME/libraries directory.
+
+3. Download the latest stable version of jquery from http://jquery.com/
+
+4. If you downloaded the Production (minified) version, move it to 
+   sites/SITENAME/libraries/jquery/jquery.min.js
+   If you downloaded the Development (uncompressed code) version, move it to:
+   sites/SITENAME/libraries/jquery/jquery.js
+
+5. Download the latest stable version of jquery-ui from http://jqueryui.com/
+
+6. Unpack the zip file you just downloaded to create a jquery-ui-VERSION directory.
+
+7. Move/rename the newly-created directory to sites/SITENAME/libraries/jquery-ui
+   and verify that the following files exist:
+
+      sites/SITENAME/libraries/jquery-ui/version.txt
+      sites/SITENAME/libraries/jquery-ui/ui/jquery.ui.core.js
+      sites/SITENAME/libraries/jquery-ui/ui/minified/jquery.ui.core.js
+
+8. (optional) Download the farbtastic plugin from farbtastic.googlecode.com
+   and move it to sites/SITENAME/libraries/farbtastic/farbtastic.js
+
+9. Enable the Jquery update module at Administer >> Modules.
 
 
 CREDITS
Index: jquery_update.info
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/jquery_update/jquery_update.info,v
retrieving revision 1.6
diff -u -r1.6 jquery_update.info
--- jquery_update.info	9 Sep 2010 17:58:22 -0000	1.6
+++ jquery_update.info	11 Dec 2010 00:13:49 -0000
@@ -1,7 +1,8 @@
 ; $Id$
 name = jQuery Update
-description = Updates jQuery to jQuery 1.4.2 and jQuery UI 1.8.4.
+description = Moves jQuery and jQuery UI to libraries folder
 package = User interface
 core = 7.x
+dependencies[] = libraries
 files[] = jquery_update.module
 files[] = jquery_update.install
Index: jquery_update.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/jquery_update/jquery_update.module,v
retrieving revision 1.10
diff -u -r1.10 jquery_update.module
--- jquery_update.module	9 Sep 2010 17:58:22 -0000	1.10
+++ jquery_update.module	11 Dec 2010 00:13:49 -0000
@@ -16,34 +16,63 @@
   $min = variable_get('jquery_update_compression_type', 'min') == 'none' ? '' : '.min';
 
   // Replace jQuery.
-  $javascript['jquery']['js']['misc/jquery.js']['data'] = $path . '/replace/jquery/jquery' . $min . '.js';
-  $javascript['jquery']['version'] = '1.4.2';
-
-  // Replace jQuery UI's JavaScript, beginning by defining the mapping.
-  $names = drupal_map_assoc(array(
-    'ui.accordion', 'ui.autocomplete', 'ui.button', 'ui.datepicker',
-    'ui.dialog', 'ui.draggable', 'ui.droppable', 'ui.mouse', 'ui.position',
-    'ui.progressbar', 'ui.resizable', 'ui.selectable', 'ui.slider',
-    'ui.sortable', 'ui.tabs', 'ui.widget', 'effects.blind', 'effects.bounce',
-    'effects.clip', 'effects.drop', 'effects.explode', 'effects.fade',
-    'effects.fold', 'effects.highlight', 'effects.pulsate', 'effects.scale',
-    'effects.slide', 'effects.transfer',
-  ));
-  $names['ui'] = 'ui.core';
-  $names['effects'] = 'effects.core';
+  $jquery_file = libraries_get_path('jquery') . '/jquery' . $min . '.js';
+  if (file_exists($jquery_file)) {
+    $version_text = file_get_contents($jquery_file,false,NULL,-1,64);
+    if (preg_match('/jQuery Javascript Library v([0-9.]+)/',$version_text,$matches)) {
+      $javascript['jquery']['version'] = $matches[1];
+      $javascript['jquery']['js']['misc/jquery.js']['data'] = $jquery_file;
+    }
+  }
 
   // Construct the jQuery UI path.
-  $jspath = $path . '/replace/ui/ui/' . (variable_get('jquery_update_compression_type', 'min') == 'min' ? 'minified/' : '');
-  foreach ($names as $name => $file) {
-    $corefile = 'misc/ui/jquery.' . $file . '.min.js';
-    $javascript[$name]['js'][$corefile]['data'] = $jspath . 'jquery.' . $file . $min . '.js';
-    $javascript[$name]['version'] = '1.8.4';
+  $lib_path = libraries_get_path('jquery-ui');
+  $version_file = $lib_path . '/version.txt';
+  if (!file_exists($version_file)) {
+    return;
   }
-  // TODO: Replace all of jQuery UI's CSS.
+  $version = trim(file_get_contents($version_file));
+
+  $ui_path = $lib_path . '/ui' . ($min == '.min' ? '/minified' : '');
+  $mask = "/jquery.((ui|effects)..*)$min.js/";
+  foreach(file_scan_directory($ui_path,$mask) as $file) {
+    if (preg_match("$mask",$file->filename,$matches)) {
+      $name = $matches[1];
+      $corefile = "misc/ui/jquery.$name.min.js";
+      if (preg_match('/(.*)\.core/',$name,$matches)) {
+        $name = $matches[1];
+      }
+      $javascript[$name]['js'][$corefile]['data'] = $file->uri;
+      $javascript[$name]['version'] = $version;
+    }
+  }  
 
   // Replace the jQuery Cookie plugin.
-  $javascript['cookie']['js']['misc/jquery.cookie.js']['data'] = $path . '/replace/ui/external/jquery.cookie.js';
-  $javascript['cookie']['version'] = '1.0';
+  $cookie_path = "$lib_path/external/cookie/jquery.cookie$min.js";
+  if (!file_exists($cookie_path)) {
+    $cookie_path = "$lib_path/external/cookie/jquery.cookie.js";
+    if (!file_exists($cookie_path)) {
+      $cookie_path = "$lib_path/external/jquery.cookie$min.js";
+      if (!file_exists($cookie_path)) {
+	$cookie_path = "$lib_path/external/jquery.cookie.js";
+      }
+    }
+  }
+  if (file_exists($cookie_path)) {
+    $javascript['cookie']['js']['misc/jquery.cookie.js']['data'] = $cookie_path;
+    $javascript['cookie']['version'] = '1.0'; // Where does this come from?
+  }
+
+  // (optional) Replace the farbtastic plugin
+  $farb_lib = libraries_get_path('farbtastic');
+  $farb_path = "$farb_lib/farbtastic$min.js";
+  if (!file_exists($farb_path)) {
+    $farb_path = "$farb_lib/farbtastic.js";
+  }
+  if (file_exists($farb_path)) {
+    $javascript['farbtastic']['js']['misc/farbtastic/farbtastic.js']['data'] = $farb_path;
+    $javascript['farbtastic']['version'] = '2.0'; // Laziness...
+  }
 }
 
 /**
