diff --git a/template.php b/template.php index 17698ba..82bcb50 100644 --- a/template.php +++ b/template.php @@ -352,8 +352,53 @@ function aurora_preprocess_node(&$variables) { * Implements hook_js_alter */ function aurora_js_alter(&$js) { + global $base_url; // Forces Modernizr to header if the Modernizr module is enabled. if (module_exists('modernizr')) { $js[modernizr_get_path()]['force header'] = true; } -} \ No newline at end of file + + // Updates jQuery and loads it from a CDN if wanted. + // Partially pulled from jquery_update module. + $version = theme_get_setting('aurora_jquery_version'); + $cdn = theme_get_setting('aurora_jquery_cdn'); + if ($cdn != 0 && $version == '1.4.4') { + return; + } + + $min = theme_get_setting('aurora_jquery_min'); + $min = ($min === 1) ? '' : '.min'; + $path_to_theme = $base_url . '/' . drupal_get_path('theme', 'aurora'); + $js['misc/jquery.js']['version'] = $version; + + if ($cdn !== '0') { + $js['misc/jquery.js']['type'] = 'external'; + + switch ($cdn) { + case 'google': + $js['misc/jquery.js']['data'] = "//ajax.googleapis.com/ajax/libs/jquery/$version/jquery$min.js"; + break; + case 'microsoft': + $js['misc/jquery.js']['data'] = "http://ajax.aspnetcdn.com/ajax/jquery/jquery-$version$min.js"; + break; + case 'jquery': + $js['misc/jquery.js']['data'] = "http://code.jquery.com/jquery-$version$min.js"; + break; + } + // Now add code to fall back on if the CDN is unavailable. + $js['misc/jquery-fallback.js'] = array( + 'group' => JS_LIBRARY, + 'weight' => -19, + 'every_page' => TRUE, + 'type' => 'inline', + 'scope' => $js['misc/jquery.js']['scope'], + 'cache' => FALSE, + 'defer' => FALSE, + 'data' => 'window.jQuery || document.write(\'