Fix bug.
This commit is contained in:
parent
f47b8126ab
commit
af31570ee5
|
@ -341,9 +341,9 @@ var CalendarModuleMonth1 = function(date,dom,subpart,url,index_flag){
|
||||||
td.find('div').html(last_inserted_date<10 ? " "+last_inserted_date+" " : last_inserted_date);
|
td.find('div').html(last_inserted_date<10 ? " "+last_inserted_date+" " : last_inserted_date);
|
||||||
td.attr("data-date-node",last_inserted_date+"-"+firstDay.getMonth()+"-"+firstDay.getFullYear());
|
td.attr("data-date-node",last_inserted_date+"-"+firstDay.getMonth()+"-"+firstDay.getFullYear());
|
||||||
last_inserted_date++;
|
last_inserted_date++;
|
||||||
}else{first_line_first_date
|
}else{
|
||||||
td.find('div').text(first_line_first_date+i)
|
td.find('div').text(first_line_first_date+i)
|
||||||
td.attr("data-date-node",(+i)+"-"+first_line_first_month+"-"+first_line_first_year);
|
td.attr("data-date-node",(first_line_first_date+i)+"-"+first_line_first_month+"-"+first_line_first_year);
|
||||||
td.addClass("w-calendar-other-month")
|
td.addClass("w-calendar-other-month")
|
||||||
}
|
}
|
||||||
row.append(td);
|
row.append(td);
|
||||||
|
@ -368,10 +368,11 @@ var CalendarModuleMonth1 = function(date,dom,subpart,url,index_flag){
|
||||||
next_month = 0;
|
next_month = 0;
|
||||||
next_year = next_year + 1;
|
next_year = next_year + 1;
|
||||||
}
|
}
|
||||||
last_target_day = new Date(next_year,next_month,6-lastDay.getDay())
|
var offset = lastDay.getDay() - (window.calendar_variable.sunday_first ? 0 : 1);
|
||||||
|
last_target_day = new Date(next_year,next_month , 6 - lastDay.getDay());
|
||||||
for(var i = 0;i < 7;i++){
|
for(var i = 0;i < 7;i++){
|
||||||
var td = $("<td><div></div></td>");
|
var td = $("<td><div></div></td>");
|
||||||
if(i <= lastDay.getDay()){
|
if(i <= offset){
|
||||||
if(today != 0 && last_inserted_date == today){
|
if(today != 0 && last_inserted_date == today){
|
||||||
td.attr("class","w-calendar-today");
|
td.attr("class","w-calendar-today");
|
||||||
}
|
}
|
||||||
|
@ -379,8 +380,8 @@ var CalendarModuleMonth1 = function(date,dom,subpart,url,index_flag){
|
||||||
td.attr("data-date-node",last_inserted_date+"-"+firstDay.getMonth()+"-"+firstDay.getFullYear());
|
td.attr("data-date-node",last_inserted_date+"-"+firstDay.getMonth()+"-"+firstDay.getFullYear());
|
||||||
last_inserted_date++;
|
last_inserted_date++;
|
||||||
}else{
|
}else{
|
||||||
td.find('div').text(i-lastDay.getDay())
|
td.find('div').text(i - offset)
|
||||||
td.attr("data-date-node",(i-lastDay.getDay())+"-"+next_month+"-"+next_year);
|
td.attr("data-date-node",(i - offset)+"-"+next_month+"-"+next_year);
|
||||||
td.addClass("w-calendar-other-month")
|
td.addClass("w-calendar-other-month")
|
||||||
}
|
}
|
||||||
row.append(td);
|
row.append(td);
|
||||||
|
@ -439,9 +440,9 @@ var CalendarModuleMonth1 = function(date,dom,subpart,url,index_flag){
|
||||||
start_of_ed_date = get_start_of_date(ed_date),
|
start_of_ed_date = get_start_of_date(ed_date),
|
||||||
timeDiff = start_of_ed_date.getTime() - start_of_sd_date.getTime(),
|
timeDiff = start_of_ed_date.getTime() - start_of_sd_date.getTime(),
|
||||||
dayDiff = Math.ceil(timeDiff / (1000 * 3600 * 24));
|
dayDiff = Math.ceil(timeDiff / (1000 * 3600 * 24));
|
||||||
if(eve.allDay && dayDiff < 1){
|
// if(eve.allDay && dayDiff < 1){
|
||||||
dayDiff = 1
|
// dayDiff = 1
|
||||||
}
|
// }
|
||||||
if(dayDiff > 0){
|
if(dayDiff > 0){
|
||||||
var inserting_date = sd.getDate();
|
var inserting_date = sd.getDate();
|
||||||
for(var i = 0;i <= dayDiff; i++){
|
for(var i = 0;i <= dayDiff; i++){
|
||||||
|
|
|
@ -508,10 +508,11 @@ var CalendarModuleMonth2 = function(date,dom,subpart,url,index_flag){
|
||||||
next_month = 0;
|
next_month = 0;
|
||||||
next_year = next_year + 1;
|
next_year = next_year + 1;
|
||||||
}
|
}
|
||||||
last_target_day = new Date(next_year,next_month,6-lastDay.getDay())
|
var offset = lastDay.getDay() - (window.calendar_variable.sunday_first ? 0 : 1);
|
||||||
|
last_target_day = new Date(next_year,next_month , 6 - lastDay.getDay());
|
||||||
for(var i = 0;i < 7;i++){
|
for(var i = 0;i < 7;i++){
|
||||||
var td = $("<td><div></div></td>");
|
var td = $("<td><div></div></td>");
|
||||||
if(i <= lastDay.getDay()){
|
if(i <= offset){
|
||||||
if(today != 0 && last_inserted_date == today){
|
if(today != 0 && last_inserted_date == today){
|
||||||
td.attr("class","w-calendar-today");
|
td.attr("class","w-calendar-today");
|
||||||
}
|
}
|
||||||
|
@ -519,8 +520,8 @@ var CalendarModuleMonth2 = function(date,dom,subpart,url,index_flag){
|
||||||
td.attr("data-date-node",last_inserted_date+"-"+firstDay.getMonth()+"-"+firstDay.getFullYear());
|
td.attr("data-date-node",last_inserted_date+"-"+firstDay.getMonth()+"-"+firstDay.getFullYear());
|
||||||
last_inserted_date++;
|
last_inserted_date++;
|
||||||
}else{
|
}else{
|
||||||
td.find('div').text(i-lastDay.getDay())
|
td.find('div').text(i - offset)
|
||||||
td.attr("data-date-node",(i-lastDay.getDay())+"-"+next_month+"-"+next_year);
|
td.attr("data-date-node",(i - offset)+"-"+next_month+"-"+next_year);
|
||||||
td.addClass("w-calendar-other-month")
|
td.addClass("w-calendar-other-month")
|
||||||
}
|
}
|
||||||
row.append(td);
|
row.append(td);
|
||||||
|
@ -579,9 +580,9 @@ var CalendarModuleMonth2 = function(date,dom,subpart,url,index_flag){
|
||||||
start_of_ed_date = get_start_of_date(ed_date),
|
start_of_ed_date = get_start_of_date(ed_date),
|
||||||
timeDiff = start_of_ed_date.getTime() - start_of_sd_date.getTime(),
|
timeDiff = start_of_ed_date.getTime() - start_of_sd_date.getTime(),
|
||||||
dayDiff = Math.ceil(timeDiff / (1000 * 3600 * 24));
|
dayDiff = Math.ceil(timeDiff / (1000 * 3600 * 24));
|
||||||
if(eve.allDay && dayDiff < 1){
|
// if(eve.allDay && dayDiff < 1){
|
||||||
dayDiff = 1
|
// dayDiff = 1
|
||||||
}
|
// }
|
||||||
if(dayDiff > 0){
|
if(dayDiff > 0){
|
||||||
var inserting_date = sd.getDate();
|
var inserting_date = sd.getDate();
|
||||||
for(var i = 0;i <= dayDiff; i++){
|
for(var i = 0;i <= dayDiff; i++){
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
class Admin::CalendarsController < OrbitAdminController
|
class Admin::CalendarsController < OrbitAdminController
|
||||||
# GET /events
|
# GET /events
|
||||||
# GET /events.json
|
# GET /events.json
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@calendar_types = CalendarType.all
|
@calendar_types = CalendarType.all
|
||||||
@calendar_setting = CalendarSetting.first
|
@calendar_setting = CalendarSetting.first
|
||||||
|
@ -66,14 +65,16 @@ class Admin::CalendarsController < OrbitAdminController
|
||||||
else
|
else
|
||||||
@categories = CalendarType.where(:category_id.in => categories) rescue []
|
@categories = CalendarType.where(:category_id.in => categories) rescue []
|
||||||
end
|
end
|
||||||
@end_d_t = params[:endDate]
|
@end_d_t = @event.end
|
||||||
@start_d_t = params[:startDate]
|
@start_d_t = @event.start
|
||||||
@all_day = false;
|
@all_day = false;
|
||||||
@recurring = false;
|
@recurring = false;
|
||||||
if params
|
if params
|
||||||
case params[:allDay]
|
case params[:allDay]
|
||||||
when "true"
|
when "true"
|
||||||
@all_day = true
|
@all_day = true
|
||||||
|
@event.end = @event.end - 1.day
|
||||||
|
@end_d_t = @event.end
|
||||||
when "false"
|
when "false"
|
||||||
@all_day = false
|
@all_day = false
|
||||||
case params[:recurring]
|
case params[:recurring]
|
||||||
|
|
|
@ -2,7 +2,6 @@ class CalendarsController < ApplicationController
|
||||||
# GET /events
|
# GET /events
|
||||||
# GET /events.json
|
# GET /events.json
|
||||||
include ActionView::Helpers::AssetTagHelper
|
include ActionView::Helpers::AssetTagHelper
|
||||||
|
|
||||||
def index
|
def index
|
||||||
page = Page.where(page_id: OrbitHelper.params[:page_id]).first
|
page = Page.where(page_id: OrbitHelper.params[:page_id]).first
|
||||||
style_file = page.layout=='index3' ? '/assets/calendar_widget2' : '/assets/calendar_widget1'
|
style_file = page.layout=='index3' ? '/assets/calendar_widget2' : '/assets/calendar_widget1'
|
||||||
|
|
|
@ -0,0 +1,24 @@
|
||||||
|
module CalendarsHelper
|
||||||
|
def self.lighten_color(my_hex, percent)
|
||||||
|
if my_hex[0] == '#'
|
||||||
|
my_hex = my_hex[1..-1]
|
||||||
|
end
|
||||||
|
comp = ''
|
||||||
|
rgb = []
|
||||||
|
batch_size = (my_hex.length/3).ceil
|
||||||
|
(0...3).each do |i|
|
||||||
|
rgb << my_hex[batch_size*i ... batch_size*(i+1)]
|
||||||
|
end
|
||||||
|
rgb.each do |ch|
|
||||||
|
tmp = (ch.to_i(16) * (1+percent/100.0)).ceil
|
||||||
|
if tmp > 255
|
||||||
|
tmp = 255
|
||||||
|
end
|
||||||
|
if tmp < 0
|
||||||
|
tmp = 0
|
||||||
|
end
|
||||||
|
comp += format("%02x", tmp)
|
||||||
|
end
|
||||||
|
return '#'+comp
|
||||||
|
end
|
||||||
|
end
|
|
@ -165,7 +165,7 @@ class Event
|
||||||
:title => self.title,
|
:title => self.title,
|
||||||
:note => tmp_note,
|
:note => tmp_note,
|
||||||
:start => self.start.to_json.gsub('"',''),
|
:start => self.start.to_json.gsub('"',''),
|
||||||
:end => (self.all_day ? [self.start, self.end - 1.day].max : self.end).to_json.gsub('"',''),
|
:end => self.end.to_json.gsub('"',''),
|
||||||
:allDay => self.all_day,
|
:allDay => self.all_day,
|
||||||
:recurring => self.recurring,
|
:recurring => self.recurring,
|
||||||
:calendar => self.calendar_type_id.to_s,
|
:calendar => self.calendar_type_id.to_s,
|
||||||
|
@ -187,7 +187,7 @@ class Event
|
||||||
:title => self.title,
|
:title => self.title,
|
||||||
:note => tmp_note,
|
:note => tmp_note,
|
||||||
:start => self.start.to_json.gsub('"',''),
|
:start => self.start.to_json.gsub('"',''),
|
||||||
:end => (self.all_day ? [self.start, self.end - 1.day].max : self.end).to_json.gsub('"',''),
|
:end => self.end.to_json.gsub('"',''),
|
||||||
:allDay => self.all_day,
|
:allDay => self.all_day,
|
||||||
:recurring => self.recurring,
|
:recurring => self.recurring,
|
||||||
:calendar => self.calendar_type_id.to_s,
|
:calendar => self.calendar_type_id.to_s,
|
||||||
|
@ -217,6 +217,7 @@ class Event
|
||||||
def self.recurring_event(start_date, end_date, preserve_hide=false)
|
def self.recurring_event(start_date, end_date, preserve_hide=false)
|
||||||
@recurring_events = self.where(:recurring => true).any_of({:recurring_end_date=>nil}, {:recurring_end_date.gte=>start_date.utc})
|
@recurring_events = self.where(:recurring => true).any_of({:recurring_end_date=>nil}, {:recurring_end_date.gte=>start_date.utc})
|
||||||
@recurring = []
|
@recurring = []
|
||||||
|
start_date_utc_mjd = start_date.to_datetime.utc.mjd
|
||||||
@recurring_events.each do |re|
|
@recurring_events.each do |re|
|
||||||
has_recurring_end_date = re.recurring_end_date.present?
|
has_recurring_end_date = re.recurring_end_date.present?
|
||||||
data = re.as_json({}, true)
|
data = re.as_json({}, true)
|
||||||
|
@ -247,16 +248,21 @@ class Event
|
||||||
if period_str
|
if period_str
|
||||||
org_start = re.start
|
org_start = re.start
|
||||||
@start_date = re.start
|
@start_date = re.start
|
||||||
@end_date = (re.all_day ? [re.start, re.end - 1.day].max : re.end)
|
@end_date = re.end
|
||||||
freq = re.frequency.to_i
|
freq = re.frequency.to_i
|
||||||
interval = freq.send(period_str)
|
interval = freq.send(period_str)
|
||||||
tmp_hide_start = re.hide_start.clone
|
tmp_hide_start = re.hide_start.clone
|
||||||
if is_month
|
if is_month
|
||||||
add_interval = ((start_date.year * 12 + start_date.month) - (@start_date.year * 12 + @start_date.month) - 1)
|
add_interval = ((start_date.year * 12 + start_date.month) - (@start_date.year * 12 + @start_date.month))
|
||||||
elsif is_year
|
elsif is_year
|
||||||
add_interval = (start_date.year - @start_date.year - 1)
|
add_interval = (start_date.year - @start_date.year)
|
||||||
else
|
else
|
||||||
add_interval = (((start_date - @start_date - 1.day).to_i / 1.day) / days)
|
add_interval = (start_date_utc_mjd - @start_date.utc.mjd)
|
||||||
|
if add_interval < 0
|
||||||
|
add_interval = -(-add_interval / days)
|
||||||
|
else
|
||||||
|
add_interval = add_interval / days
|
||||||
|
end
|
||||||
end
|
end
|
||||||
if add_interval < 0
|
if add_interval < 0
|
||||||
add_interval = add_interval % freq
|
add_interval = add_interval % freq
|
||||||
|
|
|
@ -185,7 +185,7 @@
|
||||||
tmp_html = []
|
tmp_html = []
|
||||||
%>
|
%>
|
||||||
<% (0...7).each do |i| %>
|
<% (0...7).each do |i| %>
|
||||||
<% tmp = f.check_box_tag "#{f.object_name}[weekdays][]", i, weekdays.include?(i), {:class=>"weekdays-checkbox"}
|
<% tmp = f.check_box_tag "#{f.object_name}[weekdays][]", i, weekdays.include?(i), {:class=>"weekdays-checkbox", :"data-key"=>i}
|
||||||
tmp += t("calendar.short_day.#{i}")
|
tmp += t("calendar.short_day.#{i}")
|
||||||
tmp_html << tmp
|
tmp_html << tmp
|
||||||
%>
|
%>
|
||||||
|
@ -336,8 +336,15 @@
|
||||||
$("#event_start").change(function(){
|
$("#event_start").change(function(){
|
||||||
var _this = $(this);
|
var _this = $(this);
|
||||||
var date = $.ui_datepicker.parseDate(_this.data('datepicker').settings.dateFormat, _this.val());
|
var date = $.ui_datepicker.parseDate(_this.data('datepicker').settings.dateFormat, _this.val());
|
||||||
|
if($(".weekdays-checkbox:checked").length < 1){
|
||||||
$(".weekdays-checkbox").prop("checked", false);
|
$(".weekdays-checkbox").prop("checked", false);
|
||||||
$(".weekdays-checkbox").eq(date.getDay()).prop("checked", true);
|
$(".weekdays-checkbox").filter('[data-key="' + date.getDay().toString() + '"]').prop("checked", true);
|
||||||
|
}
|
||||||
|
var end_date = $('#event_end').val();
|
||||||
|
var start_date = _this.val();
|
||||||
|
if(end_date.length != 0 && end_date < start_date){
|
||||||
|
$('#event_end').val(start_date);
|
||||||
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
|
@ -25,14 +25,20 @@
|
||||||
.widget-calendar-2.w-calendar .w-calendar-table td.w-calendar-event[data-calendar-id="<%=c.id%>"] div{
|
.widget-calendar-2.w-calendar .w-calendar-table td.w-calendar-event[data-calendar-id="<%=c.id%>"] div{
|
||||||
border-color: <%= c.color %>;
|
border-color: <%= c.color %>;
|
||||||
}
|
}
|
||||||
.widget-calendar-2.w-calendar table.w-calendar-table td.w-calendar-toggle[data-calendar-id="<%=c.id%>"] div, .widget-calendar-2.w-calendar table.w-calendar-table td.w-calendar-toggle[data-calendar-id="<%=c.id%>"] div{
|
|
||||||
background: <%= c.color %>;
|
|
||||||
}
|
|
||||||
.has_event[data-calendar-id="<%=c.id%>"]{
|
.has_event[data-calendar-id="<%=c.id%>"]{
|
||||||
background: <%= c.color %>;
|
background: <%= c.color %>;
|
||||||
}
|
}
|
||||||
.event[data-calendar-id="<%=c.id%>"], .event[data-calendar-id="<%=c.id%>"] a{
|
.event[data-calendar-id="<%=c.id%>"], .event[data-calendar-id="<%=c.id%>"] a{
|
||||||
color: <%= c.color %>;
|
color: <%= c.color %>;
|
||||||
}
|
}
|
||||||
|
<% darken_color = CalendarsHelper.lighten_color(c.color, -45) %>
|
||||||
|
.widget-calendar-1 .w-calendar-table .w-calendar-event[data-calendar-id="<%=c.id%>"]:hover, .widget-calendar-1 .w-calendar-table .w-calendar-event[data-calendar-id="<%=c.id%>"].w-calendar-toggle
|
||||||
|
{
|
||||||
|
background: <%= darken_color %>;
|
||||||
|
}
|
||||||
|
.widget-calendar-2.w-calendar table.w-calendar-table td.w-calendar-toggle[data-calendar-id="<%=c.id%>"] div{
|
||||||
|
border-color: <%= darken_color %>;
|
||||||
|
background: <%= darken_color %>;
|
||||||
|
}
|
||||||
<% end if @calendar_types %>
|
<% end if @calendar_types %>
|
||||||
</style>
|
</style>
|
|
@ -6,6 +6,7 @@ Rails.application.routes.draw do
|
||||||
s = Site.first
|
s = Site.first
|
||||||
update_flag = s.respond_to?(:tmp_flags)
|
update_flag = s.respond_to?(:tmp_flags)
|
||||||
need_update = !update_flag || !(s.tmp_flags.include?('cf2'))
|
need_update = !update_flag || !(s.tmp_flags.include?('cf2'))
|
||||||
|
need_update2 = !update_flag || !(s.tmp_flags.include?('cf3'))
|
||||||
calendar_setting = CalendarSetting.first
|
calendar_setting = CalendarSetting.first
|
||||||
calendar_setting = CalendarSetting.create if calendar_setting.nil?
|
calendar_setting = CalendarSetting.create if calendar_setting.nil?
|
||||||
if need_update
|
if need_update
|
||||||
|
@ -33,6 +34,14 @@ Rails.application.routes.draw do
|
||||||
end
|
end
|
||||||
puts "Calendar fix!"
|
puts "Calendar fix!"
|
||||||
end
|
end
|
||||||
|
if need_update2
|
||||||
|
Event.where(:recurring=>true).each do |e|
|
||||||
|
if e.end == e.start + 1.day
|
||||||
|
e.end = e.start
|
||||||
|
e.save
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
scope "(:locale)", locale: Regexp.new(locales.join("|")) do
|
scope "(:locale)", locale: Regexp.new(locales.join("|")) do
|
||||||
|
|
Loading…
Reference in New Issue