timeline-selectable.html 4.8 KB

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