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

8.0.x
Dries 2012-02-18 22:26:01 -05:00
parent c6d3a24e65
commit f3aa73aefb
1 changed files with 15 additions and 12 deletions

View File

@ -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);
}
}
}
};