diff --git jquery_update.module jquery_update.module index 10310e2..bc4cb28 100644 --- jquery_update.module +++ jquery_update.module @@ -2,7 +2,7 @@ /** * @file - * Updates Drupal to use the latest version of jQuery. + * Updates Drupal to use the latest versions of jQuery and jQuery UI. */ /** @@ -48,10 +48,9 @@ function jquery_update_library() { } /** - * Implementation of hook_js_alter(). + * Implements hook_library_alter(). */ -function jquery_update_library_alter(&$javascript, $module) { - +function jquery_update_library_alter(&$libraries, $module) { // We are updating just the system module. For all other cases we return. if ($module != 'system') { return; @@ -64,26 +63,26 @@ function jquery_update_library_alter(&$javascript, $module) { $cdn = variable_get('jquery_update_jquery_cdn', 'none'); // Replace jQuery. - jquery_update_jquery_replace($javascript, $cdn, $path, $min); - $javascript['jquery']['version'] = '1.5.1'; + jquery_update_jquery_replace($libraries, $cdn, $path, $min); + $libraries['jquery']['version'] = '1.5.1'; // Replace jQuery UI with CDN or local files. If from a CDN include all of jQuery UI. - jquery_update_jqueryui_replace($javascript, $cdn, $path, $min); + jquery_update_jqueryui_replace($libraries, $cdn, $path, $min); // Replace the jQuery Cookie plugin. - $javascript['cookie']['js']['misc/jquery.cookie.js']['data'] = $path . '/replace/ui/external/jquery.cookie.js'; + $libraries['jquery.cookie']['js']['misc/jquery.cookie.js']['data'] = $path . '/replace/ui/external/jquery.cookie.js'; // Noting the version based on git commit as no version number is available. - $javascript['cookie']['version'] = '67fb34f6a866c40d0570'; + $libraries['jquery.cookie']['version'] = '67fb34f6a866c40d0570'; // Replace jQuery Form plugin. - $javascript['jquery.form']['js']['misc/jquery.form.js']['data'] = $path . '/replace/misc/jquery.form.js'; - $javascript['jquery.form']['version'] = '2.67'; + $libraries['jquery.form']['js']['misc/jquery.form.js']['data'] = $path . '/replace/misc/jquery.form.js'; + $libraries['jquery.form']['version'] = '2.67'; } /** - * Implementation of hook_form_FORM_ID_alter(). + * Implements hook_form_FORM_ID_alter(). */ -function jquery_update_form_system_performance_settings_alter(&$form, &$form_state) { +function jquery_update_form_system_performance_settings_alter(&$form, &$form_state, $form_id) { $form['bandwidth_optimization']['jquery_update_compression_type'] = array( '#type' => 'radios', '#title' => t('jQuery compression level'), @@ -109,7 +108,7 @@ function jquery_update_form_system_performance_settings_alter(&$form, &$form_sta /** * Update jQuery to the CDN or local path. * - * @param array $javascript + * @param array $libraries * The library definition array as seen in hook_library_alter(). * @param string $cdn * The name of the CDN option to use. Possible options are: @@ -117,20 +116,20 @@ function jquery_update_form_system_performance_settings_alter(&$form, &$form_sta * - google * - microsoft */ -function jquery_update_jquery_replace(&$javascript, $cdn, $path, $min) { +function jquery_update_jquery_replace(&$libraries, $cdn, $path, $min) { switch($cdn) { case 'google': - $javascript['jquery']['js']['misc/jquery.js']['data'] = 'https://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery' . $min . '.js'; - $javascript['jquery']['js']['misc/jquery.js']['type'] = 'external'; - jquery_update_jquery_backup($javascript, $path, $min); + $libraries['jquery']['js']['misc/jquery.js']['data'] = 'https://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery' . $min . '.js'; + $libraries['jquery']['js']['misc/jquery.js']['type'] = 'external'; + jquery_update_jquery_backup($libraries, $path, $min); break; case 'microsoft': - $javascript['jquery']['js']['misc/jquery.js']['data'] = 'http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.5.1' . $min . '.js'; - $javascript['jquery']['js']['misc/jquery.js']['type'] = 'external'; - jquery_update_jquery_backup($javascript, $path, $min); + $libraries['jquery']['js']['misc/jquery.js']['data'] = 'http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.5.1' . $min . '.js'; + $libraries['jquery']['js']['misc/jquery.js']['type'] = 'external'; + jquery_update_jquery_backup($libraries, $path, $min); break; case 'none': - $javascript['jquery']['js']['misc/jquery.js']['data'] = $path . '/replace/jquery/jquery' . $min . '.js'; + $libraries['jquery']['js']['misc/jquery.js']['data'] = $path . '/replace/jquery/jquery' . $min . '.js'; break; } } @@ -138,15 +137,15 @@ function jquery_update_jquery_replace(&$javascript, $cdn, $path, $min) { /** * Add the local fallback in case jQuery from the CDN is unavailable. * - * @param array $javascript + * @param array $libraries * The $libraries array as seen in hook_library_alter() * @param string $path * The path to the module where replacements can be found. * @param string $min * The '.min' to include in the file name if we are requesting a minified version. */ -function jquery_update_jquery_backup(&$javascript, $path, $min) { - $javascript['jquery']['js'][] = array( +function jquery_update_jquery_backup(&$libraries, $path, $min) { + $libraries['jquery']['js'][] = array( 'data' => 'window.jQuery || document.write("