2
0

languages-datepicker.html 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset='utf-8' />
  5. <link rel='stylesheet' href='../lib/jquery-ui/themes/cupertino/jquery-ui.min.css' />
  6. <link href='../dist/fullcalendar.css' rel='stylesheet' />
  7. <link href='../dist/fullcalendar.print.css' rel='stylesheet' media='print' />
  8. <script src='../lib/jquery/jquery.js'></script>
  9. <script src='../lib/jquery-ui/ui/jquery-ui.js'></script>
  10. <script src='../lib/moment/moment.js'></script>
  11. <script src='../dist/fullcalendar.js'></script>
  12. <script src='../dist/lang-all.js'></script>
  13. <script>
  14. $(document).ready(function() {
  15. var currentLangCode = 'en';
  16. // build the language selector's options
  17. $.each($.fullCalendar.langs, function(langCode) {
  18. $('#lang-selector').append(
  19. $('<option/>')
  20. .attr('value', langCode)
  21. .prop('selected', langCode == currentLangCode)
  22. .text(langCode)
  23. );
  24. });
  25. // update the language when the selected option changes
  26. $('#lang-selector').on('change', function() {
  27. if (this.value) {
  28. currentLangCode = this.value;
  29. // change the language on the datepicker
  30. $('#datepicker').datepicker('option', $.datepicker.regional[currentLangCode]);
  31. // rerender the calendar
  32. $('#calendar').fullCalendar('destroy');
  33. renderCalendar();
  34. }
  35. });
  36. // initialize the datepicker
  37. $('#datepicker').datepicker({
  38. dateFormat: 'yy-mm-dd', // needed for defaultDate
  39. defaultDate: '2014-01-12',
  40. showWeek: true,
  41. showButtonPanel: true,
  42. calculateWeek: function(nativeDate) {
  43. // use Moment to calculate the local week number
  44. return moment(nativeDate).lang(currentLangCode).week();
  45. }
  46. });
  47. function renderCalendar() {
  48. $('#calendar').fullCalendar({
  49. header: {
  50. left: 'prev,next today',
  51. center: 'title',
  52. right: 'month,agendaWeek,agendaDay'
  53. },
  54. date: '2014-01-12',
  55. lang: currentLangCode,
  56. buttonIcons: false, // show the prev/next text
  57. weekNumbers: true,
  58. editable: true,
  59. events: [
  60. {
  61. title: 'All Day Event',
  62. start: '2014-01-01'
  63. },
  64. {
  65. title: 'Long Event',
  66. start: '2014-01-07',
  67. end: '2014-01-10'
  68. },
  69. {
  70. id: 999,
  71. title: 'Repeating Event',
  72. start: '2014-01-09T16:00:00'
  73. },
  74. {
  75. id: 999,
  76. title: 'Repeating Event',
  77. start: '2014-01-16T16:00:00'
  78. },
  79. {
  80. title: 'Meeting',
  81. start: '2014-01-12T10:30:00',
  82. end: '2014-01-12T12:30:00'
  83. },
  84. {
  85. title: 'Lunch',
  86. start: '2014-01-12T12:00:00'
  87. },
  88. {
  89. title: 'Birthday Party',
  90. start: '2014-01-13T07:00:00'
  91. },
  92. {
  93. title: 'Click for Google',
  94. url: 'http://google.com/',
  95. start: '2014-01-28'
  96. }
  97. ]
  98. });
  99. }
  100. renderCalendar();
  101. });
  102. </script>
  103. <style>
  104. body {
  105. margin: 0;
  106. padding: 0;
  107. text-align: center;
  108. font-family: "Lucida Grande",Helvetica,Arial,Verdana,sans-serif;
  109. font-size: 14px;
  110. }
  111. #top {
  112. background: #eee;
  113. border-bottom: 1px solid #ddd;
  114. padding: 0 10px;
  115. text-align: left;
  116. line-height: 40px;
  117. font-size: 12px;
  118. }
  119. #calendar {
  120. width: 900px;
  121. margin: 40px auto;
  122. }
  123. #datepicker {
  124. display: inline-block;
  125. }
  126. </style>
  127. </head>
  128. <body>
  129. <div id='top'>
  130. Language:
  131. <select id='lang-selector'></select>
  132. </div>
  133. <div id='calendar'></div>
  134. <div id='datepicker'></div>
  135. </body>
  136. </html>