Mercurial > defr > drupal > core
comparison modules/system/system.js @ 1:c1f4ac30525a 6.0
Drupal 6.0
| author | Franck Deroche <webmaster@defr.org> |
|---|---|
| date | Tue, 23 Dec 2008 14:28:28 +0100 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| 0:5a113a1c4740 | 1:c1f4ac30525a |
|---|---|
| 1 // $Id: system.js,v 1.14.2.1 2008/02/07 18:23:30 goba Exp $ | |
| 2 | |
| 3 /** | |
| 4 * Internal function to check using Ajax if clean URLs can be enabled on the | |
| 5 * settings page. | |
| 6 * | |
| 7 * This function is not used to verify whether or not clean URLs | |
| 8 * are currently enabled. | |
| 9 */ | |
| 10 Drupal.behaviors.cleanURLsSettingsCheck = function(context) { | |
| 11 // This behavior attaches by ID, so is only valid once on a page. | |
| 12 // Also skip if we are on an install page, as Drupal.cleanURLsInstallCheck will handle | |
| 13 // the processing. | |
| 14 if ($("#clean-url.clean-url-processed, #clean-url.install").size()) { | |
| 15 return; | |
| 16 } | |
| 17 var url = Drupal.settings.basePath +"admin/settings/clean-urls/check"; | |
| 18 $("#clean-url .description span").html('<div id="testing">'+ Drupal.t('Testing clean URLs...') +"</div>"); | |
| 19 $("#clean-url p").hide(); | |
| 20 $.ajax({ | |
| 21 url: location.protocol +"//"+ location.host + url, | |
| 22 dataType: 'json', | |
| 23 success: function () { | |
| 24 // Check was successful. | |
| 25 $("#clean-url input.form-radio").attr("disabled", false); | |
| 26 $("#clean-url .description span").append('<div class="ok">'+ Drupal.t('Your server has been successfully tested to support this feature.') +"</div>"); | |
| 27 $("#testing").hide(); | |
| 28 }, | |
| 29 error: function() { | |
| 30 // Check failed. | |
| 31 $("#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>"); | |
| 32 $("#testing").hide(); | |
| 33 } | |
| 34 }); | |
| 35 $("#clean-url").addClass('clean-url-processed'); | |
| 36 }; | |
| 37 | |
| 38 /** | |
| 39 * Internal function to check using Ajax if clean URLs can be enabled on the | |
| 40 * install page. | |
| 41 * | |
| 42 * This function is not used to verify whether or not clean URLs | |
| 43 * are currently enabled. | |
| 44 */ | |
| 45 Drupal.cleanURLsInstallCheck = function() { | |
| 46 var url = location.protocol +"//"+ location.host + Drupal.settings.basePath +"admin/settings/clean-urls/check"; | |
| 47 $("#clean-url .description").append('<span><div id="testing">'+ Drupal.settings.cleanURL.testing +"</div></span>"); | |
| 48 $("#clean-url.install").css("display", "block"); | |
| 49 $.ajax({ | |
| 50 url: url, | |
| 51 dataType: 'json', | |
| 52 success: function () { | |
| 53 // Check was successful. | |
| 54 $("#clean-url input.form-radio").attr("disabled", false); | |
| 55 $("#clean-url input.form-radio").attr("checked", 1); | |
| 56 $("#clean-url .description span").append('<div class="ok">'+ Drupal.settings.cleanURL.success +"</div>"); | |
| 57 $("#testing").hide(); | |
| 58 }, | |
| 59 error: function() { | |
| 60 // Check failed. | |
| 61 $("#clean-url .description span").append('<div class="warning">'+ Drupal.settings.cleanURL.failure +"</div>"); | |
| 62 $("#testing").hide(); | |
| 63 } | |
| 64 }); | |
| 65 $("#clean-url").addClass('clean-url-processed'); | |
| 66 }; | |
| 67 | |
| 68 /** | |
| 69 * When a field is filled out, apply its value to other fields that will likely | |
| 70 * use the same value. In the installer this is used to populate the | |
| 71 * administrator e-mail address with the same value as the site e-mail address. | |
| 72 */ | |
| 73 Drupal.behaviors.copyFieldValue = function (context) { | |
| 74 for (var sourceId in Drupal.settings.copyFieldValue) { | |
| 75 // Get the list of target fields. | |
| 76 targetIds = Drupal.settings.copyFieldValue[sourceId]; | |
| 77 if (!$('#'+ sourceId + '.copy-field-values-processed').size(), context) { | |
| 78 // Add the behavior to update target fields on blur of the primary field. | |
| 79 sourceField = $('#' + sourceId); | |
| 80 sourceField.bind('blur', function() { | |
| 81 for (var delta in targetIds) { | |
| 82 var targetField = $('#'+ targetIds[delta]); | |
| 83 if (targetField.val() == '') { | |
| 84 targetField.val(this.value); | |
| 85 } | |
| 86 } | |
| 87 }); | |
| 88 sourceField.addClass('copy-field-values-processed'); | |
| 89 } | |
| 90 } | |
| 91 }; | |
| 92 | |
| 93 /** | |
| 94 * Show/hide custom format sections on the date-time settings page. | |
| 95 */ | |
| 96 Drupal.behaviors.dateTime = function(context) { | |
| 97 // Show/hide custom format depending on the select's value. | |
| 98 $('select.date-format:not(.date-time-processed)', context).change(function() { | |
| 99 $(this).addClass('date-time-processed').parents("div.date-container").children("div.custom-container")[$(this).val() == "custom" ? "show" : "hide"](); | |
| 100 }); | |
| 101 | |
| 102 // Attach keyup handler to custom format inputs. | |
| 103 $('input.custom-format:not(.date-time-processed)', context).addClass('date-time-processed').keyup(function() { | |
| 104 var input = $(this); | |
| 105 var url = Drupal.settings.dateTime.lookup +(Drupal.settings.dateTime.lookup.match(/\?q=/) ? "&format=" : "?format=") + Drupal.encodeURIComponent(input.val()); | |
| 106 $.getJSON(url, function(data) { | |
| 107 $("div.description span", input.parent()).html(data); | |
| 108 }); | |
| 109 }); | |
| 110 | |
| 111 // Trigger the event handler to show the form input if necessary. | |
| 112 $('select.date-format', context).trigger('change'); | |
| 113 }; |
