fullcalendar.js 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. //FULL CALENDAR
  2. document.addEventListener('DOMContentLoaded', function() {
  3. var containerEl = document.getElementById('external-events');
  4. new FullCalendar.Draggable(containerEl, {
  5. itemSelector: '.fc-event',
  6. eventData: function(eventEl) {
  7. return {
  8. title: eventEl.innerText.trim(),
  9. title: eventEl.innerText,
  10. className: eventEl.className + ' overflow-hidden '
  11. }
  12. }
  13. });
  14. var calendarEl = document.getElementById('calendar2');
  15. var calendar = new FullCalendar.Calendar(calendarEl, {
  16. headerToolbar: {
  17. left: 'prev,next today',
  18. center: 'title',
  19. right: 'dayGridMonth,timeGridWeek,timeGridDay'
  20. },
  21. // defaultView: 'month',
  22. navLinks: true, // can click day/week names to navigate views
  23. businessHours: true, // display business hours
  24. editable: true,
  25. selectable: true,
  26. selectMirror: true,
  27. droppable: true, // this allows things to be dropped onto the calendar
  28. select: function(arg) {
  29. var title = prompt('Event Title:');
  30. if (title) {
  31. calendar.addEvent({
  32. title: title,
  33. start: arg.start,
  34. end: arg.end,
  35. allDay: arg.allDay
  36. })
  37. }
  38. calendar.unselect()
  39. },
  40. eventClick: function(arg) {
  41. if (confirm('Are you sure you want to delete this event?')) {
  42. arg.event.remove()
  43. }
  44. },
  45. editable: true,
  46. dayMaxEvents: true, // allow "more" link when too many events
  47. events: [{
  48. title: 'Business Lunch',
  49. start: '2021-03-03T13:00:00',
  50. constraint: 'businessHours'
  51. }, {
  52. title: 'Meeting',
  53. start: '2021-03-13T11:00:00',
  54. constraint: 'availableForMeeting', // defined below
  55. color: '#f35e90'
  56. }, {
  57. title: 'Conference',
  58. start: '2021-07-18',
  59. end: '2021-07-20',
  60. color: '#e67e22'
  61. }, {
  62. title: 'Party',
  63. start: '2021-07-29T20:00:00',
  64. color: '#22c865'
  65. },
  66. // areas where "Meeting" must be dropped
  67. {
  68. id: 'availableForMeeting',
  69. start: '2021-03-11T10:00:00',
  70. end: '2021-03-11T16:00:00',
  71. rendering: 'background',
  72. color: '#5e72e4'
  73. }, {
  74. id: 'availableForMeeting',
  75. start: '2021-03-13T10:00:00',
  76. end: '2021-03-13T16:00:00',
  77. rendering: 'background'
  78. },
  79. // red areas where no events can be dropped
  80. {
  81. start: '2021-03-24',
  82. end: '2021-03-28',
  83. overlap: false,
  84. rendering: 'background',
  85. color: 'rgba(0,0,0,0.1)'
  86. }, {
  87. start: '2021-03-06',
  88. end: '2021-03-11',
  89. overlap: false,
  90. rendering: 'background',
  91. color: 'rgba(0,0,0,0.1)'
  92. }
  93. ]
  94. });
  95. calendar.render();
  96. });
  97. //LIST FULLCALENDAR
  98. document.addEventListener('DOMContentLoaded', function() {
  99. var calendarEl = document.getElementById('calendar');
  100. var calendar = new FullCalendar.Calendar(calendarEl, {
  101. height: 'auto',
  102. headerToolbar: {
  103. left: 'prev,next today',
  104. center: 'title',
  105. right: 'listDay,listWeek'
  106. },
  107. // customize the button names,
  108. // otherwise they'd all just say "list"
  109. views: {
  110. listDay: { buttonText: 'list day' },
  111. listWeek: { buttonText: 'list week' }
  112. },
  113. initialView: 'listWeek',
  114. initialDate: '2021-07-12',
  115. navLinks: true, // can click day/week names to navigate views
  116. editable: true,
  117. // eventLimit: true, // allow "more" link when too many events
  118. dayMaxEvents: true, // allow "more" link when too many events
  119. events: [{
  120. title: 'All Day Event',
  121. start: '2021-11-01'
  122. }, {
  123. title: 'Long Event',
  124. start: '2019-11-07',
  125. end: '2021-03-10'
  126. }, {
  127. id: 999,
  128. title: 'Repeating Event',
  129. start: '2021-11-09T16:00:00'
  130. }, {
  131. id: 999,
  132. title: 'Repeating Event',
  133. start: '2021-11-16T16:00:00'
  134. }, {
  135. title: 'Conference',
  136. start: '2019-11-11',
  137. end: '2021-11-13'
  138. }, {
  139. title: 'Meeting',
  140. start: '2019-11-12T10:30:00',
  141. end: '2021-11-12T12:30:00'
  142. }, {
  143. title: 'Lunch',
  144. start: '2021-11-12T12:00:00'
  145. }, {
  146. title: 'Meeting',
  147. start: '2021-11-12T14:30:00'
  148. }, {
  149. title: 'Happy Hour',
  150. start: '2021-11-12T17:30:00'
  151. }, {
  152. title: 'Dinner',
  153. start: '2021-11-12T20:00:00'
  154. }, {
  155. title: 'Birthday Party',
  156. start: '2021-11-13T07:00:00'
  157. }, {
  158. title: 'Click for Google',
  159. url: 'http://google.com/',
  160. start: '2021-11-28'
  161. }]
  162. });
  163. calendar.render();
  164. });