locale.datepicker.js 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. /**
  2. * @file
  3. * Datepicker JavaScript for the Locale module.
  4. */
  5. (function ($, Drupal, drupalSettings) {
  6. 'use strict';
  7. /**
  8. * Attaches language support to the jQuery UI datepicker component.
  9. *
  10. * @type {Drupal~behavior}
  11. */
  12. Drupal.behaviors.localeDatepicker = {
  13. attach: function (context, settings) {
  14. // This code accesses drupalSettings and localized strings via Drupal.t().
  15. // So this code should run after these are initialized. By placing it in an
  16. // attach behavior this is assured.
  17. $.datepicker.regional['drupal-locale'] = $.extend({
  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. }, drupalSettings.jquery.ui.datepicker);
  81. $.datepicker.setDefaults($.datepicker.regional['drupal-locale']);
  82. }
  83. };
  84. })(jQuery, Drupal, drupalSettings);