timeline-selectable.html 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset='utf-8' />
  5. <link href='../packages-premium/bundle/main.css' rel='stylesheet' />
  6. <script src='../packages-premium/bundle/main.js'></script>
  7. <script>
  8. document.addEventListener('DOMContentLoaded', function() {
  9. var calendarEl = document.getElementById('calendar');
  10. var calendar = new FullCalendar.Calendar(calendarEl, {
  11. now: '2020-09-07',
  12. selectable: true,
  13. selectHelper: true,
  14. editable: true, // enable draggable events
  15. aspectRatio: 1.8,
  16. scrollTime: '00:00', // undo default 6am scrollTime
  17. headerToolbar: {
  18. left: 'today prev,next',
  19. center: 'title',
  20. right: 'resourceTimelineDay,resourceTimelineThreeDays,timeGridWeek,dayGridMonth'
  21. },
  22. initialView: 'resourceTimelineDay',
  23. views: {
  24. resourceTimelineThreeDays: {
  25. type: 'resourceTimeline',
  26. duration: { days: 3 },
  27. buttonText: '3 days'
  28. }
  29. },
  30. resourceAreaHeaderContent: 'Rooms',
  31. resources: [
  32. { id: 'a', title: 'Auditorium A' },
  33. { id: 'b', title: 'Auditorium B', eventColor: 'green' },
  34. { id: 'c', title: 'Auditorium C', eventColor: 'orange' },
  35. { id: 'd', title: 'Auditorium D', children: [
  36. { id: 'd1', title: 'Room D1' },
  37. { id: 'd2', title: 'Room D2' }
  38. ] },
  39. { id: 'e', title: 'Auditorium E' },
  40. { id: 'f', title: 'Auditorium F', eventColor: 'red' },
  41. { id: 'g', title: 'Auditorium G' },
  42. { id: 'h', title: 'Auditorium H' },
  43. { id: 'i', title: 'Auditorium I' },
  44. { id: 'j', title: 'Auditorium J' },
  45. { id: 'k', title: 'Auditorium K' },
  46. { id: 'l', title: 'Auditorium L' },
  47. { id: 'm', title: 'Auditorium M' },
  48. { id: 'n', title: 'Auditorium N' },
  49. { id: 'o', title: 'Auditorium O' },
  50. { id: 'p', title: 'Auditorium P' },
  51. { id: 'q', title: 'Auditorium Q' },
  52. { id: 'r', title: 'Auditorium R' },
  53. { id: 's', title: 'Auditorium S' },
  54. { id: 't', title: 'Auditorium T' },
  55. { id: 'u', title: 'Auditorium U' },
  56. { id: 'v', title: 'Auditorium V' },
  57. { id: 'w', title: 'Auditorium W' },
  58. { id: 'x', title: 'Auditorium X' },
  59. { id: 'y', title: 'Auditorium Y' },
  60. { id: 'z', title: 'Auditorium Z' }
  61. ],
  62. events: [
  63. { id: '1', resourceId: 'b', start: '2020-09-07T02:00:00', end: '2020-09-07T07:00:00', title: 'event 1' },
  64. { id: '2', resourceId: 'c', start: '2020-09-07T05:00:00', end: '2020-09-07T22:00:00', title: 'event 2' },
  65. { id: '3', resourceId: 'd', start: '2020-09-06', end: '2020-09-08', title: 'event 3' },
  66. { id: '4', resourceId: 'e', start: '2020-09-07T03:00:00', end: '2020-09-07T08:00:00', title: 'event 4' },
  67. { id: '5', resourceId: 'f', start: '2020-09-07T00:30:00', end: '2020-09-07T02:30:00', title: 'event 5' }
  68. ],
  69. select: function(arg) {
  70. console.log(
  71. 'select callback',
  72. arg.startStr,
  73. arg.endStr,
  74. arg.resource ? arg.resource.id : '(no resource)'
  75. );
  76. },
  77. dateClick: function(arg) {
  78. console.log(
  79. 'dateClick',
  80. arg.date,
  81. arg.resource ? arg.resource.id : '(no resource)'
  82. );
  83. }
  84. });
  85. calendar.render();
  86. document.getElementById('select-G').addEventListener('click', function() {
  87. calendar.select({
  88. start: '2020-09-07T02:00:00',
  89. end: '2020-09-07T07:00:00',
  90. resourceId: 'g'
  91. });
  92. });
  93. document.getElementById('select-unspecified').addEventListener('click', function() {
  94. calendar.select('2020-09-07T02:00:00', '2020-09-07T07:00:00');
  95. });
  96. });
  97. </script>
  98. <style>
  99. body {
  100. margin: 0;
  101. padding: 0;
  102. font-family: Arial, Helvetica Neue, Helvetica, sans-serif;
  103. font-size: 14px;
  104. }
  105. #calendar {
  106. max-width: 1100px;
  107. margin: 50px auto;
  108. }
  109. </style>
  110. </head>
  111. <body>
  112. <div id='calendar'></div>
  113. <p style='text-align:center'>
  114. <button id='select-G'>select G</button>
  115. <button id='select-unspecified'>select w/o a resource</button>
  116. </p>
  117. </body>
  118. </html>