2015-06-05 20:17:55 +00:00
|
|
|
/**
|
2017-05-19 22:12:53 +00:00
|
|
|
* DO NOT EDIT THIS FILE.
|
|
|
|
* See the following change record for more information,
|
2017-05-23 14:30:14 +00:00
|
|
|
* https://www.drupal.org/node/2815083
|
2017-05-19 22:12:53 +00:00
|
|
|
* @preserve
|
|
|
|
**/
|
2015-06-05 20:17:55 +00:00
|
|
|
|
Issue #2429443 by vijaycs85, rteijeiro, penyaskito, gloob, xjm, nod_, geertvd, pjonckiere, alexpott, Wim Leers, Gábor Hojtsy, Fabianx, tim.plunkett: Date format form is unusable
2015-06-01 16:35:52 +00:00
|
|
|
(function ($, Drupal, drupalSettings) {
|
|
|
|
var dateFormats = drupalSettings.dateFormats;
|
|
|
|
|
|
|
|
Drupal.behaviors.dateFormat = {
|
2017-05-19 22:12:53 +00:00
|
|
|
attach: function attach(context) {
|
Issue #2429443 by vijaycs85, rteijeiro, penyaskito, gloob, xjm, nod_, geertvd, pjonckiere, alexpott, Wim Leers, Gábor Hojtsy, Fabianx, tim.plunkett: Date format form is unusable
2015-06-01 16:35:52 +00:00
|
|
|
var $context = $(context);
|
|
|
|
var $source = $context.find('[data-drupal-date-formatter="source"]').once('dateFormat');
|
|
|
|
var $target = $context.find('[data-drupal-date-formatter="preview"]').once('dateFormat');
|
|
|
|
var $preview = $target.find('em');
|
|
|
|
|
|
|
|
if (!$source.length || !$target.length) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
function dateFormatHandler(e) {
|
|
|
|
var baseValue = $(e.target).val() || '';
|
|
|
|
var dateString = baseValue.replace(/\\?(.?)/gi, function (key, value) {
|
|
|
|
return dateFormats[key] ? dateFormats[key] : value;
|
|
|
|
});
|
|
|
|
|
|
|
|
$preview.html(dateString);
|
|
|
|
$target.toggleClass('js-hide', !dateString.length);
|
|
|
|
}
|
|
|
|
|
2017-05-19 22:12:53 +00:00
|
|
|
$source.on('keyup.dateFormat change.dateFormat input.dateFormat', dateFormatHandler).trigger('keyup');
|
Issue #2429443 by vijaycs85, rteijeiro, penyaskito, gloob, xjm, nod_, geertvd, pjonckiere, alexpott, Wim Leers, Gábor Hojtsy, Fabianx, tim.plunkett: Date format form is unusable
2015-06-01 16:35:52 +00:00
|
|
|
}
|
|
|
|
};
|
2017-05-19 22:12:53 +00:00
|
|
|
})(jQuery, Drupal, drupalSettings);
|