locale.datepicker.es6.js 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /**
  2. * @file
  3. * Datepicker JavaScript for the Locale module.
  4. */
  5. (function($, Drupal, drupalSettings) {
  6. /**
  7. * Attaches language support to the jQuery UI datepicker component.
  8. *
  9. * @type {Drupal~behavior}
  10. */
  11. Drupal.behaviors.localeDatepicker = {
  12. attach(context, settings) {
  13. // This code accesses drupalSettings and localized strings via Drupal.t().
  14. // So this code should run after these are initialized. By placing it in an
  15. // attach behavior this is assured.
  16. $.datepicker.regional['drupal-locale'] = $.extend(
  17. {
  18. closeText: Drupal.t('Done'),
  19. prevText: Drupal.t('Prev'),
  20. nextText: Drupal.t('Next'),
  21. currentText: Drupal.t('Today'),
  22. monthNames: [
  23. Drupal.t('January', {}, { context: 'Long month name' }),
  24. Drupal.t('February', {}, { context: 'Long month name' }),
  25. Drupal.t('March', {}, { context: 'Long month name' }),
  26. Drupal.t('April', {}, { context: 'Long month name' }),
  27. Drupal.t('May', {}, { context: 'Long month name' }),
  28. Drupal.t('June', {}, { context: 'Long month name' }),
  29. Drupal.t('July', {}, { context: 'Long month name' }),
  30. Drupal.t('August', {}, { context: 'Long month name' }),
  31. Drupal.t('September', {}, { context: 'Long month name' }),
  32. Drupal.t('October', {}, { context: 'Long month name' }),
  33. Drupal.t('November', {}, { context: 'Long month name' }),
  34. Drupal.t('December', {}, { context: 'Long month name' }),
  35. ],
  36. monthNamesShort: [
  37. Drupal.t('Jan'),
  38. Drupal.t('Feb'),
  39. Drupal.t('Mar'),
  40. Drupal.t('Apr'),
  41. Drupal.t('May'),
  42. Drupal.t('Jun'),
  43. Drupal.t('Jul'),
  44. Drupal.t('Aug'),
  45. Drupal.t('Sep'),
  46. Drupal.t('Oct'),
  47. Drupal.t('Nov'),
  48. Drupal.t('Dec'),
  49. ],
  50. dayNames: [
  51. Drupal.t('Sunday'),
  52. Drupal.t('Monday'),
  53. Drupal.t('Tuesday'),
  54. Drupal.t('Wednesday'),
  55. Drupal.t('Thursday'),
  56. Drupal.t('Friday'),
  57. Drupal.t('Saturday'),
  58. ],
  59. dayNamesShort: [
  60. Drupal.t('Sun'),
  61. Drupal.t('Mon'),
  62. Drupal.t('Tue'),
  63. Drupal.t('Wed'),
  64. Drupal.t('Thu'),
  65. Drupal.t('Fri'),
  66. Drupal.t('Sat'),
  67. ],
  68. dayNamesMin: [
  69. Drupal.t('Su'),
  70. Drupal.t('Mo'),
  71. Drupal.t('Tu'),
  72. Drupal.t('We'),
  73. Drupal.t('Th'),
  74. Drupal.t('Fr'),
  75. Drupal.t('Sa'),
  76. ],
  77. dateFormat: Drupal.t('mm/dd/yy'),
  78. firstDay: 0,
  79. isRTL: 0,
  80. },
  81. drupalSettings.jquery.ui.datepicker,
  82. );
  83. $.datepicker.setDefaults($.datepicker.regional['drupal-locale']);
  84. },
  85. };
  86. })(jQuery, Drupal, drupalSettings);