summaryrefslogtreecommitdiff
path: root/modules/system
diff options
context:
space:
mode:
Diffstat (limited to 'modules/system')
-rw-r--r--modules/system/system.js32
-rw-r--r--modules/system/system.module10
2 files changed, 23 insertions, 19 deletions
diff --git a/modules/system/system.js b/modules/system/system.js
index 11aa8b4b8..4da80811d 100644
--- a/modules/system/system.js
+++ b/modules/system/system.js
@@ -32,7 +32,7 @@ Drupal.behaviors.cleanURLsSettingsCheck = {
// 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 (!($('#edit-clean-url').size()) || $('.clean-url-processed, #edit-clean-url.install').size()) {
+ if (!($('#edit-clean-url').length) || $('#edit-clean-url.install').once('clean-url').length) {
return;
}
var url = settings.basePath + 'admin/config/search/clean-urls/check';
@@ -44,7 +44,6 @@ Drupal.behaviors.cleanURLsSettingsCheck = {
location = settings.basePath +"admin/config/search/clean-urls";
}
});
- $('#clean-url').addClass('clean-url-processed');
}
};
@@ -68,7 +67,6 @@ Drupal.cleanURLsInstallCheck = function () {
$('#edit-clean-url').attr('value', 1);
}
});
- $('#edit-clean-url').addClass('clean-url-processed');
};
/**
@@ -79,21 +77,17 @@ Drupal.cleanURLsInstallCheck = function () {
Drupal.behaviors.copyFieldValue = {
attach: function (context, settings) {
for (var sourceId in settings.copyFieldValue) {
- // Get the list of target fields.
- targetIds = settings.copyFieldValue[sourceId];
- if (!$('#'+ sourceId + '.copy-field-values-processed', context).size()) {
+ $('#' + sourceId, context).once('copy-field-values').bind('blur', function () {
+ // Get the list of target fields.
+ var targetIds = settings.copyFieldValue[sourceId];
// 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);
- }
+ for (var delta in targetIds) {
+ var targetField = $('#' + targetIds[delta]);
+ if (targetField.val() == '') {
+ targetField.val(this.value);
}
- });
- sourceField.addClass('copy-field-values-processed');
- }
+ }
+ });
}
}
};
@@ -104,12 +98,12 @@ Drupal.behaviors.copyFieldValue = {
Drupal.behaviors.dateTime = {
attach: function (context, settings) {
// 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']();
+ $('select.date-format', context).once('date-time').change(function () {
+ $(this).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 () {
+ $('input.custom-format', context).once('date-time').keyup(function () {
var input = $(this);
var url = settings.dateTime.lookup + (settings.dateTime.lookup.match(/\?q=/) ? '&format=' : '?format=') + encodeURIComponent(input.val());
$.getJSON(url, function (data) {
diff --git a/modules/system/system.module b/modules/system/system.module
index b975c8597..d9a29a0cb 100644
--- a/modules/system/system.module
+++ b/modules/system/system.module
@@ -933,6 +933,16 @@ function system_library() {
),
);
+ // jQuery Once.
+ $libraries['once'] = array(
+ 'title' => 'jQuery Once',
+ 'website' => 'http://plugins.jquery.com/project/once',
+ 'version' => '1.2',
+ 'js' => array(
+ 'misc/jquery.once.js' => array('weight' => JS_LIBRARY - 19),
+ ),
+ );
+
// jQuery Form Plugin.
$libraries['form'] = array(
'title' => 'jQuery Form Plugin',