date.js 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. /**
  2. * DO NOT EDIT THIS FILE.
  3. * See the following change record for more information,
  4. * https://www.drupal.org/node/2815083
  5. * @preserve
  6. **/
  7. (function ($, Modernizr, Drupal) {
  8. Drupal.behaviors.date = {
  9. attach: function attach(context, settings) {
  10. var $context = $(context);
  11. if (Modernizr.inputtypes.date === true) {
  12. return;
  13. }
  14. $context.find('input[data-drupal-date-format]').once('datePicker').each(function () {
  15. var $input = $(this);
  16. var datepickerSettings = {};
  17. var dateFormat = $input.data('drupalDateFormat');
  18. datepickerSettings.dateFormat = dateFormat.replace('Y', 'yy').replace('m', 'mm').replace('d', 'dd');
  19. if ($input.attr('min')) {
  20. datepickerSettings.minDate = $input.attr('min');
  21. }
  22. if ($input.attr('max')) {
  23. datepickerSettings.maxDate = $input.attr('max');
  24. }
  25. $input.datepicker(datepickerSettings);
  26. });
  27. },
  28. detach: function detach(context, settings, trigger) {
  29. if (trigger === 'unload') {
  30. $(context).find('input[data-drupal-date-format]').findOnce('datePicker').datepicker('destroy');
  31. }
  32. }
  33. };
  34. })(jQuery, Modernizr, Drupal);