Commit f3aa73ae authored by Dries's avatar Dries
Browse files

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

parent c6d3a24e
......@@ -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;
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());
var url = fieldSettings.lookup + (fieldSettings.lookup.match(/\?q=/) ? '&format=' : '?format=') + encodeURIComponent(input.val());
$.getJSON(url, function (data) {
$(suffix).empty().append(' ' + settings.text + ': <em>' + data + '</em>');
$(suffix).empty().append(' ' + fieldSettings.text + ': <em>' + data + '</em>');
});
});
})(settings.dateTime[fieldName], fieldName);
}
}
}
};
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment