X-Git-Url: http://aleph1.co.uk/gitweb/?a=blobdiff_plain;f=web%2Fcore%2Fmisc%2Fdate.js;h=b5d6db5e4a4c81e32b9fd280c68c02ba0ee528d8;hb=4f1b9b4ab48a8498afac9e2213a02a23ccf4a06c;hp=8b6b71cb1db05ba1448de153b2d6ee687e7d28bc;hpb=a2bd1bf0c2c1f1a17d188f4dc0726a45494cefae;p=yaffs-website diff --git a/web/core/misc/date.js b/web/core/misc/date.js index 8b6b71cb1..b5d6db5e4 100644 --- a/web/core/misc/date.js +++ b/web/core/misc/date.js @@ -1,28 +1,15 @@ /** - * @file - * Polyfill for HTML5 date input. - */ +* DO NOT EDIT THIS FILE. +* See the following change record for more information, +* https://www.drupal.org/node/2815083 +* @preserve +**/ (function ($, Modernizr, Drupal) { - - 'use strict'; - - /** - * Attach datepicker fallback on date elements. - * - * @type {Drupal~behavior} - * - * @prop {Drupal~behaviorAttach} attach - * Attaches the behavior. Accepts in `settings.date` an object listing - * elements to process, keyed by the HTML ID of the form element containing - * the human-readable value. Each element is an datepicker settings object. - * @prop {Drupal~behaviorDetach} detach - * Detach the behavior destroying datepickers on effected elements. - */ Drupal.behaviors.date = { - attach: function (context, settings) { + attach: function attach(context, settings) { var $context = $(context); - // Skip if date are supported by the browser. + if (Modernizr.inputtypes.date === true) { return; } @@ -30,13 +17,9 @@ var $input = $(this); var datepickerSettings = {}; var 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. + + datepickerSettings.dateFormat = dateFormat.replace('Y', 'yy').replace('m', 'mm').replace('d', 'dd'); + if ($input.attr('min')) { datepickerSettings.minDate = $input.attr('min'); } @@ -46,11 +29,10 @@ $input.datepicker(datepickerSettings); }); }, - detach: function (context, settings, trigger) { + detach: function detach(context, settings, trigger) { if (trigger === 'unload') { $(context).find('input[data-drupal-date-format]').findOnce('datePicker').datepicker('destroy'); } } }; - -})(jQuery, Modernizr, Drupal); +})(jQuery, Modernizr, Drupal); \ No newline at end of file