95 lines
3.0 KiB
JavaScript
95 lines
3.0 KiB
JavaScript
(function ($) {
|
|
|
|
"use strict";
|
|
|
|
/**
|
|
* Show/hide the 'Email site administrator when updates are available' checkbox
|
|
* on the install page.
|
|
*/
|
|
Drupal.hideEmailAdministratorCheckbox = function () {
|
|
// Make sure the secondary box is shown / hidden as necessary on page load.
|
|
if ($('#edit-update-status-module-1').is(':checked')) {
|
|
$('.form-item-update-status-module-2').show();
|
|
}
|
|
else {
|
|
$('.form-item-update-status-module-2').hide();
|
|
}
|
|
|
|
// Toggle the display as necessary when the checkbox is clicked.
|
|
$('#edit-update-status-module-1').change( function () {
|
|
$('.form-item-update-status-module-2').toggle();
|
|
});
|
|
};
|
|
|
|
/**
|
|
* When a field is filled out, apply its value to other fields that will likely
|
|
* 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 = {
|
|
attach: function (context, settings) {
|
|
for (var sourceId in settings.copyFieldValue) {
|
|
$('#' + 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.
|
|
for (var delta in targetIds) {
|
|
var targetField = $('#' + targetIds[delta]);
|
|
if (targetField.val() == '') {
|
|
targetField.val(this.value);
|
|
}
|
|
}
|
|
});
|
|
}
|
|
}
|
|
};
|
|
|
|
/**
|
|
* Show/hide custom format sections on the regional settings page.
|
|
*/
|
|
Drupal.behaviors.dateTime = {
|
|
attach: function (context, settings) {
|
|
for (var fieldName in settings.dateTime) {
|
|
if (settings.dateTime.hasOwnProperty(fieldName)) {
|
|
(function (fieldSettings, fieldName) {
|
|
var source = '#edit-' + fieldName;
|
|
var suffix = source + '-suffix';
|
|
|
|
// Attach keyup handler to custom format inputs.
|
|
$(context).find('input' + source).once('date-time').keyup(function () {
|
|
var input = $(this);
|
|
var url = fieldSettings.lookup + (/\?q=/.test(fieldSettings.lookup) ? '&format=' : '?format=') + encodeURIComponent(input.val());
|
|
$.getJSON(url, function (data) {
|
|
$(suffix).empty().append(' ' + fieldSettings.text + ': <em>' + data + '</em>');
|
|
});
|
|
});
|
|
})(settings.dateTime[fieldName], fieldName);
|
|
}
|
|
}
|
|
}
|
|
};
|
|
|
|
/**
|
|
* Show/hide settings for page caching depending on whether page caching is
|
|
* enabled or not.
|
|
*/
|
|
Drupal.behaviors.pageCache = {
|
|
attach: function (context, settings) {
|
|
var $context = $(context);
|
|
$context.find('#edit-cache-0').change(function () {
|
|
$('#page-compression-wrapper').hide();
|
|
$('#cache-error').hide();
|
|
});
|
|
$context.find('#edit-cache-1').change(function () {
|
|
$('#page-compression-wrapper').show();
|
|
$('#cache-error').hide();
|
|
});
|
|
$context.find('#edit-cache-2').change(function () {
|
|
$('#page-compression-wrapper').show();
|
|
$('#cache-error').show();
|
|
});
|
|
}
|
|
};
|
|
|
|
})(jQuery);
|