Advertisement
Guest User

Untitled

a guest
Jun 16th, 2019
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.44 KB | None | 0 0
  1. eventClick: function(calEvent, jsEvent, view) {
  2.  
  3. alert('Event: ' + calEvent.title);
  4. alert('Coordinates: ' + jsEvent.pageX + ',' + jsEvent.pageY);
  5. alert('View: ' + view.name);
  6. alert('This needs to be deleted');
  7.  
  8. // change the border color just for fun
  9. $(this).css('border-color', 'red');
  10. $('#calendar').fullCalendar(
  11. 'removeEvents'
  12. [this] );
  13.  
  14. },
  15.  
  16. $('#calendar').fullCalendar('removeEvents' , function(ev){
  17. return (ev._id == calEvent._id);
  18. })
  19.  
  20. $('#calendar').fullCalendar('removeEvents', calEvent._id);
  21.  
  22. event = {
  23. start: "2017-04-06T16:00:00.510Z",
  24. end: "2017-04-06T21:00:00.510Z",
  25. id: "idForThisEvent",
  26. title: "Event 1"
  27. }
  28.  
  29. eventClick: function(calEvent, jsEvent, view) {
  30. $('#calendar').fullCalendar('removeEvents', calEvent.id);
  31. },
  32.  
  33. eventRender = ({ event, el }) => {
  34. const duration = moment.duration(moment(event.end).diff(event.start))
  35. const hours = duration.asHours()
  36.  
  37. el.style.border = `1px solid ${event.backgroundColor}`
  38. el.className = `${el.className} event-class` // allows showing the edit and remove buttons only when hovering over the event
  39.  
  40. if (!event.extendedProps.published && !event.allDay) {
  41. el.className = el.className + ' unpublished' //it grays out the event if it hasn't been published
  42. }
  43.  
  44. const child = document.createElement('div')
  45. child.innerHTML = `
  46. <div>
  47. <div style="${styles.title}" class="pt-4">
  48. <strong>${hours} hrs </strong>
  49. </div>
  50.  
  51. <div class="event-actions">
  52. <button style="${styles.editStyle}" data-event-id=${event.id}>
  53. <i class='fa fa-edit'></i>
  54. </button>
  55. <button style="${styles.removeStyle}" data-event-id=${event.id}>
  56. <i class='fa fa-trash-o'></i>
  57. </button>
  58. </div>
  59. </div>`
  60.  
  61. el.appendChild(child)
  62. const btns = el.getElementsByTagName('button')
  63. const self = this
  64. btns[0].addEventListener('click', e => {
  65. self.onEditEvent(e)
  66. })
  67. btns[1].addEventListener('click', e => {
  68. self.onRemoveEvent(e)
  69. })
  70. }
  71.  
  72. .fc-time-grid .fc-event {
  73. overflow: auto;
  74. }
  75.  
  76. .event-class .event-actions {
  77. display: none;
  78. }
  79.  
  80.  
  81. .event-class:hover .event-actions {
  82. display: flex;
  83. justify-content: space-around;
  84. font-size: 1.75rem;
  85. padding-top: 4px;
  86. }
  87.  
  88. .unpublished {
  89. background-image: url('../assets/img/unpublish.png');
  90. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement