function jquery_update_library_alter in jQuery Update 7
Same name and namespace in other branches
- 7.3 jquery_update.module \jquery_update_library_alter()
- 7.2 jquery_update.module \jquery_update_library_alter()
Implementation of hook_js_alter().
File
- ./
jquery_update.module, line 53 - Updates Drupal to use the latest version of jQuery.
Code
function jquery_update_library_alter(&$javascript) {
$path = drupal_get_path('module', 'jquery_update');
// Make sure we inject either the minified or uncompressed version as desired.
$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.5';
// 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.shake',
'effects.slide',
'effects.transfer',
));
$names['ui'] = 'ui.core';
$names['effects'] = 'effects.core';
// Construct the jQuery UI path and replace the JavaScript.
$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.9';
}
// Replace all CSS files.
$names = drupal_map_assoc(array(
'ui.accordion',
'ui.autocomplete',
'ui.button',
'ui.datepicker',
'ui.dialog',
'ui.progressbar',
'ui.resizable',
'ui.selectable',
'ui.slider',
'ui.tabs',
));
$names['ui'] = 'ui.core';
$csspath = $path . '/replace/ui/themes/base/' . (variable_get('jquery_update_compression_type', 'min') == 'min' ? 'minified/' : '');
foreach ($names as $name => $file) {
$javascript[$name]['css']["misc/ui/jquery.{$file}.css"]['data'] = $csspath . 'jquery.' . $file . $min . '.css';
}
// Make sure ui.theme is replaced as well.
$javascript['ui']['css']['misc/ui/jquery.ui.theme.css']['data'] = $csspath . 'jquery.ui.theme' . $min . '.css';
// 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';
}