methods.html 6.0 KB

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