external-dragging-touch-punch.html 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset='utf-8' />
  5. <link href='../../dist/fullcalendar.css' rel='stylesheet' />
  6. <link href='../../dist/fullcalendar.print.css' rel='stylesheet' media='print' />
  7. <script src='../../node_modules/moment/moment.js'></script>
  8. <script src='../../node_modules/jquery/dist/jquery.js'></script>
  9. <script src='../../node_modules/components-jqueryui/jquery-ui.js'></script>
  10. <script src='../../dist/fullcalendar.js'></script>
  11. <script src='https://cdnjs.cloudflare.com/ajax/libs/jqueryui-touch-punch/0.2.3/jquery.ui.touch-punch.min.js'></script>
  12. <script>
  13. $(document).ready(function() {
  14. /* initialize the external events
  15. -----------------------------------------------------------------*/
  16. $('#external-events .fc-event').each(function() {
  17. // store data so the calendar knows to render an event upon drop
  18. $(this).data('event', {
  19. title: $.trim($(this).text()), // use the element's text as the event title
  20. stick: true // maintain when user navigates (see docs on the renderEvent method)
  21. });
  22. // make the event draggable using jQuery UI
  23. $(this).draggable({
  24. zIndex: 999,
  25. revert: true, // will cause the event to go back to its
  26. revertDuration: 0 // original position after the drag
  27. });
  28. });
  29. /* initialize the calendar
  30. -----------------------------------------------------------------*/
  31. $('#calendar').fullCalendar({
  32. header: {
  33. left: 'prev,next today',
  34. center: 'title',
  35. right: 'month,agendaWeek,agendaDay'
  36. },
  37. editable: true,
  38. droppable: true, // this allows things to be dropped onto the calendar
  39. drop: function() {
  40. // is the "remove after drop" checkbox checked?
  41. if ($('#drop-remove').is(':checked')) {
  42. // if so, remove the element from the "Draggable Events" list
  43. $(this).remove();
  44. }
  45. }
  46. });
  47. });
  48. </script>
  49. <style>
  50. body {
  51. margin-top: 40px;
  52. text-align: center;
  53. font-size: 14px;
  54. font-family: "Lucida Grande",Helvetica,Arial,Verdana,sans-serif;
  55. }
  56. #wrap {
  57. width: 1100px;
  58. margin: 0 auto;
  59. }
  60. #external-events {
  61. float: left;
  62. width: 150px;
  63. padding: 0 10px;
  64. border: 1px solid #ccc;
  65. background: #eee;
  66. text-align: left;
  67. }
  68. #external-events h4 {
  69. font-size: 16px;
  70. margin-top: 0;
  71. padding-top: 1em;
  72. }
  73. #external-events .fc-event {
  74. margin: 10px 0;
  75. cursor: pointer;
  76. }
  77. #external-events p {
  78. margin: 1.5em 0;
  79. font-size: 11px;
  80. color: #666;
  81. }
  82. #external-events p input {
  83. margin: 0;
  84. vertical-align: middle;
  85. }
  86. #calendar {
  87. float: right;
  88. width: 900px;
  89. }
  90. </style>
  91. </head>
  92. <body>
  93. <div id='wrap'>
  94. <div id='external-events'>
  95. <h4>Draggable Events</h4>
  96. <div class='fc-event'>My Event 1</div>
  97. <div class='fc-event'>My Event 2</div>
  98. <div class='fc-event'>My Event 3</div>
  99. <div class='fc-event'>My Event 4</div>
  100. <div class='fc-event'>My Event 5</div>
  101. <p>
  102. <input type='checkbox' id='drop-remove' />
  103. <label for='drop-remove'>remove after drop</label>
  104. </p>
  105. </div>
  106. <div id='calendar'></div>
  107. <div style='clear:both'></div>
  108. </div>
  109. </body>
  110. </html>