You are here

function js_injector_js_alter in JS injector 7

Implements hook_js_alter(). Since we're trying to give the administrator complete control, we'll move JS that this module has added to a high weight, higher even than the theme's JS files. Currently the weight is 200 + the crid, which is currently higher than Bartik's JS.

Parameters

$js: The array of JS files.

File

./js_injector.module, line 67
Allows administrators to inject JS into the page output based on configurable rules. Useful for adding simple JS tweaks without modifying a site's official theme.

Code

function js_injector_js_alter(&$js) {
  $js_rules = _js_injector_load_rule();
  foreach ($js_rules as $js_rule) {
    $filepath = _js_injector_rule_path($js_rule['crid']);
    if (!empty($js[$filepath])) {
      $js[$filepath]['weight'] = 200 + $js_rule['crid'];
    }
  }
}