diff options
author | Angie Byron <webchick@24967.no-reply.drupal.org> | 2009-03-13 23:15:09 +0000 |
---|---|---|
committer | Angie Byron <webchick@24967.no-reply.drupal.org> | 2009-03-13 23:15:09 +0000 |
commit | b77475baf5eee88f7ca08adaf53c7c5eda6aca58 (patch) | |
tree | 4a1bf4029dc06956ceaa9c7373dbabb85e4dc3d0 /misc/drupal.js | |
parent | 35794257c39c915f15c23b968cd9edd166a12696 (diff) | |
download | brdo-b77475baf5eee88f7ca08adaf53c7c5eda6aca58.tar.gz brdo-b77475baf5eee88f7ca08adaf53c7c5eda6aca58.tar.bz2 |
#360081 by quicksketch: Stop using global variables for JavaScript settings.
Diffstat (limited to 'misc/drupal.js')
-rw-r--r-- | misc/drupal.js | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/misc/drupal.js b/misc/drupal.js index 9b99a1d2e..9e6d9c406 100644 --- a/misc/drupal.js +++ b/misc/drupal.js @@ -51,13 +51,17 @@ Drupal.jsEnabled = document.getElementsByTagName && document.createElement && do * @param context * An element to attach behaviors to. If none is given, the document element * is used. + * @param settings + * An object containing settings for the current context. If none given, the + * global Drupal.settings object is used. */ -Drupal.attachBehaviors = function(context) { +Drupal.attachBehaviors = function(context, settings) { context = context || document; + settings = settings || Drupal.settings; // Execute all of them. $.each(Drupal.behaviors, function() { if ($.isFunction(this.attach)) { - this.attach(context); + this.attach(context, settings); } }); }; @@ -81,12 +85,13 @@ Drupal.attachBehaviors = function(context) { * * @see Drupal.attachBehaviors */ -Drupal.detachBehaviors = function(context) { +Drupal.detachBehaviors = function(context, settings) { context = context || document; + settings = settings || Drupal.settings; // Execute all of them. $.each(Drupal.behaviors, function() { if ($.isFunction(this.detach)) { - this.detach(context); + this.detach(context, settings); } }); }; @@ -320,7 +325,7 @@ if (Drupal.jsEnabled) { document.cookie = 'has_js=1; path=/'; // Attach all behaviors. $(document).ready(function() { - Drupal.attachBehaviors(this); + Drupal.attachBehaviors(this, Drupal.settings); }); } |