You are here

jquery_dollar.module in jQuery Dollar 7

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

File

jquery_dollar.module
View source
<?php

/**
 * Implements hook_js_alter().
 * This function will add a js file immediately after drupal.js that declares:
 * $ = jQuery;
 * This allows all other code to use the $ convention for writing jQuery code
 * The reason is that forcing users to use special closures to make jQuery compatible with the $ are
 * superfluous, confusing, and complicated.
 * More here: http://drupal.org/node/1407256
 */
function jquery_dollar_js_alter(&$javascript) {
  $file = drupal_get_path('module', 'jquery_dollar') . '/jquery_dollar.js';

  // Copy all properties of drupal.js.
  $javascript[$file] = $javascript['misc/drupal.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 all other code to use the $ convention for writing jQuery code The reason is that forcing users to use special closures to…