fullcalendar_advanced.js 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326
  1. /* ------------------------------------------------------------------------------
  2. *
  3. * # Fullcalendar advanced options
  4. *
  5. * Demo JS code for extra_fullcalendar_advanced.html page
  6. *
  7. * ---------------------------------------------------------------------------- */
  8. // Setup module
  9. // ------------------------------
  10. var FullCalendarAdvanced = function() {
  11. //
  12. // Setup module components
  13. //
  14. // External events
  15. var _componentFullCalendarEvents = function() {
  16. if (!$().fullCalendar || typeof Switchery == 'undefined' || !$().draggable) {
  17. console.warn('Warning - fullcalendar.min.js, switchery.min.js or jQuery UI is not loaded.');
  18. return;
  19. }
  20. // Add demo events
  21. // ------------------------------
  22. // Event colors
  23. var eventColors = [
  24. {
  25. title: 'All Day Event',
  26. start: '2014-11-01',
  27. color: '#EF5350'
  28. },
  29. {
  30. title: 'Long Event',
  31. start: '2014-11-07',
  32. end: '2014-11-10',
  33. color: '#26A69A'
  34. },
  35. {
  36. id: 999,
  37. title: 'Repeating Event',
  38. start: '2014-11-09T16:00:00',
  39. color: '#26A69A'
  40. },
  41. {
  42. id: 999,
  43. title: 'Repeating Event',
  44. start: '2014-11-16T16:00:00',
  45. color: '#5C6BC0'
  46. },
  47. {
  48. title: 'Conference',
  49. start: '2014-11-11',
  50. end: '2014-11-13',
  51. color: '#546E7A'
  52. },
  53. {
  54. title: 'Meeting',
  55. start: '2014-11-12T10:30:00',
  56. end: '2014-11-12T12:30:00',
  57. color: '#546E7A'
  58. },
  59. {
  60. title: 'Lunch',
  61. start: '2014-11-12T12:00:00',
  62. color: '#546E7A'
  63. },
  64. {
  65. title: 'Meeting',
  66. start: '2014-11-12T14:30:00',
  67. color: '#546E7A'
  68. },
  69. {
  70. title: 'Happy Hour',
  71. start: '2014-11-12T17:30:00',
  72. color: '#546E7A'
  73. },
  74. {
  75. title: 'Dinner',
  76. start: '2014-11-12T20:00:00',
  77. color: '#546E7A'
  78. },
  79. {
  80. title: 'Birthday Party',
  81. start: '2014-11-13T07:00:00',
  82. color: '#546E7A'
  83. },
  84. {
  85. title: 'Click for Google',
  86. url: 'http://google.com/',
  87. start: '2014-11-28',
  88. color: '#FF7043'
  89. }
  90. ];
  91. // External events
  92. // ------------------------------
  93. // Add switcher for events removal
  94. var remove = document.querySelector('.form-check-input-switchery');
  95. var removeInit = new Switchery(remove);
  96. // Initialize the calendar
  97. $('.fullcalendar-external').fullCalendar({
  98. header: {
  99. left: 'prev,next today',
  100. center: 'title',
  101. right: 'month,agendaWeek,agendaDay'
  102. },
  103. editable: true,
  104. defaultDate: '2014-11-12',
  105. events: eventColors,
  106. locale: 'en',
  107. droppable: true, // this allows things to be dropped onto the calendar
  108. drop: function() {
  109. if ($('#drop-remove').is(':checked')) { // is the "remove after drop" checkbox checked?
  110. $(this).remove(); // if so, remove the element from the "Draggable Events" list
  111. }
  112. },
  113. isRTL: $('html').attr('dir') == 'rtl' ? true : false
  114. });
  115. // Initialize the external events
  116. $('#external-events .fc-event').each(function() {
  117. // Different colors for events
  118. $(this).css({'backgroundColor': $(this).data('color'), 'borderColor': $(this).data('color')});
  119. // Store data so the calendar knows to render an event upon drop
  120. $(this).data('event', {
  121. title: $.trim($(this).html()), // use the element's text as the event title
  122. color: $(this).data('color'),
  123. stick: true // maintain when user navigates (see docs on the renderEvent method)
  124. });
  125. // Make the event draggable using jQuery UI
  126. $(this).draggable({
  127. zIndex: 999,
  128. revert: true, // will cause the event to go back to its
  129. revertDuration: 0 // original position after the drag
  130. });
  131. });
  132. };
  133. // FullCalendar RTL direction
  134. var _componentFullCalendarRTL = function() {
  135. if (!$().fullCalendar) {
  136. console.warn('Warning - fullcalendar.min.js is not loaded.');
  137. return;
  138. }
  139. // Add demo events
  140. // ------------------------------
  141. // Default events
  142. var events = [
  143. {
  144. title: 'All Day Event',
  145. start: '2014-11-01'
  146. },
  147. {
  148. title: 'Long Event',
  149. start: '2014-11-07',
  150. end: '2014-11-10'
  151. },
  152. {
  153. id: 999,
  154. title: 'Repeating Event',
  155. start: '2014-11-09T16:00:00'
  156. },
  157. {
  158. id: 999,
  159. title: 'Repeating Event',
  160. start: '2014-11-16T16:00:00'
  161. },
  162. {
  163. title: 'Conference',
  164. start: '2014-11-11',
  165. end: '2014-11-13'
  166. },
  167. {
  168. title: 'Meeting',
  169. start: '2014-11-12T10:30:00',
  170. end: '2014-11-12T12:30:00'
  171. },
  172. {
  173. title: 'Lunch',
  174. start: '2014-11-12T12:00:00'
  175. },
  176. {
  177. title: 'Meeting',
  178. start: '2014-11-12T14:30:00'
  179. },
  180. {
  181. title: 'Happy Hour',
  182. start: '2014-11-12T17:30:00'
  183. },
  184. {
  185. title: 'Dinner',
  186. start: '2014-11-12T20:00:00'
  187. },
  188. {
  189. title: 'Birthday Party',
  190. start: '2014-11-13T07:00:00'
  191. },
  192. {
  193. title: 'Click for Google',
  194. url: 'http://google.com/',
  195. start: '2014-11-28'
  196. }
  197. ];
  198. // Event colors
  199. var eventColors = [
  200. {
  201. title: 'All Day Event',
  202. start: '2014-11-01',
  203. color: '#EF5350'
  204. },
  205. {
  206. title: 'Long Event',
  207. start: '2014-11-07',
  208. end: '2014-11-10',
  209. color: '#26A69A'
  210. },
  211. {
  212. id: 999,
  213. title: 'Repeating Event',
  214. start: '2014-11-09T16:00:00',
  215. color: '#26A69A'
  216. },
  217. {
  218. id: 999,
  219. title: 'Repeating Event',
  220. start: '2014-11-16T16:00:00',
  221. color: '#5C6BC0'
  222. },
  223. {
  224. title: 'Conference',
  225. start: '2014-11-11',
  226. end: '2014-11-13',
  227. color: '#546E7A'
  228. },
  229. {
  230. title: 'Meeting',
  231. start: '2014-11-12T10:30:00',
  232. end: '2014-11-12T12:30:00',
  233. color: '#546E7A'
  234. },
  235. {
  236. title: 'Lunch',
  237. start: '2014-11-12T12:00:00',
  238. color: '#546E7A'
  239. },
  240. {
  241. title: 'Meeting',
  242. start: '2014-11-12T14:30:00',
  243. color: '#546E7A'
  244. },
  245. {
  246. title: 'Happy Hour',
  247. start: '2014-11-12T17:30:00',
  248. color: '#546E7A'
  249. },
  250. {
  251. title: 'Dinner',
  252. start: '2014-11-12T20:00:00',
  253. color: '#546E7A'
  254. },
  255. {
  256. title: 'Birthday Party',
  257. start: '2014-11-13T07:00:00',
  258. color: '#546E7A'
  259. },
  260. {
  261. title: 'Click for Google',
  262. url: 'http://google.com/',
  263. start: '2014-11-28',
  264. color: '#FF7043'
  265. }
  266. ];
  267. // RTL direction
  268. // ------------------------------
  269. $('.fullcalendar-rtl').fullCalendar({
  270. header: {
  271. left: 'prev,next today',
  272. center: 'title',
  273. right: 'month,agendaWeek,agendaDay'
  274. },
  275. defaultDate: '2014-11-12',
  276. editable: true,
  277. isRTL: true,
  278. locale: 'ar',
  279. events: events
  280. });
  281. };
  282. //
  283. // Return objects assigned to module
  284. //
  285. return {
  286. init: function() {
  287. _componentFullCalendarEvents();
  288. _componentFullCalendarRTL();
  289. }
  290. }
  291. }();
  292. // Initialize module
  293. // ------------------------------
  294. document.addEventListener('DOMContentLoaded', function() {
  295. FullCalendarAdvanced.init();
  296. });