methods.html 6.1 KB

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