Index: jquery_update.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/jquery_update/jquery_update.module,v
retrieving revision 1.2
diff -u -r1.2 jquery_update.module
--- jquery_update.module	21 May 2008 05:04:45 -0000	1.2
+++ jquery_update.module	14 Jun 2008 23:42:40 -0000
@@ -5,6 +5,61 @@
  * @file
  * Updates Drupal to use the latest version of jQuery.
  */
+ 
+/**
+ * Implementation of hook_menu().
+ * 
+ * Creates a menu item for the jQuery Update administrative page.
+ */
+function jquery_update_menu() {
+  $items = array();
+  $items['admin/settings/jquery_update'] = array(
+    //use capitalized Jquery (sic) to avoid menu item showing up at the bottom
+    'title' => t('Jquery Update'),
+    'description' => t('Set whether jQuery Update should use the Google AJAX Libraries API.'),
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('jquery_update_admin'),
+    'access arguments' => array('administer jQuery update'),
+    'type' => MENU_NORMAL_ITEM,
+  );
+  return $items;
+}
+
+/**
+ * Generates the administration form.
+ */
+function jquery_update_admin() {
+  $form = array();
+  $form['google_api'] = array(
+    '#type' => 'fieldset',
+    '#title' => 'Google AJAX Libraries API',
+    '#description' => t('By default, jQuery Update serves a local copy of the updated jquery.js file; however, it can optionally use the <a href="google_ajax">Google AJAX Libraries API</a> instead.', array('@google_ajax' => 'http://code.google.com/apis/ajaxlibs/')),
+  );
+  $form['google_api']['use_google'] = array(
+    '#type' => 'checkbox',
+    '#title' => t('Use the Google AJAX Libraries API to load jQuery.'),
+    '#default_value' => variable_get('use_google', 0),
+  );
+  
+  //field should ideally be disabled by default until $use_google is checked (but that requires issue #227966 to be fixed)
+  $form['google_api']['jquery_version'] = array(
+    '#type' => 'textfield',
+    '#title' => t('jQuery Version'),
+    '#default_value' => variable_get('jquery_version', '1'),
+    '#description' => t('Specify the version of jQuery to load. A value of "1" will load the latest version 1.x release. See the Google AJAX Libraries API Developer\'s Guide for <a href="@supported-versions">supported versions</a> and <a href="@how-to-specify">how to specify a desired version</a>.', array('@supported-versions' => 'http://code.google.com/apis/ajaxlibs/documentation/#jquery', '@how-to-specify' => 'http://code.google.com/apis/ajaxlibs/documentation/#googleDotLoadVersioning')),
+    '#maxlength' => 12,
+    '#size' => 12,
+    '#required' => TRUE,
+  );
+  return system_settings_form($form);
+}
+
+/**
+ * Implementation of hook_perm().
+ */
+function jquery_update_perm() {
+  return array('administer jQuery update');
+}
 
 /**
  * Implementation of hook_theme_registry_alter().
@@ -33,13 +88,19 @@
   if (!empty($variables['scripts'])) {
     // Get an array of all the JavaScript files loaded by Drupal on this page.
     $scripts = drupal_add_js();
-
-    // Create a $scripts record for our new jQuery file.
-    $jquery_path = drupal_get_path('module', 'jquery_update') . '/jquery.js';
-    $new_jquery = array($jquery_path => $scripts['core']['misc/jquery.js']);
-
-    // Replace misc/jquery.js with ours.
-    $scripts['core'] = array_merge($new_jquery, $scripts['core']);
+    
+    if (variable_get('use_google', 0) == 1) {    
+      $head = drupal_get_html_head();
+      $head .= '<script src="http://ajax.googleapis.com/ajax/libs/jquery/'. variable_get('jquery_version','1') .'/jquery.min.js" type="text/javascript"></script>' . PHP_EOL;
+      $variables['head'] = $head;    
+    } else {    
+      // Create a $scripts record for our new jQuery file.
+      $jquery_path = drupal_get_path('module', 'jquery_update') . '/jquery.js';
+      $new_jquery = array($jquery_path => $scripts['core']['misc/jquery.js']);
+  
+      // Replace misc/jquery.js with ours.
+      $scripts['core'] = array_merge($new_jquery, $scripts['core']);
+    }
     unset($scripts['core']['misc/jquery.js']);
     $variables['scripts'] = drupal_get_js('header', $scripts);
   }

