_drupal_add_js

Versions
5
_drupal_add_js($data, $type, $scope, $defer, $cache)

Helper function for drupal_add_js().

Related topics

▾ 1 function calls _drupal_add_js()

drupal_add_js in includes/common.inc
Add a JavaScript file, setting or inline code to the page.

Code

includes/common.inc, line 1760

<?php
function _drupal_add_js($data, $type, $scope, $defer, $cache) {
  static $javascript = array();

  if (!isset($javascript[$scope])) {
    $javascript[$scope] = array('core' => array(), 'module' => array(), 'theme' => array(), 'setting' => array(), 'inline' => array());
  }

  if (!isset($javascript[$scope][$type])) {
    $javascript[$scope][$type] = array();
  }

  if (!is_null($data)) {
    switch ($type) {
      case 'setting':
        $javascript[$scope][$type][] = $data;
        break;
      case 'inline':
        $javascript[$scope][$type][] = array('code' => $data, 'defer' => $defer);
        break;
      default:
        $javascript[$scope][$type][$data] = array('cache' => $cache, 'defer' => $defer);
    }
  }

  return $javascript[$scope];
}
?>
Login or register to post comments
 
 

All source code and documentation on this site is released under the terms of the GNU General Public License, version 2 and later. Drupal is a registered trademark of Dries Buytaert.