function jqmulti_alter_scripts in jQuery Multi 6
This is where the magic happens. The new jQuery is added and noConflict() is run. Finally, scripts are rearranged or added so that the targeted scripts run with the newer jQuery.
2 calls to jqmulti_alter_scripts()
- jqmulti_jquery_update_alter in ./
jqmulti.module - Implements hook_jquery_update_alter(). This takes care of the alterations in the case that jQuery Update is installed.
- jqmulti_preprocess_page in ./
jqmulti.module - Implements hook_preprocess_page().
File
- ./
jqmulti.module, line 76 - Code for the jQuery Multi module.
Code
function jqmulti_alter_scripts($scripts) {
$modulejs =& $scripts['module'];
$options = array(
'cache' => TRUE,
'defer' => FALSE,
'preprocess' => TRUE,
);
$prepend = array();
$jquery = jqmulti_jquery_path();
if (!$jquery) {
return $scripts;
}
// Get info about which files are needed.
$files = jqmulti_get_files();
// Check if we need to add libraries even if they have not been explicitly added.
if (!variable_get('jqmulti_load_libraries_always', FALSE)) {
$files = array_intersect_key($files, $modulejs);
}
// If there are no files, check if we are to add jQuery anyway.
if (empty($files)) {
if (!variable_get('jqmulti_load_always', FALSE)) {
return $scripts;
}
}
// Add the new version of jQuery.
$prepend[$jquery] = $options;
// Rearrange JS array accordingly.
foreach ($files as $file) {
// add the files
if (isset($modulejs[$file])) {
$prepend[$file] = $modulejs[$file];
unset($modulejs[$file]);
}
else {
$prepend[$file] = $options;
}
}
// Add the switch script to return jQuery to Drupal's default and save the new jQuery for later use.
$switch = jqmulti_switch_path();
$prepend[$switch] = $options;
// Prepend the $prepend array.
$modulejs = array_merge($prepend, $modulejs);
return $scripts;
}