From d1d3ce0be71254fd95991cefd508f4246a33e2f9 Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Wed, 22 Oct 2008 19:39:36 +0000 Subject: - Patch #315797 by mfer, Rob Loach, et al: rework the parameter of drupal_add_js. --- includes/batch.inc | 4 +- includes/common.inc | 131 +++++++++++++++++++++++++++++++++------------------- 2 files changed, 86 insertions(+), 49 deletions(-) (limited to 'includes') diff --git a/includes/batch.inc b/includes/batch.inc index 2cc41a922..d9d5b2a98 100644 --- a/includes/batch.inc +++ b/includes/batch.inc @@ -84,7 +84,7 @@ function _batch_progress_page_js() { // error messages. Only safe strings should be passed in to batch_set(). $current_set = _batch_current_set(); drupal_set_title($current_set['title'], PASS_THROUGH); - drupal_add_js('misc/progress.js', 'core', 'header', FALSE, FALSE); + drupal_add_js('misc/progress.js', array('type' => 'core', 'cache' => FALSE)); $url = url($batch['url'], array('query' => array('id' => $batch['id']))); $js_setting = array( @@ -95,7 +95,7 @@ function _batch_progress_page_js() { ), ); drupal_add_js($js_setting, 'setting'); - drupal_add_js('misc/batch.js', 'core', 'header', FALSE, FALSE); + drupal_add_js('misc/batch.js', array('type' => 'core', 'cache' => FALSE)); $output = '
'; return $output; diff --git a/includes/common.inc b/includes/common.inc index 326d6a09d..0c6fd0ab7 100644 --- a/includes/common.inc +++ b/includes/common.inc @@ -2046,57 +2046,100 @@ function drupal_clear_css_cache() { * settings are required by some modules to function properly. The settings * will be accessible at Drupal.settings. * + * Examples: + * @code + * drupal_add_js('misc/collapse.js'); + * drupal_add_js('misc/collapse.js', 'module'); + * drupal_add_js('$(document).ready(function(){alert("Hello!");});', + * array('type' => 'inline', 'scope' => 'footer') + * ); + * @endcode + * * @param $data - * (optional) If given, the value depends on the $type parameter: + * (optional) If given, the value depends on the $options parameter: * - 'core', 'module' or 'theme': Path to the file relative to base_path(). * - 'inline': The JavaScript code that should be placed in the given scope. * - 'setting': An array with configuration options as associative array. The * array is directly placed in Drupal.settings. You might want to wrap your * actual configuration settings in another variable to prevent the pollution * of the Drupal.settings namespace. - * @param $type - * (optional) The type of JavaScript that should be added to the page. Allowed - * values are 'core', 'module', 'theme', 'inline' and 'setting'. You - * can, however, specify any value. It is treated as a reference to a JavaScript - * file. Defaults to 'module'. - * @param $scope - * (optional) The location in which you want to place the script. Possible - * values are 'header' and 'footer' by default. If your theme implements - * different locations, however, you can also use these. - * @param $defer - * (optional) If set to TRUE, the defer attribute is set on the