Index: includes/common.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/common.inc,v
retrieving revision 1.824
diff -u -r1.824 common.inc
--- includes/common.inc 11 Nov 2008 22:39:58 -0000 1.824
+++ includes/common.inc 11 Nov 2008 23:48:55 -0000
@@ -2102,7 +2102,9 @@
* performed using this function:
*
* - Add a file ('file'):
- * Adds a reference to a JavaScript file to the page.
+ * Adds a reference to a JavaScript file to the page. This must either be
+ * relative to base_path(), or the absolute path to a JavaScript file hosted
+ * externally.
*
* - Add inline JavaScript code ('inline'):
* Executes a piece of JavaScript code on the current page by placing the code
@@ -2123,11 +2125,13 @@
* drupal_add_js('$(document).ready(function(){alert("Hello!");});',
* array('type' => 'inline', 'scope' => 'footer', 'weight' => 5)
* );
+ * drupal_add_js('http://yui.yahooapis.com/2.6.0/build/utilities/utilities.js');
* @endcode
*
* @param $data
* (optional) If given, the value depends on the $options parameter:
- * - 'file': Path to the file relative to base_path().
+ * - 'file': Path to the file relative to base_path(), or the absolute path
+ * to a JavaScript file hosted externally.
* - '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. All modules should wrap
@@ -2337,11 +2341,17 @@
break;
case 'file':
- if (!$item['preprocess'] || !$is_writable || !$preprocess_js) {
- $no_preprocess .= '\n";
+ // External scripts are embedded straight on the page.
+ if (valid_url($item['data'], TRUE)) {
+ $no_preprocess .= '\n";
}
else {
- $files[$item['data']] = $item;
+ if (!$item['preprocess'] || !$is_writable || !$preprocess_js) {
+ $no_preprocess .= '\n";
+ }
+ else {
+ $files[$item['data']] = $item;
+ }
}
break;
}