methods.html 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  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 src='../../dist/plugins/google-calendar.js'></script>
  10. <script>
  11. var cal, staticEvents;
  12. var date = new Date();
  13. var d = date.getDate();
  14. var m = date.getMonth();
  15. var y = date.getFullYear();
  16. $(document).ready(function() {
  17. cal = $('#calendar').fullCalendar({
  18. editable: true,
  19. weekends: false,
  20. headerToolbar: {
  21. left: 'prev,next today',
  22. center: 'title',
  23. right: 'month,week,dayGridWeek,day,dayGridDay'
  24. },
  25. loading: function(bool) {
  26. if (bool) {
  27. $('#loading').show();
  28. }else{
  29. $('#loading').hide();
  30. }
  31. },
  32. events: staticEvents = [
  33. {
  34. title: 'All Day Event',
  35. start: new Date(y, m, 1)
  36. },
  37. {
  38. title: 'Long Event',
  39. start: new Date(y, m, d-5),
  40. end: new Date(y, m, d-2)
  41. },
  42. {
  43. groupId: 999,
  44. title: 'Repeating Event',
  45. start: new Date(y, m, d-3, 16, 0),
  46. allDay: false
  47. },
  48. {
  49. groupId: 999,
  50. title: 'Repeating Event',
  51. start: new Date(y, m, d+4, 16, 0),
  52. allDay: false
  53. },
  54. {
  55. title: 'Meeting',
  56. start: new Date(y, m, d, 10, 30),
  57. allDay: false
  58. },
  59. {
  60. id: 777,
  61. title: 'Lunch',
  62. start: new Date(y, m, d, 12, 0),
  63. end: new Date(y, m, d, 14, 0),
  64. allDay: false
  65. },
  66. {
  67. title: 'Birthday Party',
  68. start: new Date(y, m, d+1, 19, 0),
  69. end: new Date(y, m, d+1, 22, 30),
  70. allDay: false
  71. },
  72. {
  73. title: 'Click for Google',
  74. start: new Date(y, m, 28),
  75. end: new Date(y, m, 29),
  76. url: 'http://google.com/'
  77. }
  78. ]
  79. });
  80. });
  81. function updateEventStart() {
  82. var event = cal.fullCalendar('clientEvents', 777)[0];
  83. event.start = new Date(y, m, d, 13, 30);
  84. event.end = new Date(y, m, d, 14, 50);
  85. //event.start = new Date(y, m, 25, 10, 30); // move big days
  86. //event.end = new Date(y, m, 26);
  87. //event.allDay = true;
  88. cal.fullCalendar('updateEvent', event);
  89. }
  90. function updateRepeatingEvent() {
  91. var event = cal.fullCalendar('clientEvents', 999)[0];
  92. event.start = new Date(y, m, 4, 13, 30);
  93. event.end = new Date(y, m, 5, 2, 0);
  94. event.allDay = true;
  95. event.title = "repeat yo";
  96. //event.editable = false;
  97. event.url = "http://google.com/";
  98. event.color = 'red';
  99. event.textColor = 'green';
  100. cal.fullCalendar('updateEvent', event);
  101. //console.log(cal.fullCalendar('clientEvents', 2));
  102. }
  103. function renderEvent(stick) {
  104. cal.fullCalendar('renderEvent', {
  105. start: new Date(y, m, 17),
  106. title: 'heyman'
  107. }, stick);
  108. }
  109. function getView() {
  110. var view = cal.fullCalendar('getView');
  111. console.log(view.activeStart + ' --- ' + view.activeEnd + ' "' + view.title + '"');
  112. }
  113. function getDate() {
  114. console.log(cal.fullCalendar('getDate'));
  115. }
  116. function optionGetter() {
  117. console.log(cal.fullCalendar('option', 'editable'));
  118. }
  119. var gcalFeed = FullCalendar.gcalFeed("http://www.google.com/calendar/feeds/usa__en%40holiday.calendar.google.com/public/basic");
  120. var jsonFeed = "../demos/json-events.php";
  121. </script>
  122. <style>
  123. button {
  124. font-size: 11px;
  125. }
  126. </style>
  127. </head>
  128. <body style='font-size:12px'>
  129. <p>
  130. <button onclick="cal.fullCalendar('prev')">prev</button>
  131. <button onclick="cal.fullCalendar('next')">next</button>
  132. <button onclick="cal.fullCalendar('today')">today</button>
  133. <button onclick="cal.fullCalendar('gotoDate', 1999, 9, 31)">Oct 31 1999</button>
  134. <button onclick="cal.fullCalendar('gotoDate', new Date(1999, 9, 30))">Oct 30 1999 (Date)</button>
  135. <button onclick="cal.fullCalendar('incrementDate', 1, 1, 1)">+1 +1 +1</button>
  136. <button onclick="cal.fullCalendar('incrementDate', -1, -1, -1)">-1 -1 -1</button>
  137. <button onclick="updateEventStart()">update event start</button>
  138. <button onclick="updateRepeatingEvent()">update repeating event</button>
  139. <button onclick="renderEvent(false)">render new event</button>
  140. <button onclick="renderEvent(true)">render new sticky event</button>
  141. <br />
  142. <button onclick="cal.fullCalendar('removeEvents')">remove all</button>
  143. <button onclick="cal.fullCalendar('removeEvents', 999)">remove repeating events</button>
  144. <button onclick="cal.fullCalendar('removeEvents', function(e){return !e.allDay})">remove timed events</button>
  145. <button onclick="console.log(cal.fullCalendar('clientEvents'))">log events</button>
  146. <button onclick="console.log(cal.fullCalendar('clientEvents', '999'))">log repeating events</button>
  147. <button onclick="console.log(cal.fullCalendar('clientEvents', function(e){return e.allDay}))">log all-day events</button>
  148. <br />
  149. <button onclick="cal.fullCalendar('addEventSource', staticEvents)">+ static events</button>
  150. <button onclick="cal.fullCalendar('removeEventSource', staticEvents)">- static events</button>
  151. <button onclick="cal.fullCalendar('addEventSource', gcalFeed)">+ google-calendar</button>
  152. <button onclick="cal.fullCalendar('removeEventSource', gcalFeed)">- google-calendar</button>
  153. <button onclick="cal.fullCalendar('addEventSource', jsonFeed)">+ json</button>
  154. <button onclick="cal.fullCalendar('removeEventSource', jsonFeed)">- json</button>
  155. <button onclick="cal.fullCalendar('rerenderEvents')">rerender events</button>
  156. <button onclick="cal.fullCalendar('refetchEvents')">refetch events</button>
  157. <br />
  158. <button onclick="cal.fullCalendar('changeView', 'dayGridMonth')">change to month</button>
  159. <button onclick="cal.fullCalendar('changeView', 'dayGridWeek')">change to dayGridWeek</button>
  160. <button onclick="cal.fullCalendar('changeView', 'dayGridDay')">change to dayGridDay</button>
  161. <button onclick="getView()">getView</button>
  162. <button onclick="getDate()">getDate</button>
  163. <button onclick="optionGetter()">option getter</button>
  164. <button onclick="cal.width(1100)">change width (passive)</button>
  165. <button onclick="cal.fullCalendar('render')">render</button>
  166. <button onclick="cal.fullCalendar('option', 'height', 1000)">change height</button>
  167. </p>
  168. <div id='loading' style='position:absolute;display:none'>loading...</div>
  169. <div id='calendar' style='width:70%;margin:20px auto 0;font-family:arial'></div>
  170. </body>
  171. </html>