Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set the has_js cookie for authenticated users #9

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions includes/common.inc
Original file line number Diff line number Diff line change
Expand Up @@ -2180,6 +2180,13 @@ function drupal_add_js($data = NULL, $type = 'module', $scope = 'header', $defer
),
'inline' => array(),
);

// We never cache authenticated user pages, so if they are logged in we
// allow setting of the has_js cookie so batch API functions use the JS
// version.
if (!user_is_anonymous()) {
$javascript['header']['core']['misc/jsenabled.js'] = array('cache' => TRUE, 'defer' => FALSE, 'preprocess' => TRUE);
}
}

if (isset($scope) && !isset($javascript[$scope])) {
Expand Down
12 changes: 7 additions & 5 deletions misc/drupal.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ var Drupal = Drupal || { 'settings': {}, 'behaviors': {}, 'themes': {}, 'locale'
/**
* Set the variable that indicates if JavaScript behaviors should be applied
*/
Drupal.jsEnabled = true;
Drupal.jsEnabled = document.getElementsByTagName && document.createElement && document.createTextNode && document.documentElement && document.getElementById;

/**
* Attach all registered behaviors to a page element.
Expand Down Expand Up @@ -35,10 +35,12 @@ Drupal.jsEnabled = true;
*/
Drupal.attachBehaviors = function(context) {
context = context || document;
// Execute all of them.
jQuery.each(Drupal.behaviors, function() {
this(context);
});
if (Drupal.jsEnabled) {
// Execute all of them.
jQuery.each(Drupal.behaviors, function() {
this(context);
});
}
};

/**
Expand Down
5 changes: 5 additions & 0 deletions misc/jsenabled.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
if (Drupal.jsEnabled) {
// 'js enabled' cookie
document.cookie = 'has_js=1; path=/';
}