droppable.html 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  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='../../node_modules/jquery/dist/jquery.js'></script>
  7. <script src='../../node_modules/components-jqueryui/jquery-ui.js'></script>
  8. <script src='../../node_modules/moment/moment.js'></script>
  9. <script src='../../dist/fullcalendar.js'></script>
  10. <script>
  11. $(document).ready(function() {
  12. var date = new Date();
  13. var d = date.getDate();
  14. var m = date.getMonth();
  15. var y = date.getFullYear();
  16. $('#calendar').fullCalendar({
  17. editable: true,
  18. droppable: true,
  19. drop: function(date, allDay, ev) {
  20. console.log('drop', date, allDay, ev);
  21. },
  22. //initialView: 'week',
  23. //firstDay: 1,
  24. //hiddenDays: [ 4, 6 ], // hide thursday and saturday
  25. //direction: 'rtl',
  26. //slotMinTime: '6:30am',
  27. headerToolbar: {
  28. left: 'prev,next today',
  29. center: 'title',
  30. right: 'dayGridMonth,week,dayGridWeek,day,dayGridDay'
  31. },
  32. events: [
  33. {
  34. title: 'All Day Event',
  35. start: new Date(y, m, 1)
  36. },
  37. {
  38. title: 'Long Event',
  39. start: new Date(y, m, d-5),
  40. end: new Date(y, m, d-2)
  41. },
  42. {
  43. groupId: 999,
  44. title: 'Repeating Event',
  45. start: new Date(y, m, d-3, 16, 0),
  46. allDay: false
  47. },
  48. {
  49. groupId: 999,
  50. title: 'Repeating Event',
  51. start: new Date(y, m, d+4, 16, 0),
  52. allDay: false
  53. },
  54. {
  55. title: 'Meeting',
  56. start: new Date(y, m, d, 10, 30),
  57. allDay: false
  58. },
  59. {
  60. title: 'Lunch',
  61. start: new Date(y, m, d, 12, 5),
  62. end: new Date(y, m, d, 14, 43),
  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. $('.external-event').draggable({
  80. revert: true,
  81. revertDuration: 0,
  82. zIndex: 999
  83. });
  84. $('#sortable-events').sortable();
  85. $('#calendar2').fullCalendar({
  86. //direction: 'rtl',
  87. droppable: true,
  88. dropAccept: '.for-calendar2',
  89. /*
  90. dropAccept: function(e) {
  91. console.log(e);
  92. console.log(this);
  93. return e.text() == 'Draggable 1';
  94. },
  95. */
  96. drop: function(date, allDay) {
  97. console.log('drop 2nd calendar', date, allDay);
  98. },
  99. headerToolbar: {
  100. left: 'prev,next today',
  101. center: 'title',
  102. right: 'dayGridMonth,week,dayGridWeek,day,dayGridDay'
  103. }
  104. });
  105. });
  106. </script>
  107. <style>
  108. body {
  109. margin-top: 40px;
  110. text-align: center;
  111. font-size: 13px;
  112. font-family: "Lucida Grande",Helvetica,Arial,Verdana,sans-serif;
  113. }
  114. #calendar {
  115. width: 900px;
  116. float: left;
  117. }
  118. #external-events, #sortable-events {
  119. position: relative;
  120. left: 50px;
  121. text-align: left;
  122. float: left;
  123. width: 140px;
  124. padding: 10px;
  125. border: 1px solid #aaa;
  126. background: #ccc;
  127. }
  128. .external-event, .sortable-event {
  129. height: 20px;
  130. line-height: 20px;
  131. color: #fff;
  132. background: blue;
  133. margin-bottom: 10px;
  134. padding-left: 5px;
  135. cursor: pointer;
  136. }
  137. #calendar2 {
  138. width: 900px;
  139. margin-top: 50px;
  140. }
  141. </style>
  142. </head>
  143. <body>
  144. <div id='calendar'></div>
  145. <div id='external-events'>
  146. <div class='external-event'>Draggable 1</div>
  147. <div class='external-event'>Draggable 2</div>
  148. <div class='external-event for-calendar2'>Draggable 3</div>
  149. </div>
  150. <div id='sortable-events'>
  151. <div class='sortable-event'>Sortable 1</div>
  152. <div class='sortable-event'>Sortable 2</div>
  153. <div class='sortable-event for-calendar2'>Sortable 3</div>
  154. </div>
  155. <div style='clear:both'></div>
  156. <div id='calendar2'></div>
  157. </body>
  158. </html>