|
1 (function ($) { |
|
2 |
|
3 /** |
|
4 * Show/hide the 'Email site administrator when updates are available' checkbox |
|
5 * on the install page. |
|
6 */ |
|
7 Drupal.hideEmailAdministratorCheckbox = function () { |
|
8 // Make sure the secondary box is shown / hidden as necessary on page load. |
|
9 if ($('#edit-update-status-module-1').is(':checked')) { |
|
10 $('.form-item-update-status-module-2').show(); |
|
11 } |
|
12 else { |
|
13 $('.form-item-update-status-module-2').hide(); |
|
14 } |
|
15 |
|
16 // Toggle the display as necessary when the checkbox is clicked. |
|
17 $('#edit-update-status-module-1').change( function () { |
|
18 $('.form-item-update-status-module-2').toggle(); |
|
19 }); |
|
20 }; |
|
21 |
|
22 /** |
|
23 * Internal function to check using Ajax if clean URLs can be enabled on the |
|
24 * settings page. |
|
25 * |
|
26 * This function is not used to verify whether or not clean URLs |
|
27 * are currently enabled. |
|
28 */ |
|
29 Drupal.behaviors.cleanURLsSettingsCheck = { |
|
30 attach: function (context, settings) { |
|
31 // This behavior attaches by ID, so is only valid once on a page. |
|
32 // Also skip if we are on an install page, as Drupal.cleanURLsInstallCheck will handle |
|
33 // the processing. |
|
34 if (!($('#edit-clean-url').length) || $('#edit-clean-url.install').once('clean-url').length) { |
|
35 return; |
|
36 } |
|
37 var url = settings.basePath + 'admin/config/search/clean-urls/check'; |
|
38 $.ajax({ |
|
39 url: location.protocol + '//' + location.host + url, |
|
40 dataType: 'json', |
|
41 success: function () { |
|
42 // Check was successful. Redirect using a "clean URL". This will force the form that allows enabling clean URLs. |
|
43 location = settings.basePath +"admin/config/search/clean-urls"; |
|
44 } |
|
45 }); |
|
46 } |
|
47 }; |
|
48 |
|
49 /** |
|
50 * Internal function to check using Ajax if clean URLs can be enabled on the |
|
51 * install page. |
|
52 * |
|
53 * This function is not used to verify whether or not clean URLs |
|
54 * are currently enabled. |
|
55 */ |
|
56 Drupal.cleanURLsInstallCheck = function () { |
|
57 var url = location.protocol + '//' + location.host + Drupal.settings.basePath + 'admin/config/search/clean-urls/check'; |
|
58 // Submit a synchronous request to avoid database errors associated with |
|
59 // concurrent requests during install. |
|
60 $.ajax({ |
|
61 async: false, |
|
62 url: url, |
|
63 dataType: 'json', |
|
64 success: function () { |
|
65 // Check was successful. |
|
66 $('#edit-clean-url').attr('value', 1); |
|
67 } |
|
68 }); |
|
69 }; |
|
70 |
|
71 /** |
|
72 * When a field is filled out, apply its value to other fields that will likely |
|
73 * use the same value. In the installer this is used to populate the |
|
74 * administrator e-mail address with the same value as the site e-mail address. |
|
75 */ |
|
76 Drupal.behaviors.copyFieldValue = { |
|
77 attach: function (context, settings) { |
|
78 for (var sourceId in settings.copyFieldValue) { |
|
79 $('#' + sourceId, context).once('copy-field-values').bind('blur', function () { |
|
80 // Get the list of target fields. |
|
81 var targetIds = settings.copyFieldValue[sourceId]; |
|
82 // Add the behavior to update target fields on blur of the primary field. |
|
83 for (var delta in targetIds) { |
|
84 var targetField = $('#' + targetIds[delta]); |
|
85 if (targetField.val() == '') { |
|
86 targetField.val(this.value); |
|
87 } |
|
88 } |
|
89 }); |
|
90 } |
|
91 } |
|
92 }; |
|
93 |
|
94 /** |
|
95 * Show/hide custom format sections on the regional settings page. |
|
96 */ |
|
97 Drupal.behaviors.dateTime = { |
|
98 attach: function (context, settings) { |
|
99 for (var fieldName in settings.dateTime) { |
|
100 if (settings.dateTime.hasOwnProperty(fieldName)) { |
|
101 (function (fieldSettings, fieldName) { |
|
102 var source = '#edit-' + fieldName; |
|
103 var suffix = source + '-suffix'; |
|
104 |
|
105 // Attach keyup handler to custom format inputs. |
|
106 $('input' + source, context).once('date-time').keyup(function () { |
|
107 var input = $(this); |
|
108 var url = fieldSettings.lookup + (/\?/.test(fieldSettings.lookup) ? '&format=' : '?format=') + encodeURIComponent(input.val()); |
|
109 $.getJSON(url, function (data) { |
|
110 $(suffix).empty().append(' ' + fieldSettings.text + ': <em>' + data + '</em>'); |
|
111 }); |
|
112 }); |
|
113 })(settings.dateTime[fieldName], fieldName); |
|
114 } |
|
115 } |
|
116 } |
|
117 }; |
|
118 |
|
119 /** |
|
120 * Show/hide settings for page caching depending on whether page caching is |
|
121 * enabled or not. |
|
122 */ |
|
123 Drupal.behaviors.pageCache = { |
|
124 attach: function (context, settings) { |
|
125 $('#edit-cache-0', context).change(function () { |
|
126 $('#page-compression-wrapper').hide(); |
|
127 $('#cache-error').hide(); |
|
128 }); |
|
129 $('#edit-cache-1', context).change(function () { |
|
130 $('#page-compression-wrapper').show(); |
|
131 $('#cache-error').hide(); |
|
132 }); |
|
133 $('#edit-cache-2', context).change(function () { |
|
134 $('#page-compression-wrapper').show(); |
|
135 $('#cache-error').show(); |
|
136 }); |
|
137 } |
|
138 }; |
|
139 |
|
140 })(jQuery); |