You are here

function _labjs_patch_core in LABjs 6

Replace core JavaScripts with LABjs-aware version.

Parameters

$javascript: associative array from drupal_add_js()

Return value

Nothing. Input array is modified.

2 calls to _labjs_patch_core()
labjs_advagg_js_pre_alter in ./labjs.module
Implements hook_advagg_js_pre_alter.
labjs_preprocess_page in ./labjs.module
Implements hook_preprocess_page().

File

./labjs.module, line 228
LABjs module

Code

function _labjs_patch_core(&$javascript) {
  $patches = array();
  if (isset($javascript['core']['misc/drupal.js'])) {

    // Replace drupal.js with our patched version
    $patches[] = array(
      'region' => 'core',
      'old' => 'misc/drupal.js',
      'new' => drupal_get_path('module', 'labjs') . '/drupal.modified.js',
    );
  }

  // Support for jquery_update:
  // We copy what jquery_update does in its preprocess_page.
  if (module_exists('jquery_update') && variable_get('jquery_update_replace', TRUE)) {
    $patches[] = array(
      'region' => 'core',
      'old' => 'misc/jquery.js',
      'new' => jquery_update_jquery_path(),
    );

    // Loop through each of the required replacements.
    foreach (jquery_update_get_replacements() as $type => $replacements) {
      foreach ($replacements as $find => $replace) {
        $patches[] = array(
          'region' => $type,
          'old' => $find,
          'new' => JQUERY_UPDATE_REPLACE_PATH . '/' . $replace,
        );
      }
    }
  }
  _labjs_replace_javascript($javascript, $patches);
}