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
No related merge requests found
...@@ -96,19 +96,22 @@ Drupal.behaviors.copyFieldValue = { ...@@ -96,19 +96,22 @@ Drupal.behaviors.copyFieldValue = {
*/ */
Drupal.behaviors.dateTime = { Drupal.behaviors.dateTime = {
attach: function (context, settings) { attach: function (context, settings) {
for (var value in settings.dateTime) { for (var fieldName in settings.dateTime) {
var settings = settings.dateTime[value]; if (settings.dateTime.hasOwnProperty(fieldName)) {
var source = '#edit-' + value; (function (fieldSettings, fieldName) {
var suffix = source + '-suffix'; var source = '#edit-' + fieldName;
var suffix = source + '-suffix';
// Attach keyup handler to custom format inputs. // Attach keyup handler to custom format inputs.
$('input' + source, context).once('date-time').keyup(function () { $('input' + source, context).once('date-time').keyup(function () {
var input = $(this); 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) { $.getJSON(url, function (data) {
$(suffix).empty().append(' ' + settings.text + ': <em>' + data + '</em>'); $(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