methods.html 5.9 KB

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