Mercurial > hg > cmmr2012-drupal-site
diff core/misc/date.es6.js @ 4:a9cd425dd02b
Update, including to Drupal core 8.6.10
author | Chris Cannam |
---|---|
date | Thu, 28 Feb 2019 13:11:55 +0000 |
parents | c75dbcec494b |
children |
line wrap: on
line diff
--- a/core/misc/date.es6.js Thu Feb 28 11:14:44 2019 +0000 +++ b/core/misc/date.es6.js Thu Feb 28 13:11:55 2019 +0000 @@ -3,7 +3,7 @@ * Polyfill for HTML5 date input. */ -(function ($, Modernizr, Drupal) { +(function($, Modernizr, Drupal) { /** * Attach datepicker fallback on date elements. * @@ -23,30 +23,36 @@ if (Modernizr.inputtypes.date === true) { return; } - $context.find('input[data-drupal-date-format]').once('datePicker').each(function () { - const $input = $(this); - const datepickerSettings = {}; - const dateFormat = $input.data('drupalDateFormat'); - // The date format is saved in PHP style, we need to convert to jQuery - // datepicker. - datepickerSettings.dateFormat = dateFormat - .replace('Y', 'yy') - .replace('m', 'mm') - .replace('d', 'dd'); - // Add min and max date if set on the input. - if ($input.attr('min')) { - datepickerSettings.minDate = $input.attr('min'); - } - if ($input.attr('max')) { - datepickerSettings.maxDate = $input.attr('max'); - } - $input.datepicker(datepickerSettings); - }); + $context + .find('input[data-drupal-date-format]') + .once('datePicker') + .each(function() { + const $input = $(this); + const datepickerSettings = {}; + const dateFormat = $input.data('drupalDateFormat'); + // The date format is saved in PHP style, we need to convert to jQuery + // datepicker. + datepickerSettings.dateFormat = dateFormat + .replace('Y', 'yy') + .replace('m', 'mm') + .replace('d', 'dd'); + // Add min and max date if set on the input. + if ($input.attr('min')) { + datepickerSettings.minDate = $input.attr('min'); + } + if ($input.attr('max')) { + datepickerSettings.maxDate = $input.attr('max'); + } + $input.datepicker(datepickerSettings); + }); }, detach(context, settings, trigger) { if (trigger === 'unload') { - $(context).find('input[data-drupal-date-format]').findOnce('datePicker').datepicker('destroy'); + $(context) + .find('input[data-drupal-date-format]') + .findOnce('datePicker') + .datepicker('destroy'); } }, }; -}(jQuery, Modernizr, Drupal)); +})(jQuery, Modernizr, Drupal);