Newer
Older
Angie Byron
committed
(function ($) {
Dries Buytaert
committed
/**
* 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')) {
Angie Byron
committed
$('.form-item-update-status-module-2').show();
Dries Buytaert
committed
}
else {
Angie Byron
committed
$('.form-item-update-status-module-2').hide();
Dries Buytaert
committed
}
// Toggle the display as necessary when the checkbox is clicked.
$('#edit-update-status-module-1').change( function () {
Angie Byron
committed
$('.form-item-update-status-module-2').toggle();
Dries Buytaert
committed
};
Dries Buytaert
committed
/**
* Internal function to check using Ajax if clean URLs can be enabled on the
* settings page.
*
* This function is not used to verify whether or not clean URLs
* are currently enabled.
*/
Drupal.behaviors.cleanURLsSettingsCheck = {
Angie Byron
committed
attach: function (context, settings) {
// 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.
Dries Buytaert
committed
if (!($('#edit-clean-url').length) || $('#edit-clean-url.install').once('clean-url').length) {
return;
Dries Buytaert
committed
}
Angie Byron
committed
var url = settings.basePath + 'admin/config/search/clean-urls/check';
$.ajax({
Angie Byron
committed
url: location.protocol + '//' + location.host + url,
dataType: 'json',
Angie Byron
committed
success: function () {
Dries Buytaert
committed
// Check was successful. Redirect using a "clean URL". This will force the form that allows enabling clean URLs.
Angie Byron
committed
location = settings.basePath +"admin/config/search/clean-urls";
}
});
}
Dries Buytaert
committed
/**
* Internal function to check using Ajax if clean URLs can be enabled on the
* install page.
*
* This function is not used to verify whether or not clean URLs
* are currently enabled.
*/
Angie Byron
committed
Drupal.cleanURLsInstallCheck = function () {
Angie Byron
committed
var url = location.protocol + '//' + location.host + Drupal.settings.basePath + 'admin/config/search/clean-urls/check';
Angie Byron
committed
// Submit a synchronous request to avoid database errors associated with
// concurrent requests during install.
Gábor Hojtsy
committed
$.ajax({
Angie Byron
committed
async: false,
Gábor Hojtsy
committed
url: url,
dataType: 'json',
Angie Byron
committed
success: function () {
Dries Buytaert
committed
// Check was successful.
Angie Byron
committed
$('#edit-clean-url').attr('value', 1);
}
Gábor Hojtsy
committed
});
Dries Buytaert
committed
Dries Buytaert
committed
/**
* 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 = {
Angie Byron
committed
attach: function (context, settings) {
for (var sourceId in settings.copyFieldValue) {
Dries Buytaert
committed
$('#' + 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.
Dries Buytaert
committed
for (var delta in targetIds) {
var targetField = $('#' + targetIds[delta]);
if (targetField.val() == '') {
targetField.val(this.value);
Dries Buytaert
committed
}
Dries Buytaert
committed
}
});
Dries Buytaert
committed
}
}
Gábor Hojtsy
committed
};
Dries Buytaert
committed
* Show/hide custom format sections on the regional settings page.
Drupal.behaviors.dateTime = {
Angie Byron
committed
attach: function (context, settings) {
Dries Buytaert
committed
for (var value in settings.dateTime) {
var settings = settings.dateTime[value];
var source = '#edit-' + value;
var suffix = source + '-suffix';
Dries Buytaert
committed
// Attach keyup handler to custom format inputs.
$('input' + source, context).once('date-time').keyup(function () {
var input = $(this);
var url = settings.lookup + (settings.lookup.match(/\?q=/) ? '&format=' : '?format=') + encodeURIComponent(input.val());
$.getJSON(url, function (data) {
$(suffix).empty().append(' ' + settings.text + ': <em>' + data + '</em>');
});
});
Dries Buytaert
committed
}
}
Gábor Hojtsy
committed
};
Dries Buytaert
committed
/**
* Show/hide settings for page caching depending on whether page caching is
* enabled or not.
*/
Drupal.behaviors.pageCache = {
attach: function (context, settings) {
$('#edit-cache-0', context).change(function () {
$('#page-compression-wrapper').hide();
$('#cache-error').hide();
});
$('#edit-cache-1', context).change(function () {
$('#page-compression-wrapper').show();
$('#cache-error').hide();
});
$('#edit-cache-2', context).change(function () {
$('#page-compression-wrapper').show();
$('#cache-error').show();
});
Dries Buytaert
committed
}
})(jQuery);