languages-datepicker.html 3.3 KB

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