You are here

jquery_dollar.module in jQuery Dollar 8

Same filename and directory in other branches
  1. 7 jquery_dollar.module

File

jquery_dollar.module
View source
<?php

use Drupal\Core\Asset\AttachedAssetsInterface;

/**
 * Implements hook_js_alter().
 * This function will add a js file immediately after drupal.js that declares:
 * $ = jQuery;
 * This allows other javascript code to access the $ variable from the global namespace
 * for the purposes of convenience.
 */
function jquery_dollar_js_alter(&$javascript, AttachedAssetsInterface $assets) {
  $file = drupal_get_path('module', 'jquery_dollar') . '/jquery_dollar.js';

  // Copy all properties of drupal.init.js.
  $javascript[$file] = $javascript['core/misc/drupal.init.js'];

  // Replace the file to load.
  $javascript[$file]['data'] = $file;

  // Minimally increase the weight to be loaded directly after drupal.js.
  $javascript[$file]['weight'] += 0.1;
}

Functions

Namesort descending Description
jquery_dollar_js_alter Implements hook_js_alter(). This function will add a js file immediately after drupal.js that declares: $ = jQuery; This allows other javascript code to access the $ variable from the global namespace for the purposes of convenience.