summaryrefslogtreecommitdiff
path: root/modules/system/system.js
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2008-10-29 10:01:28 +0000
committerDries Buytaert <dries@buytaert.net>2008-10-29 10:01:28 +0000
commit5371104a2d10889c532bb5d345fa6d71c0a897d1 (patch)
treebbef382cea55823195e0cb7469074b743913bc74 /modules/system/system.js
parent068febde425f4521d61f863ffaca76da65916449 (diff)
downloadbrdo-5371104a2d10889c532bb5d345fa6d71c0a897d1.tar.gz
brdo-5371104a2d10889c532bb5d345fa6d71c0a897d1.tar.bz2
- Patch #316225 by sun et al: allow behaviors to detach from AHAH/AJAX.
Diffstat (limited to 'modules/system/system.js')
-rw-r--r--modules/system/system.js114
1 files changed, 60 insertions, 54 deletions
diff --git a/modules/system/system.js b/modules/system/system.js
index c2abc8a89..3b477739e 100644
--- a/modules/system/system.js
+++ b/modules/system/system.js
@@ -7,32 +7,34 @@
* This function is not used to verify whether or not clean URLs
* are currently enabled.
*/
-Drupal.behaviors.cleanURLsSettingsCheck = function(context) {
- // This behavior attaches by ID, so is only valid once on a page.
- // Also skip if we are on an install page, as Drupal.cleanURLsInstallCheck will handle
- // the processing.
- if ($("#clean-url.clean-url-processed, #clean-url.install").size()) {
- return;
- }
- var url = Drupal.settings.basePath +"admin/settings/clean-urls/check";
- $("#clean-url .description span").html('<div id="testing">'+ Drupal.t('Testing clean URLs...') +"</div>");
- $("#clean-url p").hide();
- $.ajax({
- url: location.protocol +"//"+ location.host + url,
- dataType: 'json',
- success: function () {
- // Check was successful.
- $("#clean-url input.form-radio").attr("disabled", false);
- $("#clean-url .description span").append('<div class="ok">'+ Drupal.t('Your server has been successfully tested to support this feature.') +"</div>");
- $("#testing").hide();
- },
- error: function() {
- // Check failed.
- $("#clean-url .description span").append('<div class="warning">'+ Drupal.t('Your system configuration does not currently support this feature. The <a href="http://drupal.org/node/15365">handbook page on Clean URLs</a> has additional troubleshooting information.') +"</div>");
- $("#testing").hide();
+Drupal.behaviors.cleanURLsSettingsCheck = {
+ attach: function(context) {
+ // This behavior attaches by ID, so is only valid once on a page.
+ // Also skip if we are on an install page, as Drupal.cleanURLsInstallCheck will handle
+ // the processing.
+ if ($("#clean-url.clean-url-processed, #clean-url.install").size()) {
+ return;
}
- });
- $("#clean-url").addClass('clean-url-processed');
+ var url = Drupal.settings.basePath +"admin/settings/clean-urls/check";
+ $("#clean-url .description span").html('<div id="testing">'+ Drupal.t('Testing clean URLs...') +"</div>");
+ $("#clean-url p").hide();
+ $.ajax({
+ url: location.protocol +"//"+ location.host + url,
+ dataType: 'json',
+ success: function () {
+ // Check was successful.
+ $("#clean-url input.form-radio").attr("disabled", false);
+ $("#clean-url .description span").append('<div class="ok">'+ Drupal.t('Your server has been successfully tested to support this feature.') +"</div>");
+ $("#testing").hide();
+ },
+ error: function() {
+ // Check failed.
+ $("#clean-url .description span").append('<div class="warning">'+ Drupal.t('Your system configuration does not currently support this feature. The <a href="http://drupal.org/node/15365">handbook page on Clean URLs</a> has additional troubleshooting information.') +"</div>");
+ $("#testing").hide();
+ }
+ });
+ $("#clean-url").addClass('clean-url-processed');
+ }
};
/**
@@ -70,22 +72,24 @@ Drupal.cleanURLsInstallCheck = function() {
* use the same value. In the installer this is used to populate the
* administrator e-mail address with the same value as the site e-mail address.
*/
-Drupal.behaviors.copyFieldValue = function (context) {
- for (var sourceId in Drupal.settings.copyFieldValue) {
- // Get the list of target fields.
- targetIds = Drupal.settings.copyFieldValue[sourceId];
- if (!$('#'+ sourceId + '.copy-field-values-processed').size(), context) {
- // Add the behavior to update target fields on blur of the primary field.
- sourceField = $('#' + sourceId);
- sourceField.bind('blur', function() {
- for (var delta in targetIds) {
- var targetField = $('#'+ targetIds[delta]);
- if (targetField.val() == '') {
- targetField.val(this.value);
+Drupal.behaviors.copyFieldValue = {
+ attach: function(context) {
+ for (var sourceId in Drupal.settings.copyFieldValue) {
+ // Get the list of target fields.
+ targetIds = Drupal.settings.copyFieldValue[sourceId];
+ if (!$('#'+ sourceId + '.copy-field-values-processed').size(), context) {
+ // Add the behavior to update target fields on blur of the primary field.
+ sourceField = $('#' + sourceId);
+ sourceField.bind('blur', function() {
+ for (var delta in targetIds) {
+ var targetField = $('#'+ targetIds[delta]);
+ if (targetField.val() == '') {
+ targetField.val(this.value);
+ }
}
- }
- });
- sourceField.addClass('copy-field-values-processed');
+ });
+ sourceField.addClass('copy-field-values-processed');
+ }
}
}
};
@@ -93,21 +97,23 @@ Drupal.behaviors.copyFieldValue = function (context) {
/**
* Show/hide custom format sections on the date-time settings page.
*/
-Drupal.behaviors.dateTime = function(context) {
- // Show/hide custom format depending on the select's value.
- $('select.date-format:not(.date-time-processed)', context).change(function() {
- $(this).addClass('date-time-processed').parents("div.date-container").children("div.custom-container")[$(this).val() == "custom" ? "show" : "hide"]();
- });
+Drupal.behaviors.dateTime = {
+ attach: function(context) {
+ // Show/hide custom format depending on the select's value.
+ $('select.date-format:not(.date-time-processed)', context).change(function() {
+ $(this).addClass('date-time-processed').parents("div.date-container").children("div.custom-container")[$(this).val() == "custom" ? "show" : "hide"]();
+ });
- // Attach keyup handler to custom format inputs.
- $('input.custom-format:not(.date-time-processed)', context).addClass('date-time-processed').keyup(function() {
- var input = $(this);
- var url = Drupal.settings.dateTime.lookup +(Drupal.settings.dateTime.lookup.match(/\?q=/) ? "&format=" : "?format=") + Drupal.encodeURIComponent(input.val());
- $.getJSON(url, function(data) {
- $("div.description span", input.parent()).html(data);
+ // Attach keyup handler to custom format inputs.
+ $('input.custom-format:not(.date-time-processed)', context).addClass('date-time-processed').keyup(function() {
+ var input = $(this);
+ var url = Drupal.settings.dateTime.lookup +(Drupal.settings.dateTime.lookup.match(/\?q=/) ? "&format=" : "?format=") + Drupal.encodeURIComponent(input.val());
+ $.getJSON(url, function(data) {
+ $("div.description span", input.parent()).html(data);
+ });
});
- });
- // Trigger the event handler to show the form input if necessary.
- $('select.date-format', context).trigger('change');
+ // Trigger the event handler to show the form input if necessary.
+ $('select.date-format', context).trigger('change');
+ }
};