methods.html 5.5 KB

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