Advertisement
Guest User

Untitled

a guest
Jun 30th, 2016
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.49 KB | None | 0 0
  1. function updateEvent(the_event) {
  2. $.update(
  3. "/events/" + the_event.id,
  4. { event: { title: the_event.title,
  5. starts_at: "" + the_event.start,
  6. ends_at: "" + the_event.end,
  7. description: the_event.description
  8. }
  9. },
  10. function (reponse) { alert('successfully updated task.'); }
  11. );
  12.  
  13. $('#calendar').fullCalendar({
  14. ...
  15. editable: true,
  16. eventDrop: function(event,dayDelta,minuteDelta,allDay,revertFunc) {
  17. $.ajax({
  18. type:"PUT",
  19. url: "/events/"+event.id,
  20. data: "minute_delta="+minuteDelta+"&day_delta="+dayDelta,
  21. ..
  22. });
  23. }
  24. });
  25.  
  26. I am new in Rails,i want to update this below calendar code.It's been a while since built it.so please guide me,how to update this code,Now i am using Rails version 4.0.2
  27.  
  28. <% if current_siteuser.role == "attorney" && session[:activeclient] %>
  29. <h3>Calendar for Current Client: <%= @client_profile.first.humanize %> <%= @client_profile.last.humanize%> <b><font size=-2>
  30. </font></b></h3>
  31. <% end %>
  32.  
  33.  
  34. <script>
  35. $(document).on('ready page:load', function() {
  36.  
  37. $('#erikcalendar').fullCalendar({
  38. <% if current_siteuser == "attorney" %>
  39. <% else %>
  40. <% end %>
  41. header: {
  42. center: 'title',
  43. right: 'month,basicWeek,basicDay',
  44. left: 'today prev,next agendaWeek,agendaDay'
  45. },
  46. events: [
  47. <% if !@events.nil? %>
  48. <% @events.each do |event| %>
  49. <% if !event.recurrence_id.blank? %>
  50. <% @recur = Recurrence.find(event.recurrence_id) %>
  51. <% if @recur.repeat_unit == 'daily' then %>
  52. <% @rstart_date = event.start_date.to_date %>
  53. <% until @rstart_date > @recur.until_date %>
  54. {
  55. <% if @rstart_date and event.title then %>
  56. title: '<%= raw event.title.gsub("'", "\\'") %>',
  57. start: '<%= @rstart_date.strftime('%Y/%m/%d') %>',
  58. url: '<%= edit_event_path(event) %>'
  59. <% if event.created_by == current_siteuser.id then %>
  60. ,color: '#ffc90e'
  61. <% elsif event.created_by == current_siteuser.attorney_id %>
  62. ,color: '#94D4E9'
  63. <% end %>
  64. <% end %>
  65. <% if event.end_date then %>
  66. ,end: '<%= event.end_date.strftime('%Y/%m/%d') %>'
  67. <% end %>
  68. },
  69. <% @rstart_date = @rstart_date + 1.day %>
  70. <% end %>
  71. <% elsif @recur.repeat_unit == 'weekly' then %>
  72. <% @rstart_date = event.start_date.to_date %>
  73. <% until @rstart_date > @recur.until_date %>
  74. {
  75. <% if @rstart_date and event.title then %>
  76. title: '<%= raw event.title.gsub("'", "\\'") %>',
  77. start: '<%= @rstart_date.strftime('%Y/%m/%d') %>',
  78. url: '<%= edit_event_path(event) %>'
  79. <% if event.created_by == current_siteuser.id then %>
  80. ,color: '#ffc90e'
  81. <% elsif event.created_by == current_siteuser.attorney_id %>
  82. ,color: '#94D4E9'
  83. <% end %>
  84. <% end %>
  85. <% if event.end_date then %>
  86. ,end: '<%= event.end_date.strftime('%Y/%m/%d') %>'
  87. <% end %>
  88. },
  89. <% @rstart_date = @rstart_date + 7.days %>
  90. <% end %>
  91. <% end %>
  92. <% else %>
  93. {
  94. <% if event.start_date and event.title then %>
  95. title: '<%= raw event.title.gsub("'", "\\'") %>',
  96. start: '<%= event.start_date.strftime('%Y/%m/%d') %>',
  97. url: '<%= edit_event_path(event) %>'
  98. <% if event.created_by == current_siteuser.id then %>
  99. ,color: '#ffc90e'
  100. <% elsif event.created_by == current_siteuser.attorney_id %>
  101. ,color: '#94D4E9'
  102. <% end %>
  103. <% end %>
  104. <% if event.end_date then %>
  105. ,end: '<%= event.end_date.strftime('%Y/%m/%d') %>'
  106. <% end %>
  107. },
  108. <% end %>
  109. <% end %>
  110. <% end %>
  111. {
  112. title: 'test',
  113. start: '2012/09/12',
  114. color: '#ff0000'
  115. }
  116.  
  117. ]
  118.  
  119. })
  120. });
  121. </script>
  122. </center>
  123.  
  124. <br />
  125. <div id='erikcalendar'></div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement