You are here

function uc_add_js in Ubercart 5

Same name and namespace in other branches
  1. 6.2 uc_store/uc_store.module \uc_add_js()
41 calls to uc_add_js()
theme_uc_admin_dashboard in uc_store/uc_store.module
theme_uc_payment_method_select in payment/uc_payment/uc_payment_checkout_pane.inc
We need a theme function for the radios element in case another module alters the default or available payment methods... we need the JS to grab the right default payment details.
theme_uc_payment_pack_receive_check_form in payment/uc_payment_pack/uc_payment_pack.module
theme_uc_settings_overview in uc_store/uc_store.module
Theme an array of settings information into a pretty little table.
uc_cart_block in uc_cart/uc_cart.module
Implementation of hook_block().

... See full list

File

uc_store/uc_store.module, line 2882
Contains global Ubercart functions and store administration functionality.

Code

function uc_add_js($data = NULL, $type = 'module', $scope = 'header', $defer = FALSE, $cache = TRUE) {

  // If using the JS Aggregator module or some other module that this function
  // interferes with, uncomment the following two lines.
  // drupal_add_js($data, $type, $scope, $defer, $cache);
  // return;
  // If we're adding a module or theme .js file...
  if (($type == 'module' || $type == 'theme') && $cache) {

    // And the file actually exists...
    if (file_exists($data)) {

      // Add the file timestamp to the query so the browser-cached
      // javascript is updated when the file is updated.
      drupal_add_js($data . '?' . substr(filemtime($data), -5), $type, $scope, $defer, $cache);
    }
    else {

      // Log a file not found to the watchdog.
      watchdog('uc_store', t('Could not find JS file %path.', array(
        '%path' => $data,
      )), WATCHDOG_ERROR);
    }
  }
  else {
    drupal_add_js($data, $type, $scope, $defer, $cache);
  }
}