selectable.html 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  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. header: {
  19. left: 'prev,next today',
  20. center: 'title',
  21. right: 'month,agendaWeek,basicWeek,agendaDay,basicDay'
  22. },
  23. date: '2014-01-12',
  24. defaultView: 'month',
  25. //firstDay: 1,
  26. //isRTL: true,
  27. //minTime: 7,
  28. //weekends: false,
  29. //allDaySlot: false,
  30. //hiddenDays: [ 2, 4 ], // tuesdays and thursdays
  31. selectable: true,
  32. /*
  33. selectable: {
  34. month: false,
  35. agenda: true
  36. },
  37. */
  38. selectHelper: true,
  39. /*
  40. selectHelper: function(start, end) {
  41. return $("<div style='background:red' />").text(start+' '+end);
  42. },
  43. */
  44. //unselectAuto: false,
  45. //unselectCancel: '.fc',
  46. select: function(start, end, ev) {
  47. console.log(
  48. '---- selection ----\n' +
  49. 'start: ' + start.format() + '\n' +
  50. 'end: ' + end.format()
  51. );
  52. if (ev) {
  53. //console.log('select mouse: ' + ev.pageX + ', ' + ev.pageY);
  54. }
  55. },
  56. unselect: function(ev) {
  57. console.log('unselect');
  58. if (ev) {
  59. //console.log('unselect mouse: ' + ev.pageX + ', ' + ev.pageY);
  60. }
  61. },
  62. dayClick: function(date) {
  63. console.log('DAYCLICK', date.format());
  64. console.log(this);
  65. },
  66. editable: true,
  67. events: [
  68. {
  69. title: 'All Day Event',
  70. start: '2014-01-01'
  71. },
  72. {
  73. title: 'Long Event',
  74. start: '2014-01-07',
  75. end: '2014-01-10'
  76. },
  77. {
  78. id: 999,
  79. title: 'Repeating Event',
  80. start: '2014-01-09T16:00:00'
  81. },
  82. {
  83. id: 999,
  84. title: 'Repeating Event',
  85. start: '2014-01-16T16:00:00'
  86. },
  87. {
  88. title: 'Meeting',
  89. start: '2014-01-12T10:30:00',
  90. end: '2014-01-12T12:30:00'
  91. },
  92. {
  93. title: 'Lunch',
  94. start: '2014-01-12T12:00:00'
  95. },
  96. {
  97. title: 'Birthday Party',
  98. start: '2014-01-13T07:00:00'
  99. },
  100. {
  101. title: 'Click for Google',
  102. url: 'http://google.com/',
  103. start: '2014-01-28'
  104. }
  105. ]
  106. });
  107. });
  108. </script>
  109. <style>
  110. body {
  111. font-size: 13px;
  112. font-family: "Lucida Grande",Helvetica,Arial,Verdana,sans-serif;
  113. }
  114. #calendar {
  115. width: 900px;
  116. margin: 40px auto;
  117. }
  118. </style>
  119. </head>
  120. <body>
  121. <button onclick="calendar.fullCalendar('select', new Date(y, m, d-1), new Date(y, m, d-2), true)">1day, allday</button>
  122. <button onclick="calendar.fullCalendar('select', new Date(y, m, d-1))">1day, noend, noallday</button>
  123. <button onclick="calendar.fullCalendar('select', new Date(y, m, d-1), null, false)">1day, noend, allday=false</button>
  124. <button onclick="calendar.fullCalendar('select', new Date(y, m, d, 5, 15), new Date(y, m, d, 15, 30), false)">1day, timed</button>
  125. <button onclick="calendar.fullCalendar('select', new Date(y, m, d-3), new Date(y, m, d), true)">3day, allday</button>
  126. <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>
  127. <button onclick="calendar.fullCalendar('unselect')">unselect</button>
  128. <div id='calendar'></div>
  129. </body>
  130. </html>