external-dragging.html 3.0 KB

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