summaryrefslogtreecommitdiff
path: root/misc
diff options
context:
space:
mode:
Diffstat (limited to 'misc')
-rw-r--r--misc/ahah.js6
-rw-r--r--misc/autocomplete.js2
-rw-r--r--misc/batch.js8
-rw-r--r--misc/collapse.js2
-rw-r--r--misc/drupal.js15
-rw-r--r--misc/form.js2
-rw-r--r--misc/tabledrag.js6
-rw-r--r--misc/tableheader.js2
-rw-r--r--misc/tableselect.js2
-rw-r--r--misc/teaser.js6
-rw-r--r--misc/textarea.js2
-rw-r--r--misc/timezone.js4
12 files changed, 31 insertions, 26 deletions
diff --git a/misc/ahah.js b/misc/ahah.js
index 91906c771..70199f35a 100644
--- a/misc/ahah.js
+++ b/misc/ahah.js
@@ -17,10 +17,10 @@
* Attaches the ahah behavior to each ahah form element.
*/
Drupal.behaviors.ahah = {
- attach: function(context) {
- for (var base in Drupal.settings.ahah) {
+ attach: function(context, settings) {
+ for (var base in settings.ahah) {
if (!$('#'+ base + '.ahah-processed').size()) {
- var element_settings = Drupal.settings.ahah[base];
+ var element_settings = settings.ahah[base];
$(element_settings.selector).each(function() {
element_settings.element = this;
diff --git a/misc/autocomplete.js b/misc/autocomplete.js
index 48253c70f..920865b4b 100644
--- a/misc/autocomplete.js
+++ b/misc/autocomplete.js
@@ -5,7 +5,7 @@
* Attaches the autocomplete behavior to all required fields.
*/
Drupal.behaviors.autocomplete = {
- attach: function(context) {
+ attach: function(context, settings) {
var acdb = [];
$('input.autocomplete:not(.autocomplete-processed)', context).each(function () {
var uri = this.value;
diff --git a/misc/batch.js b/misc/batch.js
index 17c4caae9..b603a2ffc 100644
--- a/misc/batch.js
+++ b/misc/batch.js
@@ -5,16 +5,16 @@
* Attaches the batch behavior to progress bars.
*/
Drupal.behaviors.batch = {
- attach: function(context) {
+ attach: function(context, settings) {
// This behavior attaches by ID, so is only valid once on a page.
if ($('#progress.batch-processed').size()) {
return;
}
$('#progress', context).addClass('batch-processed').each(function () {
var holder = this;
- var uri = Drupal.settings.batch.uri;
- var initMessage = Drupal.settings.batch.initMessage;
- var errorMessage = Drupal.settings.batch.errorMessage;
+ var uri = settings.batch.uri;
+ var initMessage = settings.batch.initMessage;
+ var errorMessage = settings.batch.errorMessage;
// Success: redirect to the summary.
var updateCallback = function (progress, status, pb) {
diff --git a/misc/collapse.js b/misc/collapse.js
index 7da7e16b1..35ebe5287 100644
--- a/misc/collapse.js
+++ b/misc/collapse.js
@@ -52,7 +52,7 @@ Drupal.collapseScrollIntoView = function (node) {
};
Drupal.behaviors.collapse = {
- attach: function(context) {
+ attach: function(context, settings) {
$('fieldset.collapsible > legend:not(.collapse-processed)', context).each(function() {
var fieldset = $(this.parentNode);
// Expand if there are errors inside
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);
});
}
diff --git a/misc/form.js b/misc/form.js
index fd34cd103..2a2e02dad 100644
--- a/misc/form.js
+++ b/misc/form.js
@@ -2,7 +2,7 @@
(function($) {
Drupal.behaviors.multiselectSelector = {
- attach: function(context) {
+ attach: function(context, settings) {
// Automatically selects the right radio button in a multiselect control.
$('.multiselect select:not(.multiselectSelector-processed)', context)
.addClass('multiselectSelector-processed').change(function() {
diff --git a/misc/tabledrag.js b/misc/tabledrag.js
index 78854406d..d07b3c780 100644
--- a/misc/tabledrag.js
+++ b/misc/tabledrag.js
@@ -13,10 +13,10 @@
* See blocks.js for an example of adding additional functionality to tableDrag.
*/
Drupal.behaviors.tableDrag = {
- attach: function(context) {
- for (var base in Drupal.settings.tableDrag) {
+ attach: function(context, settings) {
+ for (var base in settings.tableDrag) {
if (!$('#' + base + '.tabledrag-processed', context).size()) {
- var tableSettings = Drupal.settings.tableDrag[base];
+ var tableSettings = settings.tableDrag[base];
$('#' + base).filter(':not(.tabledrag-processed)').each(function() {
// Create the new tableDrag instance. Save in the Drupal variable
diff --git a/misc/tableheader.js b/misc/tableheader.js
index 1c8c9bf1c..fbc317583 100644
--- a/misc/tableheader.js
+++ b/misc/tableheader.js
@@ -8,7 +8,7 @@ Drupal.tableHeaderDoScroll = function() {
};
Drupal.behaviors.tableHeader = {
- attach: function(context) {
+ attach: function(context, settings) {
// This breaks in anything less than IE 7. Prevent it from running.
if ($.browser.msie && parseInt($.browser.version, 10) < 7) {
return;
diff --git a/misc/tableselect.js b/misc/tableselect.js
index 152e93fb4..43a5c2aa6 100644
--- a/misc/tableselect.js
+++ b/misc/tableselect.js
@@ -2,7 +2,7 @@
(function($) {
Drupal.behaviors.tableSelect = {
- attach: function(context) {
+ attach: function(context, settings) {
$('form table:has(th.select-all):not(.tableSelect-processed)', context).each(Drupal.tableSelect);
}
};
diff --git a/misc/teaser.js b/misc/teaser.js
index c7cdf5654..abb008bc7 100644
--- a/misc/teaser.js
+++ b/misc/teaser.js
@@ -7,13 +7,13 @@
* Note: depends on resizable textareas.
*/
Drupal.behaviors.teaser = {
- attach: function(context) {
+ attach: function(context, settings) {
$('textarea.teaser:not(.teaser-processed)', context).each(function() {
var teaser = $(this).addClass('teaser-processed');
// Move teaser textarea before body, and remove its form-item wrapper.
- var body = $('#'+ Drupal.settings.teaser[this.id]);
- var checkbox = $('#'+ Drupal.settings.teaserCheckbox[this.id]).parent();
+ var body = $('#'+ settings.teaser[this.id]);
+ var checkbox = $('#'+ settings.teaserCheckbox[this.id]).parent();
var checked = $(checkbox).children('input').attr('checked') ? true : false;
var parent = teaser[0].parentNode;
$(body).before(teaser);
diff --git a/misc/textarea.js b/misc/textarea.js
index 68e696b2d..2f7ee8d3c 100644
--- a/misc/textarea.js
+++ b/misc/textarea.js
@@ -2,7 +2,7 @@
(function($) {
Drupal.behaviors.textarea = {
- attach: function(context) {
+ attach: function(context, settings) {
$('textarea.resizable:not(.textarea-processed)', context).each(function() {
// Avoid non-processed teasers.
if ($(this).is(('textarea.teaser:not(.teaser-processed)'))) {
diff --git a/misc/timezone.js b/misc/timezone.js
index db7c4560a..c877353af 100644
--- a/misc/timezone.js
+++ b/misc/timezone.js
@@ -5,7 +5,7 @@
* Set the client's system time zone as default values of form fields.
*/
Drupal.behaviors.setTimezone = {
- attach: function(context) {
+ attach: function(context, settings) {
$('select.timezone-detect:not(.timezone-processed)', context).addClass('timezone-processed').each(function() {
var dateString = Date();
// In some client environments, date strings include a time zone
@@ -51,7 +51,7 @@ Drupal.behaviors.setTimezone = {
var element = this;
$.ajax({
async: false,
- url: Drupal.settings.basePath,
+ url: settings.basePath,
data: { q: path, date: dateString },
dataType: 'json',
success: function (data) {