timegrid-views-modal.html 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset='utf-8' />
  5. <script src='../dist/index.global.js'></script>
  6. <script>
  7. /*
  8. From https://github.com/fullcalendar/fullcalendar/issues/5026
  9. */
  10. document.addEventListener('DOMContentLoaded', function() {
  11. var calendarOptions = {
  12. initialDate: '2023-01-12',
  13. initialView: 'timeGridWeek',
  14. nowIndicator: true,
  15. headerToolbar: {
  16. left: 'prev,next today',
  17. center: 'title',
  18. right: 'dayGridMonth,timeGridWeek,timeGridDay,listWeek'
  19. },
  20. navLinks: true, // can click day/week names to navigate views
  21. editable: true,
  22. selectable: true,
  23. selectMirror: true,
  24. dayMaxEvents: true, // allow "more" link when too many events
  25. events: [
  26. {
  27. title: 'All Day Event',
  28. start: '2023-01-01',
  29. },
  30. {
  31. title: 'Long Event',
  32. start: '2023-01-07',
  33. end: '2023-01-10'
  34. },
  35. {
  36. groupId: 999,
  37. title: 'Repeating Event',
  38. start: '2023-01-09T16:00:00'
  39. },
  40. {
  41. groupId: 999,
  42. title: 'Repeating Event',
  43. start: '2023-01-16T16:00:00'
  44. },
  45. {
  46. title: 'Conference',
  47. start: '2023-01-11',
  48. end: '2023-01-13'
  49. },
  50. {
  51. title: 'Meeting',
  52. start: '2023-01-12T10:30:00',
  53. end: '2023-01-12T12:30:00'
  54. },
  55. {
  56. title: 'Lunch',
  57. start: '2023-01-12T12:00:00'
  58. },
  59. {
  60. title: 'Meeting',
  61. start: '2023-01-12T14:30:00'
  62. },
  63. {
  64. title: 'Happy Hour',
  65. start: '2023-01-12T17:30:00'
  66. },
  67. {
  68. title: 'Dinner',
  69. start: '2023-01-12T20:00:00'
  70. },
  71. {
  72. title: 'Birthday Party',
  73. start: '2023-01-13T07:00:00'
  74. },
  75. {
  76. title: 'Click for Google',
  77. url: 'http://google.com/',
  78. start: '2023-01-28'
  79. }
  80. ]
  81. };
  82. var calendar = new FullCalendar.Calendar(document.getElementById('calendar'), calendarOptions);
  83. calendar.render();
  84. var calendar2 = new FullCalendar.Calendar(document.getElementById('calendar2'), calendarOptions);
  85. calendar2.render();
  86. /*
  87. Modal
  88. */
  89. var modal = document.querySelector('.modal');
  90. var modalTrigger = document.querySelector('.modal-trigger');
  91. var modalOverlay = document.querySelector('.modal-overlay');
  92. modalTrigger.addEventListener('click', function() {
  93. modal.classList.add('is-visible');
  94. calendar2.updateSize();
  95. });
  96. modalOverlay.addEventListener('click', function() {
  97. modal.classList.remove('is-visible');
  98. });
  99. });
  100. </script>
  101. <style>
  102. body {
  103. margin: 10px;
  104. padding: 0;
  105. font-family: Arial, Helvetica Neue, Helvetica, sans-serif;
  106. font-size: 14px;
  107. }
  108. #calendar {
  109. max-width: 1100px;
  110. margin: 0 auto;
  111. }
  112. .modal {
  113. display: none;
  114. position: absolute;
  115. z-index: 10000;
  116. top: 0;
  117. left: 0;
  118. width: 100%;
  119. height: 100%;
  120. }
  121. .modal.is-visible {
  122. display: block;
  123. }
  124. .modal-overlay {
  125. position: fixed;
  126. z-index: 10;
  127. top: 0;
  128. left: 0;
  129. width: 100%;
  130. height: 100%;
  131. background: hsla(0, 0%, 0%, 0.5);
  132. }
  133. .modal-wrapper {
  134. position: absolute;
  135. z-index: 9999;
  136. top: 6em;
  137. left: 50%;
  138. width: 600px;
  139. margin-left: -16em;
  140. background-color: #fff;
  141. box-shadow: 0 0 1.5em hsla(0, 0%, 0%, 0.35);
  142. }
  143. .modal-content {
  144. padding: 1em;
  145. }
  146. </style>
  147. </head>
  148. <body>
  149. <button class='modal-trigger'>Show modal</button>
  150. <div id='calendar'></div>
  151. <div class='modal'>
  152. <div class='modal-overlay'></div>
  153. <div class='modal-wrapper'>
  154. <div class='modal-content'>
  155. <div id='calendar2'></div>
  156. </div>
  157. </div>
  158. </div>
  159. </body>
  160. </html>