selectable.html 3.6 KB

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