| 1 |
/**
|
| 2 |
* Show/hide custom format sections on the date-time settings page.
|
| 3 |
*/
|
| 4 |
Drupal.behaviors.dateDateTime = function(context) {
|
| 5 |
// Show/hide custom format depending on the select's value.
|
| 6 |
$('select.date-format:not(.date-time-processed)', context).change(function() {
|
| 7 |
$(this).addClass('date-time-processed').parents("div.date-container").children("div.custom-container")[$(this).val() == "custom" ? "show" : "hide"]();
|
| 8 |
});
|
| 9 |
|
| 10 |
// Attach keyup handler to custom format inputs.
|
| 11 |
$('input.custom-format:not(.date-time-processed)', context).addClass('date-time-processed').keyup(function() {
|
| 12 |
var input = $(this);
|
| 13 |
var url = Drupal.settings.dateDateTime.lookup +(Drupal.settings.dateDateTime.lookup.match(/\?q=/) ? "&format=" : "?format=") + Drupal.encodeURIComponent(input.val());
|
| 14 |
$.getJSON(url, function(data) {
|
| 15 |
$("div.description span", input.parent()).html(data);
|
| 16 |
});
|
| 17 |
});
|
| 18 |
|
| 19 |
// Trigger the event handler to show the form input if necessary.
|
| 20 |
$('select.date-format', context).trigger('change');
|
| 21 |
};
|