Commit 5120c8a8 authored by Gábor Hojtsy's avatar Gábor Hojtsy
Browse files

#194026 by mfer: if only themes add JS files, drupal.js and jquery.js were not added

parent e9f52b42
......@@ -1816,8 +1816,10 @@ function drupal_clear_css_cache() {
function drupal_add_js($data = NULL, $type = 'module', $scope = 'header', $defer = FALSE, $cache = TRUE, $preprocess = TRUE) {
static $javascript = array();
if (isset($data)) {
// Add jquery.js and drupal.js the first time a Javascript file is added.
if (isset($data) && empty($javascript)) {
if (empty($javascript)) {
$javascript['header'] = array(
'core' => array(
'misc/jquery.js' => array('cache' => TRUE, 'defer' => FALSE, 'preprocess' => TRUE),
......@@ -1826,6 +1828,7 @@ function drupal_add_js($data = NULL, $type = 'module', $scope = 'header', $defer
'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());
}
......@@ -1834,7 +1837,6 @@ function drupal_add_js($data = NULL, $type = 'module', $scope = 'header', $defer
$javascript[$scope][$type] = array();
}
if (isset($data)) {
switch ($type) {
case 'setting':
$javascript[$scope][$type][] = $data;
......@@ -1849,8 +1851,14 @@ function drupal_add_js($data = NULL, $type = 'module', $scope = 'header', $defer
}
if (isset($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 '';
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment