You are here

function jquery_update_jqueryui_cdn in jQuery Update 7.3

Same name and namespace in other branches
  1. 7.2 jquery_update.module \jquery_update_jqueryui_cdn()

Handle when jQuery UI is updated to the cdn version.

Parameters

string $cdn: The name of the CDN option to use. Possible options are:

  • none
  • google
  • microsoft

array $javascript: The $libraries array as seen in hook_library_alter()

string $path: The path to the module where replacements can be found.

string $min: The '.min' to include in the file name if we are requesting a minified version.

  • @param array $names An array mapping jquery ui parts to their file names.
1 call to jquery_update_jqueryui_cdn()
jquery_update_jqueryui_replace in ./jquery_update.module
Update jQuery UI to the CDN or local path.

File

./jquery_update.module, line 617
Updates Drupal to use the latest version of jQuery.

Code

function jquery_update_jqueryui_cdn($cdn, &$javascript, $path, $min, $names) {

  // Construct the jQuery UI path and replace the JavaScript.
  $jspath = $path . '/replace/ui/ui/' . ($min == '.min' ? 'minified/' : '');
  foreach ($names as $name => $file) {
    list($file_core, $file_updated) = is_array($file) ? $file : array(
      $file,
      $file,
    );
    $corefile = 'misc/ui/jquery.' . $file_core . '.min.js';

    // Remove the core files.
    unset($javascript[$name]['js'][$corefile]);
    $javascript[$name]['version'] = '1.10.2';
  }

  // UI is used by all of UI. Add the js cdn here.
  $javascript['ui']['js'][$cdn] = array(
    'data' => $cdn,
    'type' => 'external',
    'group' => JS_LIBRARY,
    'weight' => -11,
  );

  // The cdn puts jQuery UI core and the jQuery UI Effects library in the same
  // file, but the latter can normally be used without the former. So we need
  // to add a dependency to guarantee that code which uses the Effects library
  // has the file loaded regardless of whether they are also using jQuery UI
  // core.
  $javascript['effects']['dependencies'][] = array(
    'system',
    'ui',
  );
}