selectable.html 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <link href='../../dist/fullcalendar.css' rel='stylesheet' />
  5. <link href='../../dist/fullcalendar.print.css' rel='stylesheet' media='print' />
  6. <script src='../../node_modules/jquery/dist/jquery.js'></script>
  7. <script src='../../node_modules/moment/moment.js'></script>
  8. <script src='../../dist/fullcalendar.js'></script>
  9. <script>
  10. // TODO: get rid of this!!! (used at the bottom too)
  11. var date = new Date();
  12. var d = date.getDate();
  13. var m = date.getMonth();
  14. var y = date.getFullYear();
  15. var calendar;
  16. $(document).ready(function() {
  17. calendar = $('#calendar').fullCalendar({
  18. headerToolbar: {
  19. left: 'prev,next today',
  20. center: 'title',
  21. right: 'month,week,dayGridWeek,day,dayGridDay'
  22. },
  23. date: '2014-01-12',
  24. initialView: 'dayGridMonth',
  25. //firstDay: 1,
  26. //direction: 'rtl',
  27. //slotMinTime: 7,
  28. //weekends: false,
  29. //allDaySlot: false,
  30. //hiddenDays: [ 2, 4 ], // tuesdays and thursdays
  31. selectable: true,
  32. selectMirror: true,
  33. /*
  34. selectMirror: function(start, end) {
  35. return $("<div style='background:red' />").text(start+' '+end);
  36. },
  37. */
  38. //unselectAuto: false,
  39. //unselectCancel: '.fc',
  40. select: function(start, end, ev) {
  41. console.log(
  42. '---- selection ----\n' +
  43. 'start: ' + start.format() + '\n' +
  44. 'end: ' + end.format()
  45. );
  46. if (ev) {
  47. //console.log('select mouse: ' + ev.pageX + ', ' + ev.pageY);
  48. }
  49. },
  50. unselect: function(ev) {
  51. console.log('unselect');
  52. if (ev) {
  53. //console.log('unselect mouse: ' + ev.pageX + ', ' + ev.pageY);
  54. }
  55. },
  56. dayClick: function(date) {
  57. console.log('DAYCLICK', date.format());
  58. console.log(this);
  59. },
  60. editable: true,
  61. events: [
  62. {
  63. title: 'All Day Event',
  64. start: '2014-01-01'
  65. },
  66. {
  67. title: 'Long Event',
  68. start: '2014-01-07',
  69. end: '2014-01-10'
  70. },
  71. {
  72. groupId: 999,
  73. title: 'Repeating Event',
  74. start: '2014-01-09T16:00:00'
  75. },
  76. {
  77. groupId: 999,
  78. title: 'Repeating Event',
  79. start: '2014-01-16T16:00:00'
  80. },
  81. {
  82. title: 'Meeting',
  83. start: '2014-01-12T10:30:00',
  84. end: '2014-01-12T12:30:00'
  85. },
  86. {
  87. title: 'Lunch',
  88. start: '2014-01-12T12:00:00'
  89. },
  90. {
  91. title: 'Birthday Party',
  92. start: '2014-01-13T07:00:00'
  93. },
  94. {
  95. title: 'Click for Google',
  96. url: 'http://google.com/',
  97. start: '2014-01-28'
  98. }
  99. ]
  100. });
  101. });
  102. </script>
  103. <style>
  104. body {
  105. font-size: 13px;
  106. font-family: "Lucida Grande",Helvetica,Arial,Verdana,sans-serif;
  107. }
  108. #calendar {
  109. width: 900px;
  110. margin: 40px auto;
  111. }
  112. </style>
  113. </head>
  114. <body>
  115. <button onclick="calendar.fullCalendar('select', new Date(y, m, d-1), new Date(y, m, d-2), true)">1day, allday</button>
  116. <button onclick="calendar.fullCalendar('select', new Date(y, m, d-1))">1day, noend, noallday</button>
  117. <button onclick="calendar.fullCalendar('select', new Date(y, m, d-1), null, false)">1day, noend, allday=false</button>
  118. <button onclick="calendar.fullCalendar('select', new Date(y, m, d, 5, 15), new Date(y, m, d, 15, 30), false)">1day, timed</button>
  119. <button onclick="calendar.fullCalendar('select', new Date(y, m, d-3), new Date(y, m, d), true)">3day, allday</button>
  120. <button onclick="calendar.fullCalendar('select', new Date(y, m, d-2, 5, 15), new Date(y, m, d+1, 15, 30), false)">3day, timed</button>
  121. <button onclick="calendar.fullCalendar('unselect')">unselect</button>
  122. <div id='calendar'></div>
  123. </body>
  124. </html>