fix some error
This commit is contained in:
parent
25d1187f99
commit
460d5a15f2
|
@ -19,7 +19,7 @@ var Calendar = function(dom,page_id,event_date=''){
|
|||
this.initialize = function(){
|
||||
if (event_date != ''){
|
||||
var event_dates = event_date.split("-");
|
||||
var date = new Date(event_dates[0],event_dates[1],event_dates[2]);
|
||||
var date = new Date(Date.UTC(event_dates[0],event_dates[1],event_dates[2]));
|
||||
}else{
|
||||
var date = new Date();
|
||||
}
|
||||
|
@ -358,8 +358,8 @@ var AgendaView = function(calendar){
|
|||
}
|
||||
var eventsManager = function(){
|
||||
var url = "/xhr/calendars/agenda",
|
||||
sd = new Date(start_year,start_month,1),
|
||||
ed = new Date(end_year,end_month+1,0),
|
||||
sd = new Date(Date.UTC(start_year,start_month,1)),
|
||||
ed = new Date(Date.UTC(end_year,end_month+1,0)),
|
||||
usd = Math.round(sd/1000),
|
||||
ued = Math.round(ed/1000);
|
||||
$.ajax({
|
||||
|
@ -395,7 +395,7 @@ var AgendaView = function(calendar){
|
|||
c_m = s.getMonth(),
|
||||
c_d = s.getDate(),
|
||||
c_y = s.getFullYear(),
|
||||
end_of_c_month = new Date(s.getFullYear(),s.getMonth()+1,0).getDate();
|
||||
end_of_c_month = new Date(Date.UTC(s.getFullYear(),s.getMonth()+1,0)).getDate();
|
||||
|
||||
for(var i = 0; i <= diffDays; i++){
|
||||
var td = agenda_space.find("td[data-date-node="+c_d+"-"+c_m+"-"+c_y+"]");
|
||||
|
@ -485,8 +485,8 @@ var AgendaView = function(calendar){
|
|||
this.monthDom = $("<div class='row' data-year='"+year+"' data-month='"+month+"'></div>");
|
||||
var template = $(month_template);
|
||||
var list_template = $(event_list_template);
|
||||
var firstDay = new Date(year,month,1);
|
||||
var lastDay = new Date(year,month+1,0);
|
||||
var firstDay = new Date(Date.UTC(year,month,1));
|
||||
var lastDay = new Date(Date.UTC(year,month+1,0));
|
||||
var last_inserted_date = 1;
|
||||
|
||||
var renderMonth = function(){
|
||||
|
@ -514,7 +514,7 @@ var AgendaView = function(calendar){
|
|||
var day = 1,
|
||||
sat_counter = 0,
|
||||
sunday_counter = 0,
|
||||
date = new Date(year, month, day);
|
||||
date = new Date(Date.UTC(year, month, day));
|
||||
|
||||
while(date.getMonth() === month) {
|
||||
if(date.getDay() === 0) {
|
||||
|
@ -523,7 +523,7 @@ var AgendaView = function(calendar){
|
|||
sat_counter++;
|
||||
}
|
||||
day++;
|
||||
date = new Date(year, month, day);
|
||||
date = new Date(Date.UTC(year, month, day));
|
||||
}
|
||||
return (sunday_counter == 5 && sat_counter == 5 ? 6 : 5);
|
||||
}
|
||||
|
|
|
@ -10,10 +10,10 @@
|
|||
fetchInterval = null,
|
||||
month = date.getMonth(),
|
||||
year = date.getFullYear(),
|
||||
first_target_day = new Date(year,month,1),
|
||||
last_target_day = new Date(year,month+1,0),
|
||||
firstDay = new Date(year,month,1),
|
||||
lastDay = new Date(year,month+1,0),
|
||||
first_target_day = new Date(Date.UTC(year,month,1)),
|
||||
last_target_day = new Date(Date.UTC(year,month+1,0)),
|
||||
firstDay = new Date(Date.UTC(year,month,1)),
|
||||
lastDay = new Date(Date.UTC(year,month+1,0)),
|
||||
today = date.getDate(),
|
||||
last_inserted_date = 1,
|
||||
monthDom = $("<div data-year='"+year+"' data-month='"+month+"'></div>"),
|
||||
|
@ -337,7 +337,7 @@
|
|||
if(dayDiff > 0){
|
||||
var inserting_date = sd.getDate();
|
||||
for(var i = 0;i <= dayDiff; i++){
|
||||
var dt = inserting_date + "-" + month + "-" + year,
|
||||
var dt = inserting_date + "-" + sd.getMonth() + "-" + sd.getFullYear(),
|
||||
td = dom.find("td[data-date-node=" + dt + "]");
|
||||
if (events[dt]==undefined){
|
||||
events[dt]=[]
|
||||
|
@ -370,7 +370,7 @@
|
|||
}
|
||||
})
|
||||
if (!toggle_data){
|
||||
if (dom.find('td.w-calendar-event.w-calendar-today').length != 0){
|
||||
if (dom.find('td.w-calendar-today').length != 0){
|
||||
toggle_event(dom.find('td.w-calendar-today'),'show')
|
||||
}else{
|
||||
toggle_event(dom.find('td'),'hide')
|
||||
|
@ -410,8 +410,8 @@
|
|||
year++;
|
||||
month = 0;
|
||||
}
|
||||
firstDay = new Date(year,month,1);
|
||||
lastDay = new Date(year,month+1,0);
|
||||
firstDay = new Date(Date.UTC(year,month,1));
|
||||
lastDay = new Date(Date.UTC(year,month+1,0));
|
||||
today = (initialDate.getMonth() == month && initialDate.getFullYear() == year ? initialDate.getDate() : 0);
|
||||
last_inserted_date = 1;
|
||||
var toggle_type,ele;
|
||||
|
@ -438,8 +438,8 @@
|
|||
year--;
|
||||
month = 11;
|
||||
}
|
||||
firstDay = new Date(year,month,1);
|
||||
lastDay = new Date(year,month+1,0);
|
||||
firstDay = new Date(Date.UTC(year,month,1));
|
||||
lastDay = new Date(Date.UTC(year,month+1,0));
|
||||
today = (initialDate.getMonth() == month && initialDate.getFullYear() == year ? initialDate.getDate() : 0);
|
||||
last_inserted_date = 1;
|
||||
var toggle_type,ele;
|
||||
|
|
|
@ -10,10 +10,10 @@
|
|||
fetchInterval = null,
|
||||
month = date.getMonth(),
|
||||
year = date.getFullYear(),
|
||||
first_target_day = new Date(year,month,1),
|
||||
last_target_day = new Date(year,month+1,0),
|
||||
firstDay = new Date(year,month,1),
|
||||
lastDay = new Date(year,month+1,0),
|
||||
first_target_day = new Date(Date.UTC(year,month,1)),
|
||||
last_target_day = new Date(Date.UTC(year,month+1,0)),
|
||||
firstDay = new Date(Date.UTC(year,month,1)),
|
||||
lastDay = new Date(Date.UTC(year,month+1,0)),
|
||||
today = date.getDate(),
|
||||
last_inserted_date = 1,
|
||||
monthDom = $("<div data-year='"+year+"' data-month='"+month+"'></div>"),
|
||||
|
@ -476,7 +476,7 @@
|
|||
if(dayDiff > 0){
|
||||
var inserting_date = sd.getDate();
|
||||
for(var i = 0;i <= dayDiff; i++){
|
||||
var dt = inserting_date + "-" + month + "-" + year,
|
||||
var dt = inserting_date + "-" + sd.getMonth() + "-" + sd.getFullYear(),
|
||||
td = dom.find("td[data-date-node=" + dt + "]");
|
||||
if (events[dt]==undefined){
|
||||
events[dt]=[]
|
||||
|
@ -509,7 +509,7 @@
|
|||
}
|
||||
})
|
||||
if (!toggle_data){
|
||||
if (dom.find('td.w-calendar-event.w-calendar-today').length != 0){
|
||||
if (dom.find('td.w-calendar-today').length != 0){
|
||||
toggle_event(dom.find('td.w-calendar-today'),'show')
|
||||
}else{
|
||||
toggle_event(dom.find('td'),'hide')
|
||||
|
@ -550,8 +550,8 @@
|
|||
year++;
|
||||
month = 0;
|
||||
}
|
||||
firstDay = new Date(year,month,1);
|
||||
lastDay = new Date(year,month+1,0);
|
||||
firstDay = new Date(Date.UTC(year,month,1));
|
||||
lastDay =new Date(Date.UTC(year,month+1,0));
|
||||
today = (initialDate.getMonth() == month && initialDate.getFullYear() == year ? initialDate.getDate() : 0);
|
||||
last_inserted_date = 1;
|
||||
var toggle_type,ele;
|
||||
|
@ -578,8 +578,8 @@
|
|||
year--;
|
||||
month = 11;
|
||||
}
|
||||
firstDay = new Date(year,month,1);
|
||||
lastDay = new Date(year,month+1,0);
|
||||
firstDay = new Date(Date.UTC(year,month,1));
|
||||
lastDay = new Date(Date.UTC(year,month+1,0));
|
||||
today = (initialDate.getMonth() == month && initialDate.getFullYear() == year ? initialDate.getDate() : 0);
|
||||
last_inserted_date = 1;
|
||||
var toggle_type,ele;
|
||||
|
|
|
@ -87,7 +87,7 @@ a.event-container{
|
|||
margin-top: 2em;
|
||||
}
|
||||
.widget-calendar-1 .w-calendar-nav a {
|
||||
top: 2em;
|
||||
top: 0.5em;
|
||||
}
|
||||
.calendar-dialog div.ui-dialog-content {
|
||||
max-height: 20em !important;
|
||||
|
|
|
@ -71,7 +71,7 @@ a.event-container-one{
|
|||
padding: 0.2em;
|
||||
font-size: 1.5em;
|
||||
}
|
||||
.widget-calendar-2 table.w-calendar-table td.w-calendar-toggle div {
|
||||
.widget-calendar-2 table.w-calendar-table td.w-calendar-toggle div, .widget-calendar-2 table.w-calendar-table td.w-calendar-toggle div{
|
||||
background: #6f0007;
|
||||
border-radius: 1.5em;
|
||||
color: white;
|
||||
|
|
|
@ -42,8 +42,8 @@ class CalendarsController < ApplicationController
|
|||
events =[]
|
||||
if !page.nil?
|
||||
if params[:start].present? && params[:end].present?
|
||||
sdt = Time.at(params[:start].to_i)
|
||||
edt = Time.at(params[:end].to_i)
|
||||
sdt = Time.at(params[:start].to_i).utc
|
||||
edt = Time.at(params[:end].to_i).utc
|
||||
events = Event.monthly_event(sdt,edt).convert_front+Event.recurring_event(sdt,edt)
|
||||
end
|
||||
end
|
||||
|
@ -64,15 +64,15 @@ class CalendarsController < ApplicationController
|
|||
calendar_types = []
|
||||
end
|
||||
if params[:unix_start].present? && params[:unix_end].present?
|
||||
agenda_start = Time.at(params[:unix_start].to_i).to_s
|
||||
agenda_end = Time.at(params[:unix_end].to_i).to_s
|
||||
agenda_start = Time.at(params[:unix_start].to_i).utc.to_s
|
||||
agenda_end = Time.at(params[:unix_end].to_i).utc.to_s
|
||||
if !calendar_types.blank?
|
||||
events = Event.where(:calendar_type_id.in => calendar_types).agenda_events(agenda_start,agenda_end)
|
||||
else
|
||||
events = Event.agenda_events(agenda_start,agenda_end)
|
||||
end
|
||||
end
|
||||
render json: {"events" => events,"calendar_title"=>get_calendar_title(Time.at(params[:month_start].to_i))}.to_json({"frontend" => true})
|
||||
render json: {"events" => events,"calendar_title"=>get_calendar_title(Time.at(params[:month_start].to_i).utc)}.to_json({"frontend" => true})
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -86,19 +86,19 @@ class CalendarsController < ApplicationController
|
|||
calendar_types = []
|
||||
end
|
||||
if params[:unix_start].present? && params[:unix_end].present?
|
||||
agenda_start = Time.at(params[:unix_start].to_i).to_s
|
||||
agenda_end = Time.at(params[:unix_end].to_i).to_s
|
||||
agenda_start = Time.at(params[:unix_start].to_i).utc.to_s
|
||||
agenda_end = Time.at(params[:unix_end].to_i).utc.to_s
|
||||
if !calendar_types.blank?
|
||||
events = Event.where(:calendar_type_id.in => calendar_types).agenda_events(agenda_start,agenda_end)
|
||||
else
|
||||
events = Event.agenda_events(agenda_start,agenda_end)
|
||||
end
|
||||
end
|
||||
render json: {"events" => events,"calendar_title"=>get_calendar_title(Time.at(params[:month_start].to_i))}.to_json({"frontend" => true})
|
||||
render json: {"events" => events,"calendar_title"=>get_calendar_title(Time.at(params[:month_start].to_i).utc)}.to_json({"frontend" => true})
|
||||
end
|
||||
end
|
||||
def get_calendar_title(now_date=nil)
|
||||
now_date = Time.now if now_date.nil?
|
||||
now_date = Time.now.utc if now_date.nil?
|
||||
month_name = I18n.locale.to_s=='zh_tw' ? now_date.month : I18n.t("calendar.month_name.#{now_date.month}")
|
||||
I18n.t("calendar.calendar_title",year: now_date.year,month: month_name)
|
||||
end
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<div class="w-calendar widget-calendar-1" data-module="calendar">
|
||||
<div class='month_template'>
|
||||
<h4 class="widget-title ">
|
||||
<span class="text"></span>
|
||||
<span class="text"><span style="display: none;">placeholder</span></span>
|
||||
<i class="fa fa-circle-o-notch fa-spin fa-fw loading hide"></i>
|
||||
</h4>
|
||||
<div class="w-calendar-nav">
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
</div>
|
||||
<div class='month_template'>
|
||||
<h4 class="widget-title ">
|
||||
<span class="text"></span>
|
||||
<span class="text"><span style="display: none;">placeholder</span></span>
|
||||
<i class="fa fa-circle-o-notch fa-spin fa-fw loading hide"></i>
|
||||
</h4>
|
||||
<div class="w-calendar-nav">
|
||||
|
|
|
@ -27,7 +27,9 @@
|
|||
</button>
|
||||
</div>
|
||||
<div id="view_holder">
|
||||
<h3 id="current_title" class="current_day_title"></h3>
|
||||
<h3 id="current_title" class="current_day_title">
|
||||
<span style="display: none;">placeholder</span>
|
||||
</h3>
|
||||
<div id="calendar"></div>
|
||||
<div id="calendar_agenda"></div>
|
||||
</div>
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
<div class="w-calendar widget-calendar-1 index2" data-module="calendar" data-page-id="{{page_id}}">
|
||||
<div class='month_template'>
|
||||
<h4 class="widget-title ">
|
||||
<span class="text"></span>
|
||||
<span class="text"><span style="display: none;">placeholder</span></span>
|
||||
<i class="fa fa-circle-o-notch fa-spin fa-fw loading hide"></i>
|
||||
</h4>
|
||||
<div class="w-calendar-nav">
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
</div>
|
||||
<div class='month_template'>
|
||||
<h4 class="widget-title ">
|
||||
<span class="text"></span>
|
||||
<span class="text"><span style="display: none;">placeholder</span></span>
|
||||
<i class="fa fa-circle-o-notch fa-spin fa-fw loading hide"></i>
|
||||
</h4>
|
||||
<div class="w-calendar-nav">
|
||||
|
|
Loading…
Reference in New Issue