diff --git a/app/assets/javascripts/calendar_frontend.js b/app/assets/javascripts/calendar_frontend.js index 5901a16..d76a3f2 100644 --- a/app/assets/javascripts/calendar_frontend.js +++ b/app/assets/javascripts/calendar_frontend.js @@ -1,5 +1,4 @@ -var Calendar = function(dom,page_id){ - +var Calendar = function(dom,page_id,event_date=''){ c = this; this.title = $("#current_title"); this.calendar = $(dom); @@ -18,7 +17,13 @@ var Calendar = function(dom,page_id){ var agendaView = new AgendaView(c); var loadeventsonviewchange = false; this.initialize = function(){ - var date = new Date(); + if (event_date != ''){ + var event_dates = event_date.split("-"); + var date = new Date(event_dates[0],event_dates[1],event_dates[2]); + }else{ + var date = new Date(); + } + // var date = new Date(); var d = date.getDate(); var m = date.getMonth(); var y = date.getFullYear(); @@ -47,6 +52,10 @@ var Calendar = function(dom,page_id){ c.dialog.show({"x":e.originalEvent.clientX,"y":e.originalEvent.clientY}); } }); + + if (event_date != ''){ + c.calendar.fullCalendar('gotoDate', y, (m - 1), d); + } c.nextBtn.click(function(){ c.dialog.dismiss(); diff --git a/app/assets/javascripts/calendar_widget.js b/app/assets/javascripts/calendar_widget.js index 4a2d360..7d8122a 100644 --- a/app/assets/javascripts/calendar_widget.js +++ b/app/assets/javascripts/calendar_widget.js @@ -122,6 +122,9 @@ ed = new Date(eve.end), timeDiff = Math.abs(ed.getTime() - sd.getTime()), dayDiff = Math.ceil(timeDiff / (1000 * 3600 * 24)); + if(eve.allDay){ + dayDiff = 1 ; + } if(dayDiff > 0){ var inserting_date = (sd < firstDay ? 1 : sd.getDate()); for(i = 0;i <= dayDiff; i++){ @@ -130,7 +133,7 @@ td.addClass("w-calendar-event"); if(index_url != ""){ td.on("click",function(){ - window.location.href = "http://" + window.location.host + index_url; + window.location.href = "http://" + window.location.host + index_url + '/' + eve.id + '-'; }) } inserting_date++; diff --git a/app/controllers/calendars_controller.rb b/app/controllers/calendars_controller.rb index 0dcf2f1..b820565 100644 --- a/app/controllers/calendars_controller.rb +++ b/app/controllers/calendars_controller.rb @@ -11,6 +11,15 @@ class CalendarsController < ApplicationController } end + def show + params = OrbitHelper.params + event = Event.find(params[:uid]) + { + "page_id" => params[:page_id], + "event_date" => event.start.strftime("%Y-%m-%d") + } + end + def widget part = OrbitHelper.get_current_widget diff --git a/app/views/calendars/show.html.erb b/app/views/calendars/show.html.erb new file mode 100644 index 0000000..20f0461 --- /dev/null +++ b/app/views/calendars/show.html.erb @@ -0,0 +1,7 @@ + +<%= javascript_include_tag 'fullcalendar' %> +<%= javascript_include_tag 'calendar_frontend' %> +<%= stylesheet_link_tag "fullcalendar"%> +<%= stylesheet_link_tag "calendar"%> + +<%= render_view %> \ No newline at end of file