parent
22b451eb63
commit
876434e6a5
|
@ -19,6 +19,14 @@ if(!(window.calendar_variable.dayNames)){
|
||||||
window.calendar_variable.dayNamesShort = ['Sun', 'Mon', 'Tue', 'Wed','Thu', 'Fri', 'Sat'];
|
window.calendar_variable.dayNamesShort = ['Sun', 'Mon', 'Tue', 'Wed','Thu', 'Fri', 'Sat'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if(Array.prototype.rotate == undefined){
|
||||||
|
Array.prototype.rotate = function(n) {
|
||||||
|
n = n % this.length;
|
||||||
|
while (this.length && n < 0) n += this.length;
|
||||||
|
this.push.apply(this, this.splice(0, n));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
}
|
||||||
if(window.calendar_variable.is_chinese){
|
if(window.calendar_variable.is_chinese){
|
||||||
window.calendar_variable.months = [];
|
window.calendar_variable.months = [];
|
||||||
for(var i=0;i<12;i++){
|
for(var i=0;i<12;i++){
|
||||||
|
@ -729,7 +737,7 @@ var AgendaView = function(calendar){
|
||||||
'<table class="table table-condensed table-bordered">' +
|
'<table class="table table-condensed table-bordered">' +
|
||||||
'<tbody>' +
|
'<tbody>' +
|
||||||
'<tr>' +
|
'<tr>' +
|
||||||
calendar_variable.dayNamesShort.map(function(title){
|
calendar_variable.dayNamesShort.slice(0).rotate(calendar_variable.sunday_first ? 0 : 1).map(function(title){
|
||||||
return '<th class="week_title">'+title+'</th>';
|
return '<th class="week_title">'+title+'</th>';
|
||||||
}).join('') +
|
}).join('') +
|
||||||
'</tr>' +
|
'</tr>' +
|
||||||
|
@ -1066,9 +1074,10 @@ var AgendaView = function(calendar){
|
||||||
var row = $("<tr></tr>");
|
var row = $("<tr></tr>");
|
||||||
switch (position){
|
switch (position){
|
||||||
case "first":
|
case "first":
|
||||||
|
var offset = firstDay.getDay() - (window.calendar_variable.sunday_first ? 0 : 1);
|
||||||
for(var i = 0;i < 7;i++){
|
for(var i = 0;i < 7;i++){
|
||||||
var td = $("<td></td>");
|
var td = $("<td></td>");
|
||||||
if(i >= firstDay.getDay()){
|
if(i >= offset){
|
||||||
td.text(last_inserted_date);
|
td.text(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++;
|
||||||
|
@ -1086,9 +1095,10 @@ var AgendaView = function(calendar){
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "last":
|
case "last":
|
||||||
|
var offset = lastDay.getDay() - (window.calendar_variable.sunday_first ? 0 : 1);
|
||||||
for(var i = 0;i < 7;i++){
|
for(var i = 0;i < 7;i++){
|
||||||
var td = $("<td></td>");
|
var td = $("<td></td>");
|
||||||
if(i <= lastDay.getDay()){
|
if(i <= offset){
|
||||||
td.text(last_inserted_date);
|
td.text(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++;
|
||||||
|
|
|
@ -19,6 +19,14 @@ if(!(window.calendar_variable.dayNames)){
|
||||||
window.calendar_variable.dayNamesShort = ['Sun', 'Mon', 'Tue', 'Wed','Thu', 'Fri', 'Sat'];
|
window.calendar_variable.dayNamesShort = ['Sun', 'Mon', 'Tue', 'Wed','Thu', 'Fri', 'Sat'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if(Array.prototype.rotate == undefined){
|
||||||
|
Array.prototype.rotate = function(n) {
|
||||||
|
n = n % this.length;
|
||||||
|
while (this.length && n < 0) n += this.length;
|
||||||
|
this.push.apply(this, this.splice(0, n));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
}
|
||||||
if(window.calendar_variable.is_chinese){
|
if(window.calendar_variable.is_chinese){
|
||||||
window.calendar_variable.months = [];
|
window.calendar_variable.months = [];
|
||||||
for(var i=0;i<12;i++){
|
for(var i=0;i<12;i++){
|
||||||
|
@ -560,7 +568,7 @@ var AgendaView = function(calendar){
|
||||||
'<table class="table table-condensed table-bordered">' +
|
'<table class="table table-condensed table-bordered">' +
|
||||||
'<tbody>' +
|
'<tbody>' +
|
||||||
'<tr>' +
|
'<tr>' +
|
||||||
calendar_variable.dayNamesShort.map(function(title){
|
calendar_variable.dayNamesShort.slice(0).rotate(calendar_variable.sunday_first ? 0 : 1).map(function(title){
|
||||||
return '<th class="week_title">'+title+'</th>';
|
return '<th class="week_title">'+title+'</th>';
|
||||||
}).join('') +
|
}).join('') +
|
||||||
'</tr>' +
|
'</tr>' +
|
||||||
|
@ -898,9 +906,10 @@ var AgendaView = function(calendar){
|
||||||
var row = $("<tr></tr>");
|
var row = $("<tr></tr>");
|
||||||
switch (position){
|
switch (position){
|
||||||
case "first":
|
case "first":
|
||||||
|
var offset = firstDay.getDay() - (window.calendar_variable.sunday_first ? 0 : 1);
|
||||||
for(var i = 0;i < 7;i++){
|
for(var i = 0;i < 7;i++){
|
||||||
var td = $("<td></td>");
|
var td = $("<td></td>");
|
||||||
if(i >= firstDay.getDay()){
|
if(i >= offset){
|
||||||
td.text(last_inserted_date);
|
td.text(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++;
|
||||||
|
@ -918,9 +927,10 @@ var AgendaView = function(calendar){
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "last":
|
case "last":
|
||||||
|
var offset = lastDay.getDay() - (window.calendar_variable.sunday_first ? 0 : 1);
|
||||||
for(var i = 0;i < 7;i++){
|
for(var i = 0;i < 7;i++){
|
||||||
var td = $("<td></td>");
|
var td = $("<td></td>");
|
||||||
if(i <= lastDay.getDay()){
|
if(i <= offset){
|
||||||
td.text(last_inserted_date);
|
td.text(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++;
|
||||||
|
|
|
@ -326,23 +326,24 @@ var CalendarModuleMonth1 = function(date,dom,subpart,url,index_flag){
|
||||||
var row = $("<tr></tr>");
|
var row = $("<tr></tr>");
|
||||||
switch (position){
|
switch (position){
|
||||||
case "first":
|
case "first":
|
||||||
var first_line_first_day = new Date(year,month,firstDay.getDate()-firstDay.getDay())
|
var offset = firstDay.getDay() - (window.calendar_variable.sunday_first ? 0 : 1);
|
||||||
|
var first_line_first_day = new Date(year,month,firstDay.getDate() - offset)
|
||||||
var first_line_first_date = first_line_first_day.getDate()
|
var first_line_first_date = first_line_first_day.getDate()
|
||||||
var first_line_first_month = first_line_first_day.getMonth()
|
var first_line_first_month = first_line_first_day.getMonth()
|
||||||
var first_line_first_year = first_line_first_day.getFullYear()
|
var first_line_first_year = first_line_first_day.getFullYear()
|
||||||
first_target_day = new Date(first_line_first_year,first_line_first_month,first_line_first_date)
|
first_target_day = new Date(first_line_first_year,first_line_first_month,first_line_first_date)
|
||||||
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 >= firstDay.getDay()){
|
if(i >= offset){
|
||||||
if(today != 0 && last_inserted_date == today){
|
if(today != 0 && last_inserted_date == today){
|
||||||
td.addClass("w-calendar-today");
|
td.addClass("w-calendar-today");
|
||||||
}
|
}
|
||||||
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{
|
}else{first_line_first_date
|
||||||
td.find('div').text(first_line_first_date+i)
|
td.find('div').text(first_line_first_date+i)
|
||||||
td.attr("data-date-node",(first_line_first_date+i)+"-"+first_line_first_month+"-"+first_line_first_year);
|
td.attr("data-date-node",(+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);
|
||||||
|
|
|
@ -466,14 +466,15 @@ var CalendarModuleMonth2 = function(date,dom,subpart,url,index_flag){
|
||||||
var row = $("<tr></tr>");
|
var row = $("<tr></tr>");
|
||||||
switch (position){
|
switch (position){
|
||||||
case "first":
|
case "first":
|
||||||
var first_line_first_day = new Date(year,month,firstDay.getDate()-firstDay.getDay())
|
var offset = firstDay.getDay() - (window.calendar_variable.sunday_first ? 0 : 1);
|
||||||
|
var first_line_first_day = new Date(year,month,firstDay.getDate() - offset)
|
||||||
var first_line_first_date = first_line_first_day.getDate()
|
var first_line_first_date = first_line_first_day.getDate()
|
||||||
var first_line_first_month = first_line_first_day.getMonth()
|
var first_line_first_month = first_line_first_day.getMonth()
|
||||||
var first_line_first_year = first_line_first_day.getFullYear()
|
var first_line_first_year = first_line_first_day.getFullYear()
|
||||||
first_target_day = new Date(first_line_first_year,first_line_first_month,first_line_first_date)
|
first_target_day = new Date(first_line_first_year,first_line_first_month,first_line_first_date)
|
||||||
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 >= firstDay.getDay()){
|
if(i >= offset){
|
||||||
if(today != 0 && last_inserted_date == today){
|
if(today != 0 && last_inserted_date == today){
|
||||||
td.addClass("w-calendar-today");
|
td.addClass("w-calendar-today");
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,21 +5,20 @@ $(function() {
|
||||||
$.pageslide.loadComplete(function(pageslide, item) {
|
$.pageslide.loadComplete(function(pageslide, item) {
|
||||||
$('.filter-item').removeClass("active");
|
$('.filter-item').removeClass("active");
|
||||||
item.closest('li').addClass('active');
|
item.closest('li').addClass('active');
|
||||||
|
$('.color-picker').miniColors("destroy");
|
||||||
|
setForm(item.data('form'));
|
||||||
if(item.data('id') == 'new') {
|
if(item.data('id') == 'new') {
|
||||||
resetForm();
|
|
||||||
pageslide.find('form').attr('method', 'post');
|
pageslide.find('form').attr('method', 'post');
|
||||||
$("#update_patch").remove();
|
$("#update_patch").remove();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$('.color-picker').miniColors("destroy");
|
|
||||||
setForm(item.data('form'));
|
|
||||||
pageslide.find('form').attr("action",item.data("href"));
|
pageslide.find('form').attr("action",item.data("href"));
|
||||||
if($("#update_patch").length == 0){
|
if($("#update_patch").length == 0){
|
||||||
pageslide.find("form").append("<input type='hidden' id='update_patch' value='patch' name='_method' />");
|
pageslide.find("form").append("<input type='hidden' id='update_patch' value='patch' name='_method' />");
|
||||||
}
|
}
|
||||||
pageslide.find('input[type="checkbox"]').prop( 'checked', item.data('disable') );
|
pageslide.find('input[type="checkbox"]').prop( 'checked', item.data('disable') );
|
||||||
|
}
|
||||||
$('.color-picker').miniColors();
|
$('.color-picker').miniColors();
|
||||||
$('.miniColors-trigger').addClass('btn');
|
$('.miniColors-trigger').addClass('btn');
|
||||||
}
|
|
||||||
});
|
});
|
||||||
})
|
})
|
|
@ -49,8 +49,8 @@ class Admin::CalendarsController < OrbitAdminController
|
||||||
end
|
end
|
||||||
|
|
||||||
def agenda
|
def agenda
|
||||||
agenda_start = Time.at(params[:unix_start].to_i).to_s
|
agenda_start = Time.at(params[:unix_start].to_i).utc
|
||||||
agenda_end = Time.at(params[:unix_end].to_i).to_s
|
agenda_end = Time.at(params[:unix_end].to_i).utc
|
||||||
@events = Event.agenda_events(agenda_start,agenda_end)
|
@events = Event.agenda_events(agenda_start,agenda_end)
|
||||||
# re = Event.recurring_event(Time.at(params[:unix_start].to_i), Time.at(params[:unix_end].to_i))
|
# re = Event.recurring_event(Time.at(params[:unix_start].to_i), Time.at(params[:unix_end].to_i))
|
||||||
# @events = @events.inject(re, :<<)
|
# @events = @events.inject(re, :<<)
|
||||||
|
|
|
@ -10,7 +10,7 @@ class CalendarsController < ApplicationController
|
||||||
{
|
{
|
||||||
"modes_info" => @calendar_setting.get_modes_info.map.with_index{|(trans, mode),i| {trans: trans, mode: mode, active_class: (i ==
|
"modes_info" => @calendar_setting.get_modes_info.map.with_index{|(trans, mode),i| {trans: trans, mode: mode, active_class: (i ==
|
||||||
2 ? 'active' : '')}},
|
2 ? 'active' : '')}},
|
||||||
"week_title" => @calendar_setting.week_title.map{|t| {'week_title'=> t}},
|
"week_title" => @calendar_setting.week_title.map{|t| {'week_title'=> t}}.rotate(@calendar_setting.sunday_first ? 0 : 1),
|
||||||
"extras" => {
|
"extras" => {
|
||||||
"page_id" => OrbitHelper.params[:page_id],
|
"page_id" => OrbitHelper.params[:page_id],
|
||||||
'widget_title' => page.name,
|
'widget_title' => page.name,
|
||||||
|
@ -43,7 +43,7 @@ class CalendarsController < ApplicationController
|
||||||
{
|
{
|
||||||
"modes_info" => @calendar_setting.get_modes_info.map.with_index{|(trans, mode),i| {trans: trans, mode: mode, active_class: (i ==
|
"modes_info" => @calendar_setting.get_modes_info.map.with_index{|(trans, mode),i| {trans: trans, mode: mode, active_class: (i ==
|
||||||
2 ? 'active' : '')}},
|
2 ? 'active' : '')}},
|
||||||
"week_title" => @calendar_setting.week_title.map{|t| {'week_title'=> t}},
|
"week_title" => @calendar_setting.week_title.map{|t| {'week_title'=> t}}.rotate(@calendar_setting.sunday_first ? 0 : 1),
|
||||||
"extras" => {
|
"extras" => {
|
||||||
"subpart-id" => part.id.to_s,
|
"subpart-id" => part.id.to_s,
|
||||||
"more_url" => OrbitHelper.widget_more_url,
|
"more_url" => OrbitHelper.widget_more_url,
|
||||||
|
@ -94,8 +94,8 @@ class CalendarsController < ApplicationController
|
||||||
calendar_types = []
|
calendar_types = []
|
||||||
end
|
end
|
||||||
if params[:unix_start].present? && params[:unix_end].present?
|
if params[:unix_start].present? && params[:unix_end].present?
|
||||||
agenda_start = Time.at(params[:unix_start].to_i).utc.to_s
|
agenda_start = Time.at(params[:unix_start].to_i).utc
|
||||||
agenda_end = Time.at(params[:unix_end].to_i).utc.to_s
|
agenda_end = Time.at(params[:unix_end].to_i).utc
|
||||||
event = Event.where("title_translations.#{locale}".to_sym.ne=>"")
|
event = Event.where("title_translations.#{locale}".to_sym.ne=>"")
|
||||||
events = event.with_categories(calendar_types).agenda_events(agenda_start,agenda_end)
|
events = event.with_categories(calendar_types).agenda_events(agenda_start,agenda_end)
|
||||||
end
|
end
|
||||||
|
@ -115,8 +115,8 @@ class CalendarsController < ApplicationController
|
||||||
calendar_types = []
|
calendar_types = []
|
||||||
end
|
end
|
||||||
if params[:unix_start].present? && params[:unix_end].present?
|
if params[:unix_start].present? && params[:unix_end].present?
|
||||||
agenda_start = Time.at(params[:unix_start].to_i).utc.to_s
|
agenda_start = Time.at(params[:unix_start].to_i).utc
|
||||||
agenda_end = Time.at(params[:unix_end].to_i).utc.to_s
|
agenda_end = Time.at(params[:unix_end].to_i).utc
|
||||||
event = Event.where("title_translations.#{locale}".to_sym.ne=>"")
|
event = Event.where("title_translations.#{locale}".to_sym.ne=>"")
|
||||||
events = event.with_categories(calendar_types).agenda_events(agenda_start,agenda_end)
|
events = event.with_categories(calendar_types).agenda_events(agenda_start,agenda_end)
|
||||||
end
|
end
|
||||||
|
|
|
@ -17,6 +17,7 @@ class Event
|
||||||
field :recurring, type: Boolean, default: false
|
field :recurring, type: Boolean, default: false
|
||||||
field :frequency
|
field :frequency
|
||||||
field :period
|
field :period
|
||||||
|
field :weekdays, type: Array, default: []
|
||||||
field :recurring_end_date, type: DateTime
|
field :recurring_end_date, type: DateTime
|
||||||
field :create_user_id
|
field :create_user_id
|
||||||
field :update_user_id
|
field :update_user_id
|
||||||
|
@ -24,6 +25,7 @@ class Event
|
||||||
field :model_cat
|
field :model_cat
|
||||||
field :model_page_id
|
field :model_page_id
|
||||||
field :model_tags, type: Array, default: []
|
field :model_tags, type: Array, default: []
|
||||||
|
field :is_weekdays, type: Boolean, default: false
|
||||||
belongs_to :calendar_type
|
belongs_to :calendar_type
|
||||||
field :url
|
field :url
|
||||||
field :url_translations, type: Hash, default: {}
|
field :url_translations, type: Hash, default: {}
|
||||||
|
@ -64,6 +66,11 @@ class Event
|
||||||
self['title'] = self.title
|
self['title'] = self.title
|
||||||
self['note'] = self.note
|
self['note'] = self.note
|
||||||
self['url'] = self.url
|
self['url'] = self.url
|
||||||
|
if self.is_weekdays
|
||||||
|
self.weekdays = (1..5).to_a #平日
|
||||||
|
else
|
||||||
|
self.weekdays = self.weekdays.map{|s| s.to_i}.sort
|
||||||
|
end
|
||||||
end
|
end
|
||||||
########################################
|
########################################
|
||||||
validates_presence_of :title, :message => "Please fill the title of the Event", :if => lambda { self['title_translations'].blank? }
|
validates_presence_of :title, :message => "Please fill the title of the Event", :if => lambda { self['title_translations'].blank? }
|
||||||
|
@ -158,6 +165,7 @@ class Event
|
||||||
is_year = false
|
is_year = false
|
||||||
days = 1
|
days = 1
|
||||||
interval = nil
|
interval = nil
|
||||||
|
weekdays = nil
|
||||||
if re.period == 'Daily'
|
if re.period == 'Daily'
|
||||||
period_str = 'day'
|
period_str = 'day'
|
||||||
interval = 1.day
|
interval = 1.day
|
||||||
|
@ -165,6 +173,8 @@ class Event
|
||||||
period_str = 'week'
|
period_str = 'week'
|
||||||
days = 7
|
days = 7
|
||||||
interval = 1.week
|
interval = 1.week
|
||||||
|
weekdays = re.weekdays
|
||||||
|
weekdays = nil if weekdays.blank?
|
||||||
elsif re.period == 'Monthly'
|
elsif re.period == 'Monthly'
|
||||||
period_str = 'month'
|
period_str = 'month'
|
||||||
is_month = true
|
is_month = true
|
||||||
|
@ -195,13 +205,32 @@ class Event
|
||||||
add_interval += (freq - rest)
|
add_interval += (freq - rest)
|
||||||
end
|
end
|
||||||
add_interval = add_interval.send(period_str)
|
add_interval = add_interval.send(period_str)
|
||||||
|
need_check_start = false
|
||||||
|
if weekdays
|
||||||
|
add_interval -= @start_date.wday.day
|
||||||
|
need_check_start = true
|
||||||
|
end
|
||||||
|
start_date = [start_date, @start_date].max
|
||||||
@start_date += add_interval
|
@start_date += add_interval
|
||||||
@end_date += add_interval
|
@end_date += add_interval
|
||||||
new_end_date = has_recurring_end_date ? [re.recurring_end_date,end_date].min : end_date
|
new_end_date = has_recurring_end_date ? [re.recurring_end_date,end_date].min : end_date
|
||||||
while @start_date <= new_end_date do
|
while @start_date <= new_end_date do
|
||||||
if @start_date >= start_date && @start_date != org_start
|
if weekdays
|
||||||
|
weekdays.each do |w|
|
||||||
|
new_start = (@start_date + w.day)
|
||||||
|
if need_check_start && new_start < start_date
|
||||||
|
next
|
||||||
|
end
|
||||||
|
if new_start != org_start
|
||||||
|
@recurring << data.merge({:start => new_start.to_json.gsub('"',''), :end => (@end_date + w.day).to_json.gsub('"','')})
|
||||||
|
end
|
||||||
|
end
|
||||||
|
need_check_start = false
|
||||||
|
else
|
||||||
|
if @start_date != org_start
|
||||||
@recurring << data.merge({:start => @start_date.to_json.gsub('"',''), :end => @end_date.to_json.gsub('"','')})
|
@recurring << data.merge({:start => @start_date.to_json.gsub('"',''), :end => @end_date.to_json.gsub('"','')})
|
||||||
end
|
end
|
||||||
|
end
|
||||||
@start_date += interval
|
@start_date += interval
|
||||||
@end_date += interval
|
@end_date += interval
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<%= label_tag("color", t("calendar.color")) %>
|
<%= label_tag("color", t("calendar.color")) %>
|
||||||
<div class="input-append">
|
<div class="input-append">
|
||||||
<%= f.text_field :color, id: "color", :class => "color-picker miniColors input-small", :size => "7", :maxlength => "7", :autocomplete=>"off",:value=>"9100FF" %>
|
<%= text_field_tag "#{f.object_name}[color]", f.object.color || "#9100FF", id: "color", :class => "color-picker miniColors input-small", :size => "7", :maxlength => "7", :autocomplete=>"off",:value=>"#9100FF" %>
|
||||||
</div>
|
</div>
|
||||||
<%= f.fields_for :title_translations do |f| %>
|
<%= f.fields_for :title_translations do |f| %>
|
||||||
<% @site_valid_locales.each do |locale| %>
|
<% @site_valid_locales.each do |locale| %>
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
|
|
||||||
<div class="bottomnav clearfix">
|
<div class="bottomnav clearfix">
|
||||||
<div class="action pull-right">
|
<div class="action pull-right">
|
||||||
<a href="#" class="btn btn-primary open-slide" data-id="new" onclick="return false;">
|
<a href="#" class="btn btn-primary open-slide" data-id="new" data-title="<%=t(:new_category)%>" data-form="<%=@calendar_type.title_translations.merge(color: "#9100FF").to_json%>" onclick="return false;">
|
||||||
<i class="icons-plus"></i>Add
|
<i class="icons-plus"></i>Add
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
<div class="row-fluid">
|
<div class="row-fluid">
|
||||||
<div class="span2">
|
<div class="span2">
|
||||||
<%= label_tag("color", t("calendar.color")) %>
|
<%= label_tag("color", t("calendar.color")) %>
|
||||||
<%= f.text_field :color, :class => "color-picker miniColors span5", :size => "7", :maxlength => "7", :autocomplete=>"off",:value=>"9100FF" %>
|
<%= text_field_tag "#{f.object_name}[color]", "#9100FF", :id=>"color", :class=>"color-picker miniColors span5", :size=>"7", :maxlength=>"7", :autocomplete=>"off" %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
@ -124,7 +124,7 @@
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<% data_format = @event.all_day ? 'yyyy/MM/dd' : 'yyyy/MM/dd hh:mm' %>
|
<% data_format = @all_day ? 'yyyy/MM/dd' : 'yyyy/MM/dd hh:mm' %>
|
||||||
<div class="control-group">
|
<div class="control-group">
|
||||||
<%= f.label t("start_date"), :class=>"control-label" %>
|
<%= f.label t("start_date"), :class=>"control-label" %>
|
||||||
<%#= f.datetime_select :start %>
|
<%#= f.datetime_select :start %>
|
||||||
|
@ -161,9 +161,9 @@
|
||||||
</div>
|
</div>
|
||||||
<div id="recurring_panel" <%= (@recurring ? '' : "style=display:none;") %> >
|
<div id="recurring_panel" <%= (@recurring ? '' : "style=display:none;") %> >
|
||||||
<div class="control-group">
|
<div class="control-group">
|
||||||
<%=f.label :period, t("calendar.repeats"),:class=>"control-label" %>
|
<%=f.label :period, t("calendar.repeats"),:class=>"control-label", :for => "event_period" %>
|
||||||
<div class="controls">
|
<div class="controls">
|
||||||
<%=f.select :period, Event::REPEATS.map{|v| [t("calendar.#{v.downcase}"),v]},{},:class=>"span5" %>
|
<%=f.select :period, Event::REPEATS.map{|v| [t("calendar.#{v.downcase}"),v]},{},:class=>"span5",:id => "event_period" %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="control-group">
|
<div class="control-group">
|
||||||
|
@ -172,6 +172,31 @@
|
||||||
<%=f.select :frequency, (1..30).to_a,{},:class=>"span2" %>
|
<%=f.select :frequency, (1..30).to_a,{},:class=>"span2" %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div id="Weekly_panel" class="<%= 'hide' if f.object.period != 'Weekly' %>">
|
||||||
|
<%=f.label :is_weekdays, t("calendar.type") ,:class=>"control-label", :for => "event_is_weekdays" %>
|
||||||
|
<div class="controls">
|
||||||
|
<%=f.select :is_weekdays, options_for_select(['custom', 'weekdays'].map.with_index{|v, i| [t("calendar.#{v}"), i.to_s]}, f.object.is_weekdays ? '1' : '0'),{},:class=>"span5",:id=>"event_is_weekdays" %>
|
||||||
|
<div id="Weekly_custom_panel" class="<%= 'hide' if f.object.is_weekdays %>">
|
||||||
|
<%
|
||||||
|
weekdays = f.object.weekdays
|
||||||
|
if f.object.new_record? && f.object.start
|
||||||
|
weekdays = [f.object.start.wday]
|
||||||
|
end
|
||||||
|
tmp_html = []
|
||||||
|
%>
|
||||||
|
<% (0...7).each do |i| %>
|
||||||
|
<% tmp = f.check_box_tag "#{f.object_name}[weekdays][]", i, weekdays.include?(i), {:class=>"weekdays-checkbox"}
|
||||||
|
tmp += t("calendar.short_day.#{i}")
|
||||||
|
tmp_html << tmp
|
||||||
|
%>
|
||||||
|
<% end %>
|
||||||
|
<% unless (CalendarSetting.first.sunday_first rescue false)
|
||||||
|
tmp_html.rotate!(1)
|
||||||
|
end %>
|
||||||
|
<%= tmp_html.join("\n").html_safe %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div class="control-group">
|
<div class="control-group">
|
||||||
<%= f.label t("calendar.recurring_end_date"), :class=>"control-label" %>
|
<%= f.label t("calendar.recurring_end_date"), :class=>"control-label" %>
|
||||||
<div class="controls">
|
<div class="controls">
|
||||||
|
@ -294,5 +319,25 @@
|
||||||
$(this).html(($('<div></div>').append(e.originalEvent.clipboardData.getData('text/plain')).text()));
|
$(this).html(($('<div></div>').append(e.originalEvent.clipboardData.getData('text/plain')).text()));
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
});
|
});
|
||||||
|
$("#event_is_weekdays").change(function(){
|
||||||
|
if($(this).val() == "0"){
|
||||||
|
$("#Weekly_custom_panel").removeClass('hide');
|
||||||
|
}else{
|
||||||
|
$("#Weekly_custom_panel").addClass('hide');
|
||||||
|
}
|
||||||
|
})
|
||||||
|
$("#event_period").change(function(){
|
||||||
|
if($(this).val() == "Weekly"){
|
||||||
|
$("#Weekly_panel").removeClass('hide');
|
||||||
|
}else{
|
||||||
|
$("#Weekly_panel").addClass('hide');
|
||||||
|
}
|
||||||
|
})
|
||||||
|
$("#event_start").change(function(){
|
||||||
|
var _this = $(this);
|
||||||
|
var date = $.ui_datepicker.parseDate(_this.data('datepicker').settings.dateFormat, _this.val());
|
||||||
|
$(".weekdays-checkbox").prop("checked", false);
|
||||||
|
$(".weekdays-checkbox").eq(date.getDay()).prop("checked", true);
|
||||||
|
})
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
|
@ -1,5 +1,8 @@
|
||||||
en:
|
en:
|
||||||
calendar:
|
calendar:
|
||||||
|
type: Type
|
||||||
|
custom: Custom
|
||||||
|
weekdays: Weekdays
|
||||||
recurring_end_date: "Recurring End Date"
|
recurring_end_date: "Recurring End Date"
|
||||||
"12_hour_clock": "12 hour clock"
|
"12_hour_clock": "12 hour clock"
|
||||||
"24_hour_clock": "24 hour clock"
|
"24_hour_clock": "24 hour clock"
|
||||||
|
@ -17,6 +20,14 @@ en:
|
||||||
month: "Month"
|
month: "Month"
|
||||||
agenda: "Agenda"
|
agenda: "Agenda"
|
||||||
day_of_the_week: "Day of the week"
|
day_of_the_week: "Day of the week"
|
||||||
|
short_day:
|
||||||
|
"0": "Sun"
|
||||||
|
"1": "Mon"
|
||||||
|
"2": "Tue"
|
||||||
|
"3": "Wed"
|
||||||
|
"4": "Thu"
|
||||||
|
"5": "Fri"
|
||||||
|
"6": "Sat"
|
||||||
day:
|
day:
|
||||||
"0": "Sunday"
|
"0": "Sunday"
|
||||||
"1": "Monday"
|
"1": "Monday"
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
zh_tw:
|
zh_tw:
|
||||||
calendar:
|
calendar:
|
||||||
|
type: 類型
|
||||||
|
custom: 自訂
|
||||||
|
weekdays: 平日
|
||||||
recurring_end_date: "週期結束時間"
|
recurring_end_date: "週期結束時間"
|
||||||
"12_hour_clock": "12小時制"
|
"12_hour_clock": "12小時制"
|
||||||
"24_hour_clock": "24小時制"
|
"24_hour_clock": "24小時制"
|
||||||
|
@ -17,6 +20,14 @@ zh_tw:
|
||||||
month: "月曆"
|
month: "月曆"
|
||||||
agenda: "日程"
|
agenda: "日程"
|
||||||
day_of_the_week: "星期幾"
|
day_of_the_week: "星期幾"
|
||||||
|
short_day:
|
||||||
|
"0": "日"
|
||||||
|
"1": "一"
|
||||||
|
"2": "二"
|
||||||
|
"3": "三"
|
||||||
|
"4": "四"
|
||||||
|
"5": "五"
|
||||||
|
"6": "六"
|
||||||
day:
|
day:
|
||||||
"0": "週日"
|
"0": "週日"
|
||||||
"1": "週一"
|
"1": "週一"
|
||||||
|
|
|
@ -5,7 +5,7 @@ Rails.application.routes.draw do
|
||||||
Thread.new do
|
Thread.new 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?('cf1'))
|
need_update = !update_flag || !(s.tmp_flags.include?('cf2'))
|
||||||
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
|
||||||
|
@ -21,9 +21,14 @@ Rails.application.routes.draw do
|
||||||
e.url_translations = locales.map{|l| [l.to_s, e[:url].to_s]}.to_h
|
e.url_translations = locales.map{|l| [l.to_s, e[:url].to_s]}.to_h
|
||||||
e.save
|
e.save
|
||||||
end
|
end
|
||||||
|
Event.where(:period=>'Weekly',:weekdays=>nil).each do |e|
|
||||||
|
wday = e.start.wday rescue nil
|
||||||
|
e.weekdays = [wday]
|
||||||
|
e.save
|
||||||
|
end
|
||||||
if update_flag
|
if update_flag
|
||||||
s = Site.first
|
s = Site.first
|
||||||
s.tmp_flags << 'cf1'
|
s.tmp_flags << 'cf2'
|
||||||
s.save
|
s.save
|
||||||
end
|
end
|
||||||
puts "Calendar fix!"
|
puts "Calendar fix!"
|
||||||
|
|
Loading…
Reference in New Issue