Skip to content
Snippets Groups Projects
Commit f3aa73ae authored by Dries Buytaert's avatar Dries Buytaert
Browse files

- Patch #1444160 by Niklas Fiekas: Drupal.behaviors.dateTime needs a clean-up.

parent c6d3a24e
Branches
Tags
2 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
......@@ -96,19 +96,22 @@ Drupal.behaviors.copyFieldValue = {
*/
Drupal.behaviors.dateTime = {
attach: function (context, settings) {
for (var value in settings.dateTime) {
var settings = settings.dateTime[value];
var source = '#edit-' + value;
var suffix = source + '-suffix';
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.
$('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>');
});
});
// Attach keyup handler to custom format inputs.
$('input' + source, context).once('date-time').keyup(function () {
var input = $(this);
var url = fieldSettings.lookup + (fieldSettings.lookup.match(/\?q=/) ? '&format=' : '?format=') + encodeURIComponent(input.val());
$.getJSON(url, function (data) {
$(suffix).empty().append(' ' + fieldSettings.text + ': <em>' + data + '</em>');
});
});
})(settings.dateTime[fieldName], fieldName);
}
}
}
};
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment