summaryrefslogtreecommitdiff
path: root/includes
diff options
context:
space:
mode:
authorGábor Hojtsy <gabor@hojtsy.hu>2007-11-30 15:31:13 +0000
committerGábor Hojtsy <gabor@hojtsy.hu>2007-11-30 15:31:13 +0000
commit5120c8a8ddbd1f7269e330dbe835d6593104e4d2 (patch)
tree370664e19c5859b5b6d2348acdf6d6adce2aa19e /includes
parente9f52b4248a5268630b51ee0746dcf8b6449d445 (diff)
downloadbrdo-5120c8a8ddbd1f7269e330dbe835d6593104e4d2.tar.gz
brdo-5120c8a8ddbd1f7269e330dbe835d6593104e4d2.tar.bz2
#194026 by mfer: if only themes add JS files, drupal.js and jquery.js were not added
Diffstat (limited to 'includes')
-rw-r--r--includes/common.inc48
1 files changed, 28 insertions, 20 deletions
diff --git a/includes/common.inc b/includes/common.inc
index 4af694080..fe41d29ce 100644
--- a/includes/common.inc
+++ b/includes/common.inc
@@ -1816,25 +1816,27 @@ function drupal_clear_css_cache() {
function drupal_add_js($data = NULL, $type = 'module', $scope = 'header', $defer = FALSE, $cache = TRUE, $preprocess = TRUE) {
static $javascript = array();
- // Add jquery.js and drupal.js the first time a Javascript file is added.
- if (isset($data) && empty($javascript)) {
- $javascript['header'] = array(
- 'core' => array(
- 'misc/jquery.js' => array('cache' => TRUE, 'defer' => FALSE, 'preprocess' => TRUE),
- 'misc/drupal.js' => array('cache' => TRUE, 'defer' => FALSE, 'preprocess' => TRUE),
- ),
- 'module' => array(), 'theme' => array(), 'setting' => array(), 'inline' => array(),
- );
- }
- if (isset($scope) && !isset($javascript[$scope])) {
- $javascript[$scope] = array('core' => array(), 'module' => array(), 'theme' => array(), 'setting' => array(), 'inline' => array());
- }
-
- if (isset($type) && isset($scope) && !isset($javascript[$scope][$type])) {
- $javascript[$scope][$type] = array();
- }
-
if (isset($data)) {
+
+ // Add jquery.js and drupal.js the first time a Javascript file is added.
+ if (empty($javascript)) {
+ $javascript['header'] = array(
+ 'core' => array(
+ 'misc/jquery.js' => array('cache' => TRUE, 'defer' => FALSE, 'preprocess' => TRUE),
+ 'misc/drupal.js' => array('cache' => TRUE, 'defer' => FALSE, 'preprocess' => TRUE),
+ ),
+ 'module' => array(), 'theme' => array(), 'setting' => array(), 'inline' => array(),
+ );
+ }
+
+ if (isset($scope) && !isset($javascript[$scope])) {
+ $javascript[$scope] = array('core' => array(), 'module' => array(), 'theme' => array(), 'setting' => array(), 'inline' => array());
+ }
+
+ if (isset($type) && isset($scope) && !isset($javascript[$scope][$type])) {
+ $javascript[$scope][$type] = array();
+ }
+
switch ($type) {
case 'setting':
$javascript[$scope][$type][] = $data;
@@ -1849,7 +1851,13 @@ function drupal_add_js($data = NULL, $type = 'module', $scope = 'header', $defer
}
if (isset($scope)) {
- return $javascript[$scope];
+
+ if (isset($javascript[$scope])) {
+ return $javascript[$scope];
+ }
+ else {
+ return array();
+ }
}
else {
return $javascript;
@@ -1883,7 +1891,7 @@ function drupal_get_js($scope = 'header', $javascript = NULL) {
$javascript = drupal_add_js(NULL, NULL, $scope);
}
- if (count($javascript) < 1) {
+ if (empty($javascript)) {
return '';
}