Projet

Général

Profil

Révision e4c061ad

Ajouté par Assos Assos il y a plus de 9 ans

Weekly update of contrib modules

Voir les différences:

drupal7/sites/all/modules/jquery_update/jquery_update.module
94 94
        $version = $admin_version;
95 95
      }
96 96
    }
97
    // If the ajax version is set then that one always win.
98
    if (!empty($_POST['ajax_page_state']['jquery_version'])) {
99
      $ajax_version = $_POST['ajax_page_state']['jquery_version'];
100
      if (in_array($ajax_version, array('default', '1.5', '1.6', '1.7', '1.8', '1.9', '1.10'))) {
101
        $version = $ajax_version;
102
      }
103
    }
97 104

  
98 105
    // Always add a new jquery_version array to ajaxPageState.
99 106
    // This is what we used to determine which version to use
......
103 110
      'type' => 'setting',
104 111
    );
105 112
    $javascript['drupal.ajax']['dependencies'][] = array('jquery_update', 'jquery_update.ajax.fix');
113

  
114
    // Don't replace anything if Drupal provided jQuery should be used
115
    if ('default' == $version) {
116
      return;
117
    }
118

  
106 119
    jquery_update_jquery_replace($javascript, $cdn, $path, $min, $version);
107 120

  
108 121
    // Replace jQuery UI with CDN or local files. If from a CDN include all of
......
163 176
    '#type' => 'select',
164 177
    '#title' => t('Default jQuery Version'),
165 178
    '#options' => array(
179
      'default' => t('Default (provided by Drupal)'),
166 180
      '1.5' => '1.5',
167 181
      '1.7' => '1.7',
168 182
      '1.8' => '1.8',
......
177 191
    '#type' => 'select',
178 192
    '#title' => t('Alternate jQuery version for administrative pages'),
179 193
    '#options' => array(
180
      '' => t('Use the default'),
194
      '' => t('Default jQuery Version'),
195
      'default' => t('Default (provided by Drupal)'),
181 196
      '1.5' => '1.5',
182 197
      '1.7' => '1.7',
183 198
      '1.8' => '1.8',
......
194 209
      'min' => t('Production (minified)'),
195 210
      'none' => t('Development (uncompressed)'),
196 211
    ),
212
    // Do not show this field if jQuery version is default
213
    '#states' => array(
214
      'invisible' => array(
215
        ':input[name=jquery_update_jquery_version]' => array('value' => "default"),
216
      ),
217
    ),
197 218
    '#default_value' => variable_get('jquery_update_compression_type', 'min'),
198 219
  );
199 220
  $form['jquery_update_jquery_cdn'] = array(
......
205 226
      'microsoft' => t('Microsoft'),
206 227
      'jquery' => t('jQuery'),
207 228
    ),
229
    // Do not show this field if jQuery version is default
230
    '#states' => array(
231
      'invisible' => array(
232
        ':input[name=jquery_update_jquery_version]' => array('value' => "default"),
233
      ),
234
    ),
208 235
    '#default_value' => variable_get('jquery_update_jquery_cdn', 'none'),
209 236
    '#description' => t('Use jQuery and jQuery UI from a CDN. If the CDN is not available the local version of jQuery and jQuery UI will be used.'),
210 237
  );
......
231 258
 *   The version of jQuery to use.
232 259
 */
233 260
function jquery_update_jquery_replace(&$javascript, $cdn, $path, $min, $version) {
234
  // If the ajax version is set then that one always win.
235
  if (!empty($_POST['ajax_page_state']['jquery_version'])) {
236
    $ajax_version = $_POST['ajax_page_state']['jquery_version'];
237
    if (in_array($ajax_version, array('1.5', '1.6', '1.7', '1.8', '1.9', '1.10'))) {
238
      $version = $ajax_version;
239
    }
240
  }
241 261

  
242 262
  // Make sure to use the latest version in given branch.
243 263
  $trueversion = NULL;
......
267 287
  // Check for CDN support.
268 288
  switch ($cdn) {
269 289
    case 'google':
270
      $javascript['jquery']['js']['misc/jquery.js']['data'] = 'https://ajax.googleapis.com/ajax/libs/jquery/' . $trueversion . '/jquery' . $min . '.js';
290
      $javascript['jquery']['js']['misc/jquery.js']['data'] = '//ajax.googleapis.com/ajax/libs/jquery/' . $trueversion . '/jquery' . $min . '.js';
271 291
      $javascript['jquery']['js']['misc/jquery.js']['type'] = 'external';
272 292
      jquery_update_jquery_backup($javascript, $path, $min, $version);
273 293
      break;
274 294

  
275 295
    case 'microsoft':
276
      $javascript['jquery']['js']['misc/jquery.js']['data'] = 'http://ajax.aspnetcdn.com/ajax/jQuery/jquery-' . $trueversion . $min . '.js';
296
      $javascript['jquery']['js']['misc/jquery.js']['data'] = '//ajax.aspnetcdn.com/ajax/jQuery/jquery-' . $trueversion . $min . '.js';
277 297
      $javascript['jquery']['js']['misc/jquery.js']['type'] = 'external';
278 298
      jquery_update_jquery_backup($javascript, $path, $min, $version);
279 299
      break;
280 300

  
281 301
    case 'jquery':
282
      $javascript['jquery']['js']['misc/jquery.js']['data'] = 'http://code.jquery.com/jquery-' . $trueversion . $min . '.js';
302
      $javascript['jquery']['js']['misc/jquery.js']['data'] = '//code.jquery.com/jquery-' . $trueversion . $min . '.js';
283 303
      $javascript['jquery']['js']['misc/jquery.js']['type'] = 'external';
284 304
      jquery_update_jquery_backup($javascript, $path, $min, $version);
285 305
      break;
......
377 397
    'ui.accordion', 'ui.autocomplete', 'ui.button', 'ui.datepicker', 'ui.dialog', 'ui.draggable',
378 398
    'ui.droppable', 'ui.mouse', 'ui.position', 'ui.progressbar', 'ui.resizable', 'ui.selectable',
379 399
    'ui.slider', 'ui.sortable', 'ui.tabs', 'ui.widget', 'ui.spinner', 'ui.menu', 'ui.tooltip',
380
    'effects.blind', 'effects.bounce', 'effects.clip', 'effects.drop', 'effects.explode', 'effects.fade',
381
    'effects.fold', 'effects.highlight', 'effects.pulsate', 'effects.scale', 'effects.shake', 'effects.slide',
382
    'effects.transfer',
383 400
  ));
384 401
  $names['ui'] = 'ui.core';
385
  $names['effects'] = 'ui.effect';
402
  $names['effects'] = array('effects.core', 'ui.effect'); // map[library_hook] = array(core_fn, updated_fn)
403
  $names = jquery_update_make_library_hook_to_file_name_segment_map_for_effects($names);
386 404

  
387 405
  switch ($cdn) {
388 406
    case 'google':
389
      $cdn = 'https://ajax.googleapis.com/ajax/libs/jqueryui/1.10.2/jquery-ui' . $min . '.js';
407
      $cdn = '//ajax.googleapis.com/ajax/libs/jqueryui/1.10.2/jquery-ui' . $min . '.js';
390 408
      jquery_update_jqueryui_cdn($cdn, $javascript, $path, $min, $names);
391 409
      jquery_update_jqueryui_backup($javascript, $path, $min);
392 410
      break;
393 411

  
394 412
    case 'microsoft':
395
      $cdn = 'http://ajax.aspnetcdn.com/ajax/jquery.ui/1.10.2/jquery-ui' . $min . '.js';
413
      $cdn = '//ajax.aspnetcdn.com/ajax/jquery.ui/1.10.2/jquery-ui' . $min . '.js';
414
      jquery_update_jqueryui_cdn($cdn, $javascript, $path, $min, $names);
415
      jquery_update_jqueryui_backup($javascript, $path, $min);
416
      break;
417

  
418
    case 'jquery':
419
      $cdn = '//code.jquery.com/ui/1.10.2/jquery-ui' . $min . '.js';
396 420
      jquery_update_jqueryui_cdn($cdn, $javascript, $path, $min, $names);
397 421
      jquery_update_jqueryui_backup($javascript, $path, $min);
398 422
      break;
......
403 427
  }
404 428
}
405 429

  
430
/**
431
 * Create a mapping from system.module library hooks to file name segments.
432
 *
433
 * @param array $map Optional. If given, append to it.
434
 * @return array The keys are library hooks  and the values are each arrays of
435
 * 2 file name segments as values. The first file name segment can be used to
436
 * reach Drupal core's jQuery UI effect files, and the second file name segment
437
 * can be used to construct a path to the equivalent replacement
438
 * jQuery UI effect file provided by jquery_update.module.
439
 */
440
function jquery_update_make_library_hook_to_file_name_segment_map_for_effects($map = array()) {
441
  $effect_names = array(
442
    'blind', 'bounce', 'clip', 'drop', 'explode', 'fade', 'fold',
443
    'highlight', 'pulsate', 'scale', 'shake', 'slide', 'transfer',
444
  );
445
  foreach ($effect_names as $effect_name) {
446
    $library_hook = 'effects.' . $effect_name;
447
    $file_name_segment_core = $library_hook; // Yes, for the effect files, this is indeed identical.
448
    $file_name_segment_updated = 'ui.effect-' . $effect_name;
449
    $map[$library_hook] = array($file_name_segment_core, $file_name_segment_updated);
450
  }
451
  return $map;
452
}
453

  
406 454
/**
407 455
 * Add the local fallback in case jQuery UI from the CDN is unavailable.
408 456
 *
......
447 495
  // Construct the jQuery UI path and replace the JavaScript.
448 496
  $jspath = $path . '/replace/ui/ui/' . ($min == '.min' ? 'minified/' : '');
449 497
  foreach ($names as $name => $file) {
450
    $corefile = 'misc/ui/jquery.' . $file . '.min.js';
498
    list($file_core, $file_updated) = is_array($file) ? $file : array($file, $file);
499
    $corefile = 'misc/ui/jquery.' . $file_core . '.min.js';
451 500
    // Remove the core files.
452 501
    unset($javascript[$name]['js'][$corefile]);
453 502
    $javascript[$name]['version'] = '1.10.2';
......
487 536
  // Construct the jQuery UI path and replace the JavaScript.
488 537
  $jspath = $path . '/replace/ui/ui/' . ($min == '.min' ? 'minified/' : '');
489 538
  foreach ($names as $name => $file) {
490
    $corefile = 'misc/ui/jquery.' . $file . '.min.js';
491
    $javascript[$name]['js'][$corefile]['data'] = $jspath . 'jquery.' . $file . $min . '.js';
539
    list($file_core, $file_updated) = is_array($file) ? $file : array($file, $file);
540
    $corefile = 'misc/ui/jquery.' . $file_core . '.min.js';
541
    $javascript[$name]['js'][$corefile]['data'] = $jspath . 'jquery.' . $file_updated . $min . '.js';
492 542
    $javascript[$name]['version'] = '1.10.2';
493 543
  }
494 544
}

Formats disponibles : Unified diff