Add calendar setting.
Change translations. Fix known bug.
This commit is contained in:
parent
906b0f9718
commit
a2f4c13b61
|
@ -1,4 +1,53 @@
|
|||
window.auto_close_popup = false;
|
||||
if(window.calendar_variable == undefined){
|
||||
window.calendar_variable = {};
|
||||
window.calendar_variable.is_chinese = ( I18n && I18n.locale.indexOf('zh') != -1 );
|
||||
window.calendar_variable.date_type = 0;
|
||||
}else{
|
||||
if(window.calendar_variable.date_type == 1){
|
||||
window.calendar_variable.is_chinese = false;
|
||||
}else{
|
||||
window.calendar_variable.is_chinese = ( I18n && I18n.locale.indexOf('zh') != -1 );
|
||||
}
|
||||
}
|
||||
if(!(window.calendar_variable.dayNames)){
|
||||
if(window.calendar_variable.is_chinese){
|
||||
window.calendar_variable.dayNames = ['週日', '週一', '週二', '週三','週四', '週五', '週六'];
|
||||
window.calendar_variable.dayNamesShort = ['日', '一', '二', '三','四', '五', '六'];
|
||||
}else{
|
||||
window.calendar_variable.dayNames = ['Sunday', 'Monday', 'Tuesday', 'Wednesday','Thursday', 'Friday', 'Saturday'];
|
||||
window.calendar_variable.dayNamesShort = ['Sun', 'Mon', 'Tue', 'Wed','Thu', 'Fri', 'Sat'];
|
||||
}
|
||||
}
|
||||
if(window.calendar_variable.is_chinese){
|
||||
window.calendar_variable.months = [];
|
||||
for(var i=0;i<12;i++){
|
||||
window.calendar_variable.months.push((i+1)+"月");
|
||||
}
|
||||
}else{
|
||||
window.calendar_variable.months = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];
|
||||
}
|
||||
if(window.calendar_variable.date_type == 2){
|
||||
window.calendar_variable.datetime_format = calendar_variable.is_chinese ? 'yy/MM/dd b h:m' : 'dd/MM/yy h:m b';
|
||||
window.calendar_variable.month_year_format = calendar_variable.is_chinese ? 'yy/MM' : 'MM/yy';
|
||||
window.calendar_variable.date_format = calendar_variable.is_chinese ? 'yy/MM/dd' : 'dd/MM/yy';
|
||||
window.calendar_variable.date_format_with_short_month = calendar_variable.is_chinese ? 'yy/MM/dd' : 'dd/MM/yy';
|
||||
window.calendar_variable.date_format_with_week = calendar_variable.is_chinese ? 'yy/MM/dd (W)' : 'W, MM/dd/yy';
|
||||
window.calendar_variable.short_date = (calendar_variable.is_chinese ? "MM/dd (W)" : "W, dd/MM");
|
||||
window.calendar_variable.short_date_time = (calendar_variable.is_chinese ? "MM/dd (W) b h:m" : "W, dd/MM h:m b");
|
||||
}else{
|
||||
window.calendar_variable.datetime_format = calendar_variable.is_chinese ? 'y MMM d b h:m' : 'd MMM, y h:m b';
|
||||
window.calendar_variable.month_year_format = calendar_variable.is_chinese ? 'y MMM' : 'MMM y';
|
||||
window.calendar_variable.date_format = calendar_variable.is_chinese ? 'y MMM d' : 'd MMM, y';
|
||||
window.calendar_variable.date_format_with_short_month = calendar_variable.is_chinese ? 'y M d' : 'd M, y';
|
||||
window.calendar_variable.date_format_with_week = calendar_variable.is_chinese ? 'y MMM d (W)' : 'W, MMM d, y';
|
||||
window.calendar_variable.short_date = (calendar_variable.is_chinese ? "MMM d (W)" : "W, d MMM");
|
||||
window.calendar_variable.short_date_time = (calendar_variable.is_chinese ? "MMM d (W) b h:m" : "W, d MMM h:m b");
|
||||
}
|
||||
window.calendar_variable.short_date_numeric = (calendar_variable.is_chinese ? "MM/dd (w)" : "w MM/dd");
|
||||
window.time_format = (calendar_variable.is_chinese ? "b h:m" : "h:m b");
|
||||
window.calendar_variable.std_date_format = 'y-MM-d';
|
||||
window.calendar_variable.short_day = (calendar_variable.is_chinese ? "d (W)" : "W d");
|
||||
$.fn.fullCalendar = function(args){
|
||||
var self = this[0]
|
||||
if(!self.calendar_args)
|
||||
|
@ -60,41 +109,40 @@ FullCalendar.Calendar.prototype.isAnOverlapEvent = function(eventStartDay, event
|
|||
}
|
||||
return false;
|
||||
}
|
||||
window.is_chinese = ( I18n && I18n.locale.indexOf('zh') != -1 );
|
||||
window.datetime_format = is_chinese ? 'y M d h:m b' : 'd M, y h:m b';
|
||||
window.date_format = is_chinese ? 'y M d' : 'd M, y';
|
||||
window.datetime_format = window.date_format;
|
||||
window.time_format = "h:m b";
|
||||
window.std_date_format = 'y-MM-d';
|
||||
window.short_day = (is_chinese ? "d (w)" : "w d");
|
||||
window.short_date = (is_chinese ? "M d (w)" : "w d, M");
|
||||
window.short_date_time = (is_chinese ? "M d (w) h:m b" : "w d, M h:m b");
|
||||
window.getDateString = function(date, format,is_chinese) {
|
||||
var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
|
||||
var week_days = ['Sun','Mon','Tue','Wed','Thu','Fri','Sat'];
|
||||
if(is_chinese){
|
||||
months = [];
|
||||
for(var i=0;i<12;i++){
|
||||
months.push((i+1)+"月");
|
||||
}
|
||||
week_days = ["週日","週一","週二","週三","週四","週五","週六"]
|
||||
}
|
||||
|
||||
window.getDateString = function(date, format, is_chinese) {
|
||||
var months = calendar_variable.months;
|
||||
var week_days = calendar_variable.dayNames;
|
||||
var getPaddedComp = function(comp) {
|
||||
return ((parseInt(comp) < 10) ? ('0' + comp) : comp)
|
||||
},
|
||||
formattedDate = format,
|
||||
y = date.getFullYear(),
|
||||
m = date.getMonth(),
|
||||
d = date.getDate(),
|
||||
H = date.getHours(),
|
||||
M = date.getMinutes(),
|
||||
s = date.getSeconds(),
|
||||
S = date.getMilliseconds(),
|
||||
month_name = months[m],
|
||||
am_trans = (calendar_variable.is_chinese ? '上午' : 'AM'),
|
||||
pm_trans = (calendar_variable.is_chinese ? '下午' : 'PM'),
|
||||
o = {
|
||||
"y+": date.getFullYear() + (is_chinese ? "年" : ""), // year
|
||||
"MM+": getPaddedComp(date.getMonth() + 1), //raw month
|
||||
"M+": months[date.getMonth()], //month
|
||||
"d+": (is_chinese ? (date.getDate() + "日") : getPaddedComp(date.getDate())), //day
|
||||
"w+": week_days[date.getDay()], //weekday
|
||||
"h+": getPaddedComp((date.getHours() > 12) ? date.getHours() % 12 : date.getHours()), //hour
|
||||
"H+": getPaddedComp(date.getHours()), //hour
|
||||
"m+": getPaddedComp(date.getMinutes()), //minute
|
||||
"s+": getPaddedComp(date.getSeconds()), //second
|
||||
"S+": getPaddedComp(date.getMilliseconds()), //millisecond,
|
||||
"b+": (date.getHours() >= 12) ? 'PM' : 'AM'
|
||||
"yy+": y, //raw year
|
||||
"y+": y + (calendar_variable.is_chinese ? "年" : ""), // year
|
||||
"MMM+": month_name, //month
|
||||
"MM+": getPaddedComp(m + 1), //raw month
|
||||
"M+": month_name.substring(0,3), //month
|
||||
"dd+": getPaddedComp(d), //raw day
|
||||
"d+": (calendar_variable.is_chinese ? (d + "日") : getPaddedComp(d)), //day
|
||||
"W+": week_days[date.getDay()], //weekday
|
||||
"w+": (calendar_variable.is_chinese ? week_days[date.getDay()].substr(-1, 1) : week_days[date.getDay()].substr(0, 3)), //weekday
|
||||
"h+": getPaddedComp((H > 12) ? H % 12 : H), //hour
|
||||
"H+": getPaddedComp(H), //hour
|
||||
"m+": getPaddedComp(M), //minute
|
||||
"s+": getPaddedComp(s), //second
|
||||
"S+": getPaddedComp(S), //millisecond,
|
||||
"b+": (H >= 12) ? pm_trans : am_trans
|
||||
};
|
||||
|
||||
for (var k in o) {
|
||||
|
@ -288,7 +336,7 @@ var Calendar = function(dom){
|
|||
});
|
||||
},
|
||||
// events: 'https://fullcalendar.io/demo-events.json',
|
||||
headerToolbar: false,
|
||||
headerToolbar: false,
|
||||
fixedWeekCount: false,
|
||||
initialView: dview,
|
||||
loading: function(bool) {
|
||||
|
@ -306,12 +354,35 @@ var Calendar = function(dom){
|
|||
originalEvent = eventClickInfo.jsEvent,
|
||||
view = eventClickInfo.view,
|
||||
el = $(eventClickInfo.el);
|
||||
c.event_create_space.html("").hide();
|
||||
c.dialog.dismiss();
|
||||
c.dialog.inflate(calEvent);
|
||||
c.dialog.show({"x": originalEvent.clientX,"y": originalEvent.clientY});
|
||||
if(el.hasClass("reserve_btn")){
|
||||
window.calEvent = calEvent;
|
||||
var start_time = calEvent.event.start;
|
||||
var date_str = window.getDateString(start_time,std_date_format);
|
||||
c.dialog.hide();
|
||||
var allow_times = calEvent.event._def.extendedProps.allow_times;
|
||||
window.pick_hire_date(date_str,allow_times);
|
||||
}else{
|
||||
c.event_create_space.html("").hide();
|
||||
c.dialog.dismiss();
|
||||
c.dialog.inflate(calEvent);
|
||||
c.dialog.show({"x": originalEvent.clientX,"y": originalEvent.clientY});
|
||||
}
|
||||
},
|
||||
select : function(selectionInfo){
|
||||
dateClick: function(ev) {
|
||||
var calendar = this;
|
||||
var calendar_dom = $(this.el);
|
||||
if(c.calendar_dom.hasClass("active_picker")){
|
||||
var date = ev.date,
|
||||
date_str = getDateString(date,date_time_str_format),
|
||||
day_element = ev.dayEl,
|
||||
jsEvent = ev.jsEvent;
|
||||
var time_str = date_str.split(" ")[1];
|
||||
var date_str = date_str.split(" ")[0];
|
||||
calendar_dom.trigger("init_time",[time_str]);
|
||||
calendar_dom.trigger("select_time",[date_str]);
|
||||
}
|
||||
},
|
||||
select : function(selectionInfo){
|
||||
var jsEvent = selectionInfo.jsEvent,
|
||||
view = selectionInfo.view;
|
||||
var start = selectionInfo.start,
|
||||
|
@ -338,10 +409,37 @@ var Calendar = function(dom){
|
|||
})
|
||||
},
|
||||
views: {
|
||||
dayGridMonth: {
|
||||
dayMaxEvents: false
|
||||
}
|
||||
}
|
||||
timeGridDay: {
|
||||
titleFormat: function(date_info){
|
||||
var date = date_info.date.marker;
|
||||
return getDateString(date, calendar_variable.date_format_with_week);
|
||||
},
|
||||
dayHeaderFormat: function(date_info){
|
||||
return window.calendar_variable.dayNames[date_info.date.marker.getDay()];
|
||||
}
|
||||
},
|
||||
timeGridWeek: {
|
||||
titleFormat: function(date_info){
|
||||
var start = date_info.start.marker,
|
||||
end = date_info.end.marker;
|
||||
return getDateString(start, calendar_variable.date_format) + ' ~ ' + getDateString(end, calendar_variable.date_format);
|
||||
},
|
||||
dayHeaderFormat: function(date_info){
|
||||
return getDateString(date_info.date.marker, calendar_variable.short_date_numeric);
|
||||
}
|
||||
},
|
||||
dayGridMonth: {
|
||||
dayMaxEvents: false,
|
||||
titleFormat: function(date_info){
|
||||
var date = date_info.date.marker;
|
||||
return getDateString(date, calendar_variable.month_year_format);
|
||||
},
|
||||
dayHeaderFormat: function(date_info){
|
||||
return window.calendar_variable.dayNamesShort[date_info.date.marker.getDay()];
|
||||
}
|
||||
}
|
||||
},
|
||||
firstDay: (window.calendar_variable.sunday_first == true ? 0 : 1)
|
||||
});
|
||||
c.create_event_btn.click(function(){
|
||||
$.ajax({
|
||||
|
@ -356,14 +454,17 @@ var Calendar = function(dom){
|
|||
c.nextBtn.click(function(){
|
||||
c.dialog.dismiss();
|
||||
c.calendar_dom.calendar.next();
|
||||
c.title.text(c.calendar_dom.calendar.currentData.viewTitle);
|
||||
});
|
||||
c.prevBtn.click(function(){
|
||||
c.dialog.dismiss();
|
||||
c.calendar_dom.calendar.prev();
|
||||
c.title.text(c.calendar_dom.calendar.currentData.viewTitle);
|
||||
});
|
||||
c.todayBtn.click(function(){
|
||||
c.dialog.dismiss();
|
||||
c.calendar_dom.calendar.today();
|
||||
c.title.text(c.calendar_dom.calendar.currentData.viewTitle);
|
||||
});
|
||||
c.modeBtns.click(function(){
|
||||
c.dialog.dismiss();
|
||||
|
@ -404,13 +505,8 @@ var Calendar = function(dom){
|
|||
c.calendar_dom.calendar.refetchEvents();
|
||||
loadeventsonviewchange = false;
|
||||
}
|
||||
if(c.calendar_dom.calendar.currentData){
|
||||
var viewTitle = c.calendar_dom.calendar.currentData.viewTitle;
|
||||
if(view == "timeGridDay" && $('.fc-col-header-cell-cushion ').text() != "")
|
||||
viewTitle = $('.fc-col-header-cell-cushion ').text() + ', ' + viewTitle;
|
||||
$('#current_title').html(viewTitle);
|
||||
}
|
||||
c.calendar_dom.calendar.render(); //Rerender to fix layout
|
||||
c.title.text(c.calendar_dom.calendar.currentData.viewTitle);
|
||||
// c.calendar_dom.calendar.rerenderEvents(); //Rerender to fix layout
|
||||
};
|
||||
if(c.currentView == "agenda"){toggleViews("agenda");loadeventsonviewchange = true;}
|
||||
};
|
||||
|
@ -464,11 +560,8 @@ var EventDialog = function(calendar,event){
|
|||
_event.allDay = _event.event.allDay;
|
||||
_event._start = _event.event.start;
|
||||
_event._end = (_event.event.end ? _event.event.end : _event.event.start);
|
||||
// var start_date = getDateString(_event._start,date_format);
|
||||
// var end_date = getDateString(_event._end,date_format);
|
||||
if(_event._end - _event._start > 86400 * 1000){
|
||||
_event.allDay = true;
|
||||
}
|
||||
// var start_date = getDateString(_event._start,calendar_variable.date_format);
|
||||
// var end_date = getDateString(_event._end,calendar_variable.date_format);
|
||||
_event.title = _event.event.title;
|
||||
var extendedProps = _event.event.extendedProps;
|
||||
Object.keys(extendedProps).forEach(function(k){
|
||||
|
@ -481,15 +574,15 @@ var EventDialog = function(calendar,event){
|
|||
end_time = "",
|
||||
time_string = null;
|
||||
if(_event.allDay) {
|
||||
start_time = getDateString(_event._start,datetime_format, is_chinese);
|
||||
start_time = getDateString(_event._start,calendar_variable.date_format_with_short_month);
|
||||
if(_event._end)
|
||||
end_time = getDateString(_event._end,datetime_format, is_chinese);
|
||||
end_time = getDateString(_event._end,calendar_variable.date_format_with_short_month);
|
||||
time_string = (_event._start === _event._end || !_event._end ? "<p class='start-date'><i class='icons-calendar' /></i>" + start_time + "</p>" : "<i class='icons-calendar' /></i>" + start_time + "<br><i class='icons-arrow-right-5' /></i>" + end_time + "");
|
||||
} else {
|
||||
start_time = getDateString(_event._start,date_format, is_chinese);
|
||||
end_time = getDateString(_event._end,date_format, is_chinese);
|
||||
var stime = getDateString(_event._start,time_format, is_chinese),
|
||||
etime = getDateString(_event._end,time_format, is_chinese),
|
||||
start_time = getDateString(_event._start,calendar_variable.date_format_with_short_month);
|
||||
end_time = getDateString(_event._end,calendar_variable.date_format_with_short_month);
|
||||
var stime = getDateString(_event._start,time_format),
|
||||
etime = getDateString(_event._end,time_format),
|
||||
same = (start_time == end_time);
|
||||
if( same ){
|
||||
time_string = "<p class='date'><i class='icons-calendar' /></i> " +
|
||||
|
@ -507,7 +600,7 @@ var EventDialog = function(calendar,event){
|
|||
template = '<div class="modal-content">' +
|
||||
'<div class="modal-header">' +
|
||||
'<button type="button" class="close event-close-btn" data-dismiss="modal" aria-hidden="true">×</button>' +
|
||||
'<h3>' + _event.title + '</h3>' +
|
||||
'<h3>' + (_event.url_linked=='' ? _event.title : ("<a href=\"" +_event.url_linked+"\">"+_event.title+"</a>")) + '</h3>' +
|
||||
'</div>' +
|
||||
'<div class="modal-body">' +
|
||||
'<div class="event_summary">' + time_string + '</br>' + _event.hiring_person_name + '</div>' + _event.note +
|
||||
|
@ -615,20 +708,16 @@ var AgendaView = function(calendar){
|
|||
var start_year = today.getFullYear();
|
||||
var end_month = ((start_month + minDifference) > 11 ? (start_month + minDifference) - 11 : start_month + minDifference);
|
||||
var end_year = ((start_month + minDifference) > 11 ? start_year+1 : start_year);
|
||||
var monthNames = ['January','February','March','April','May','June','July','August','September','October','November','December'];
|
||||
var monthNames = window.calendar_variable.months;
|
||||
var month_template = '<div class="col-md-4">' +
|
||||
'<h4></h4>' +
|
||||
'<div class="tiny_calendar">' +
|
||||
'<table class="table table-condensed table-bordered">' +
|
||||
'<tbody>' +
|
||||
'<tr>' +
|
||||
'<th class="week_title">Sun</th>' +
|
||||
'<th class="week_title">Mon</th>' +
|
||||
'<th class="week_title">Tue</th>' +
|
||||
'<th class="week_title">Wed</th>' +
|
||||
'<th class="week_title">Thu</th>' +
|
||||
'<th class="week_title">Fri</th>' +
|
||||
'<th class="week_title">Sat</th>' +
|
||||
calendar_variable.dayNamesShort.map(function(title){
|
||||
return '<th class="week_title">'+title+'</th>';
|
||||
}).join('') +
|
||||
'</tr>' +
|
||||
'</tbody>' +
|
||||
'</table>' +
|
||||
|
@ -639,10 +728,8 @@ var AgendaView = function(calendar){
|
|||
'<table class="table table-condensed table-bordered event_list">' +
|
||||
'<thead>' +
|
||||
'<tr>' +
|
||||
'<th>Date</th>' +
|
||||
'<th>Time</th>' +
|
||||
'<th>DateTime</th>' +
|
||||
'<th>Events</th>' +
|
||||
'<th>Borrower</th>' +
|
||||
'</tr>' +
|
||||
'</thead>' +
|
||||
'<tbody>' +
|
||||
|
@ -654,20 +741,18 @@ var AgendaView = function(calendar){
|
|||
'</div>';
|
||||
|
||||
var head_template = '<div>' +
|
||||
'<label>From</label>' +
|
||||
'<label>'+(window.calendar_variable.from ? window.calendar_variable.from : 'From')+'</label>' +
|
||||
'<input class="input-large" id="agenda_start" placeholder="YYYY/MM" type="text" value="'+start_year+'/'+('0'+(start_month+1)).substr(-2,2)+'" title="YYYY/MM" autocomplete="off">'+
|
||||
'<label>To</label>' +
|
||||
'<label>'+(window.calendar_variable.to ? window.calendar_variable.to : 'To')+'</label>' +
|
||||
'<input class="input-large" id="agenda_end" placeholder="YYYY/MM" type="text" value="'+end_year+'/'+('0'+(end_month+1)).substr(-2,2)+'" title="YYYY/MM" autocomplete="off">'+
|
||||
'<button id="show_events" class="btn btn-sm bt-filter btn-primary">Show Events</button>' +
|
||||
'</div>';
|
||||
|
||||
var event_template = '<tr>' +
|
||||
'<td />' +
|
||||
'<td class="event_time" />' +
|
||||
'<td class="event_datetime" />' +
|
||||
'<td>' +
|
||||
'<div class="event" />' +
|
||||
'</td>' +
|
||||
'<td class="Borrower">'+
|
||||
'</tr>';
|
||||
// var month_template = '<div class="span4"><h4></h4><div class="tiny_calendar"><table class="table"><tbody><tr><th class="week_title">Sun</th><th class="week_title">Mon</th><th class="week_title">Tue</th><th class="week_title">Wed</th><th class="week_title">Thu</th><th class="week_title">Fri</th><th class="week_title">Sat</th></tr></tbody></table></div></div>';
|
||||
|
||||
|
@ -762,8 +847,9 @@ var AgendaView = function(calendar){
|
|||
type : "get",
|
||||
url : url,
|
||||
dataType : "json",
|
||||
data : {"agenda_start":sd.toLocaleString(),"agenda_end":ed.toLocaleString(),"page_id" : _calendar.page_id,"start":usd,"end":ued},
|
||||
data : {"agenda_start":sd.toLocaleString(),"agenda_end":ed.toLocaleString(),"unix_start":usd,"unix_end":ued},
|
||||
success : function(data){
|
||||
console.log(data)
|
||||
$("#agenda_start,#agenda_end").datepicker({
|
||||
dateFormat: "yy/mm",
|
||||
onChangeMonthYear: function( year, month, inst ){
|
||||
|
@ -850,16 +936,21 @@ var AgendaView = function(calendar){
|
|||
var e_t = $(event_template),
|
||||
s = new Date(event.start),
|
||||
e = new Date(event.end),
|
||||
dateFormat = "",
|
||||
hiring_person_name = event.hiring_person_name;
|
||||
if(s.getDate() == e.getDate() && s.getMonth() == s.getMonth() && e.getFullYear() == e.getFullYear())
|
||||
dateFormat = getDateString(s, short_day,is_chinese);
|
||||
else
|
||||
dateFormat = getDateString(s,short_date,is_chinese) + ' - ' + getDateString(e,short_date,is_chinese);
|
||||
e_t.find("td:first").text(dateFormat);
|
||||
e_t.find("td.event_time").text((event.diff_day ? (getDateString(s, short_date_time,is_chinese)+"~"+getDateString(e, short_date_time, is_chinese)) : (getDateString(s, time_format)+"~"+getDateString(e, time_format))));
|
||||
datetimeFormat = "";
|
||||
if(s.getDate() == e.getDate() && s.getMonth() == s.getMonth() && e.getFullYear() == e.getFullYear()){
|
||||
datetimeFormat = getDateString(s, calendar_variable.short_day);
|
||||
if(!event.allDay){
|
||||
datetimeFormat += (' ' + getDateString(s,time_format) + ' - ' + getDateString(e,time_format));
|
||||
}
|
||||
}else{
|
||||
if(event.allDay){
|
||||
datetimeFormat = getDateString(s,calendar_variable.short_date) + ' - ' + getDateString(e,calendar_variable.short_date);
|
||||
}else{
|
||||
datetimeFormat = getDateString(s,calendar_variable.short_date_time) + ' - ' + getDateString(e,calendar_variable.short_date_time);
|
||||
}
|
||||
}
|
||||
e_t.find("td.event_datetime").text(datetimeFormat);
|
||||
e_t.find("div.event").html(event.title).css("color",event.color);
|
||||
e_t.find("td.Borrower").text(hiring_person_name);
|
||||
return e_t;
|
||||
}
|
||||
|
||||
|
@ -918,7 +1009,8 @@ var AgendaView = function(calendar){
|
|||
var last_inserted_date = 1;
|
||||
|
||||
var renderMonth = function(){
|
||||
var num_of_rows = getNumberOfRows(year,month)
|
||||
var num_of_rows = getNumberOfRows(year,month);
|
||||
var tbody = template.find("table.table tbody");
|
||||
for(var i = 0; i < num_of_rows; i++){
|
||||
var tr = null;
|
||||
if(i == 0)
|
||||
|
@ -931,9 +1023,9 @@ var AgendaView = function(calendar){
|
|||
if(tr == null){
|
||||
break;
|
||||
}
|
||||
template.find("table.table tbody").append(tr);
|
||||
template.find("h4").text(monthNames[firstDay.getMonth()] + " - " + firstDay.getFullYear());
|
||||
tbody.append(tr);
|
||||
}
|
||||
template.find("h4").text(getDateString(firstDay, calendar_variable.month_year_format));
|
||||
_this.monthDom.append(template);
|
||||
_this.monthDom.append(list_template);
|
||||
}
|
||||
|
|
|
@ -1,4 +1,53 @@
|
|||
window.auto_close_popup = false;
|
||||
if(window.calendar_variable == undefined){
|
||||
window.calendar_variable = {};
|
||||
window.calendar_variable.is_chinese = ( I18n && I18n.locale.indexOf('zh') != -1 );
|
||||
window.calendar_variable.date_type = 0;
|
||||
}else{
|
||||
if(window.calendar_variable.date_type == 1){
|
||||
window.calendar_variable.is_chinese = false;
|
||||
}else{
|
||||
window.calendar_variable.is_chinese = ( I18n && I18n.locale.indexOf('zh') != -1 );
|
||||
}
|
||||
}
|
||||
if(!(window.calendar_variable.dayNames)){
|
||||
if(window.calendar_variable.is_chinese){
|
||||
window.calendar_variable.dayNames = ['週日', '週一', '週二', '週三','週四', '週五', '週六'];
|
||||
window.calendar_variable.dayNamesShort = ['日', '一', '二', '三','四', '五', '六'];
|
||||
}else{
|
||||
window.calendar_variable.dayNames = ['Sunday', 'Monday', 'Tuesday', 'Wednesday','Thursday', 'Friday', 'Saturday'];
|
||||
window.calendar_variable.dayNamesShort = ['Sun', 'Mon', 'Tue', 'Wed','Thu', 'Fri', 'Sat'];
|
||||
}
|
||||
}
|
||||
if(window.calendar_variable.is_chinese){
|
||||
window.calendar_variable.months = [];
|
||||
for(var i=0;i<12;i++){
|
||||
window.calendar_variable.months.push((i+1)+"月");
|
||||
}
|
||||
}else{
|
||||
window.calendar_variable.months = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];
|
||||
}
|
||||
if(window.calendar_variable.date_type == 2){
|
||||
window.calendar_variable.datetime_format = calendar_variable.is_chinese ? 'yy/MM/dd b h:m' : 'dd/MM/yy h:m b';
|
||||
window.calendar_variable.month_year_format = calendar_variable.is_chinese ? 'yy/MM' : 'MM/yy';
|
||||
window.calendar_variable.date_format = calendar_variable.is_chinese ? 'yy/MM/dd' : 'dd/MM/yy';
|
||||
window.calendar_variable.date_format_with_short_month = calendar_variable.is_chinese ? 'yy/MM/dd' : 'dd/MM/yy';
|
||||
window.calendar_variable.date_format_with_week = calendar_variable.is_chinese ? 'yy/MM/dd (W)' : 'W, MM/dd/yy';
|
||||
window.calendar_variable.short_date = (calendar_variable.is_chinese ? "MM/dd (W)" : "W, dd/MM");
|
||||
window.calendar_variable.short_date_time = (calendar_variable.is_chinese ? "MM/dd (W) b h:m" : "W, dd/MM h:m b");
|
||||
}else{
|
||||
window.calendar_variable.datetime_format = calendar_variable.is_chinese ? 'y MMM d b h:m' : 'd MMM, y h:m b';
|
||||
window.calendar_variable.month_year_format = calendar_variable.is_chinese ? 'y MMM' : 'MMM y';
|
||||
window.calendar_variable.date_format = calendar_variable.is_chinese ? 'y MMM d' : 'd MMM, y';
|
||||
window.calendar_variable.date_format_with_short_month = calendar_variable.is_chinese ? 'y M d' : 'd M, y';
|
||||
window.calendar_variable.date_format_with_week = calendar_variable.is_chinese ? 'y MMM d (W)' : 'W, MMM d, y';
|
||||
window.calendar_variable.short_date = (calendar_variable.is_chinese ? "MMM d (W)" : "W, d MMM");
|
||||
window.calendar_variable.short_date_time = (calendar_variable.is_chinese ? "MMM d (W) b h:m" : "W, d MMM h:m b");
|
||||
}
|
||||
window.calendar_variable.short_date_numeric = (calendar_variable.is_chinese ? "MM/dd (w)" : "w MM/dd");
|
||||
window.time_format = (calendar_variable.is_chinese ? "b h:m" : "h:m b");
|
||||
window.calendar_variable.std_date_format = 'y-MM-d';
|
||||
window.calendar_variable.short_day = (calendar_variable.is_chinese ? "d (W)" : "W d");
|
||||
$.fn.fullCalendar = function(args){
|
||||
var self = this[0]
|
||||
if(!self.calendar_args)
|
||||
|
@ -44,65 +93,64 @@ FullCalendar.Calendar.prototype.isAnOverlapEvent = function(eventStartDay, event
|
|||
eventEndDay = new Date(eventEndDay);
|
||||
var events = this.get_all_events();
|
||||
for (var i = 0; i < events.length; i++) {
|
||||
var eventA = events[i];
|
||||
// start-time in between any of the events
|
||||
if (eventStartDay >= eventA.start && eventStartDay <= eventA.end) {
|
||||
return true;
|
||||
}
|
||||
//end-time in between any of the events
|
||||
if (eventEndDay >= eventA.start && eventEndDay <= eventA.end) {
|
||||
return true;
|
||||
}
|
||||
//any of the events in between/on the start-time and end-time
|
||||
if (eventStartDay <= eventA.start && eventEndDay >= eventA.end) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
var eventA = events[i];
|
||||
// start-time in between any of the events
|
||||
if (eventStartDay >= eventA.start && eventStartDay <= eventA.end) {
|
||||
return true;
|
||||
}
|
||||
//end-time in between any of the events
|
||||
if (eventEndDay >= eventA.start && eventEndDay <= eventA.end) {
|
||||
return true;
|
||||
}
|
||||
//any of the events in between/on the start-time and end-time
|
||||
if (eventStartDay <= eventA.start && eventEndDay >= eventA.end) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
window.is_chinese = ( I18n && I18n.locale.indexOf('zh') != -1 );
|
||||
window.datetime_format = is_chinese ? 'y M d h:m b' : 'd M, y h:m b';
|
||||
window.date_format = is_chinese ? 'y M d' : 'd M, y';
|
||||
window.time_format = "h:m b";
|
||||
window.date_time_str_format = 'y/MM/d H:m';
|
||||
window.std_date_format = 'y-MM-d';
|
||||
window.short_day = (is_chinese ? "d (w)" : "w d");
|
||||
window.short_date = (is_chinese ? "M d (w)" : "w d, M");
|
||||
window.short_date_time = (is_chinese ? "M d (w) h:m b" : "w d, M h:m b");
|
||||
window.getDateString = function(date, format,is_chinese) {
|
||||
var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
|
||||
var week_days = ['Sun','Mon','Tue','Wed','Thu','Fri','Sat'];
|
||||
if(is_chinese){
|
||||
months = [];
|
||||
for(var i=0;i<12;i++){
|
||||
months.push((i+1)+"月");
|
||||
}
|
||||
week_days = ["週日","週一","週二","週三","週四","週五","週六"]
|
||||
}
|
||||
var getPaddedComp = function(comp) {
|
||||
return ((parseInt(comp) < 10) ? ('0' + comp) : comp)
|
||||
},
|
||||
formattedDate = format,
|
||||
o = {
|
||||
"y+": date.getFullYear() + (is_chinese ? "年" : ""), // year
|
||||
"MM+": getPaddedComp(date.getMonth() + 1), //raw month
|
||||
"M+": months[date.getMonth()], //month
|
||||
"d+": (is_chinese ? (date.getDate() + "日") : getPaddedComp(date.getDate())), //day
|
||||
"w+": week_days[date.getDay()], //weekday
|
||||
"h+": getPaddedComp((date.getHours() > 12) ? date.getHours() % 12 : date.getHours()), //hour
|
||||
"H+": getPaddedComp(date.getHours()), //hour
|
||||
"m+": getPaddedComp(date.getMinutes()), //minute
|
||||
"s+": getPaddedComp(date.getSeconds()), //second
|
||||
"S+": getPaddedComp(date.getMilliseconds()), //millisecond,
|
||||
"b+": (date.getHours() >= 12) ? 'PM' : 'AM'
|
||||
};
|
||||
|
||||
for (var k in o) {
|
||||
if (new RegExp("(" + k + ")").test(format)) {
|
||||
formattedDate = formattedDate.replace(RegExp.$1, o[k]);
|
||||
}
|
||||
}
|
||||
return formattedDate;
|
||||
window.getDateString = function(date, format, is_chinese) {
|
||||
var months = calendar_variable.months;
|
||||
var week_days = calendar_variable.dayNames;
|
||||
var getPaddedComp = function(comp) {
|
||||
return ((parseInt(comp) < 10) ? ('0' + comp) : comp)
|
||||
},
|
||||
formattedDate = format,
|
||||
y = date.getFullYear(),
|
||||
m = date.getMonth(),
|
||||
d = date.getDate(),
|
||||
H = date.getHours(),
|
||||
M = date.getMinutes(),
|
||||
s = date.getSeconds(),
|
||||
S = date.getMilliseconds(),
|
||||
month_name = months[m],
|
||||
am_trans = (calendar_variable.is_chinese ? '上午' : 'AM'),
|
||||
pm_trans = (calendar_variable.is_chinese ? '下午' : 'PM'),
|
||||
o = {
|
||||
"yy+": y, //raw year
|
||||
"y+": y + (calendar_variable.is_chinese ? "年" : ""), // year
|
||||
"MMM+": month_name, //month
|
||||
"MM+": getPaddedComp(m + 1), //raw month
|
||||
"M+": month_name.substring(0,3), //month
|
||||
"dd+": getPaddedComp(d), //raw day
|
||||
"d+": (calendar_variable.is_chinese ? (d + "日") : getPaddedComp(d)), //day
|
||||
"W+": week_days[date.getDay()], //weekday
|
||||
"w+": (calendar_variable.is_chinese ? week_days[date.getDay()].substr(-1, 1) : week_days[date.getDay()].substr(0, 3)), //weekday
|
||||
"h+": getPaddedComp((H > 12) ? H % 12 : H), //hour
|
||||
"H+": getPaddedComp(H), //hour
|
||||
"m+": getPaddedComp(M), //minute
|
||||
"s+": getPaddedComp(s), //second
|
||||
"S+": getPaddedComp(S), //millisecond,
|
||||
"b+": (H >= 12) ? pm_trans : am_trans
|
||||
};
|
||||
|
||||
for (var k in o) {
|
||||
if (new RegExp("(" + k + ")").test(format)) {
|
||||
formattedDate = formattedDate.replace(RegExp.$1, o[k]);
|
||||
}
|
||||
}
|
||||
return formattedDate;
|
||||
};
|
||||
var Calendar = function(dom,page_id,event_date=''){
|
||||
|
||||
|
@ -123,6 +171,7 @@ var Calendar = function(dom,page_id,event_date=''){
|
|||
this.rangeSelection = $("#range_selection");
|
||||
var agendaView = new AgendaView(c);
|
||||
var loadeventsonviewchange = false;
|
||||
this.success_event = null;
|
||||
this.initialize = function(){
|
||||
if (event_date != ''){
|
||||
var event_dates = event_date.split("-");
|
||||
|
@ -164,7 +213,7 @@ var Calendar = function(dom,page_id,event_date=''){
|
|||
});
|
||||
},
|
||||
// events: 'https://fullcalendar.io/demo-events.json',
|
||||
headerToolbar: false,
|
||||
headerToolbar: false,
|
||||
fixedWeekCount: false,
|
||||
initialView: dview,
|
||||
loading: function(bool) {
|
||||
|
@ -177,12 +226,12 @@ var Calendar = function(dom,page_id,event_date=''){
|
|||
c.calendar_dom.calendar.refetchEvents();
|
||||
},
|
||||
eventTimeFormat: { hour12: true, hour: '2-digit', minute: '2-digit', omitZeroMinute: true, meridiem: 'narrow' },
|
||||
eventClick: function(eventClickInfo) {
|
||||
var calEvent = {"event": eventClickInfo.event},
|
||||
originalEvent = eventClickInfo.jsEvent,
|
||||
view = eventClickInfo.view,
|
||||
el = $(eventClickInfo.el);
|
||||
if(el.hasClass("reserve_btn")){
|
||||
eventClick: function(eventClickInfo) {
|
||||
var calEvent = {"event": eventClickInfo.event},
|
||||
originalEvent = eventClickInfo.jsEvent,
|
||||
view = eventClickInfo.view,
|
||||
el = $(eventClickInfo.el);
|
||||
if(el.hasClass("reserve_btn")){
|
||||
window.calEvent = calEvent;
|
||||
var start_time = calEvent.event.start;
|
||||
var date_str = window.getDateString(start_time,std_date_format);
|
||||
|
@ -190,12 +239,12 @@ var Calendar = function(dom,page_id,event_date=''){
|
|||
var allow_times = calEvent.event._def.extendedProps.allow_times;
|
||||
window.pick_hire_date(date_str,allow_times);
|
||||
}else{
|
||||
c.dialog.dismiss();
|
||||
c.dialog.inflate(calEvent);
|
||||
c.dialog.show({"x": originalEvent.clientX,"y": originalEvent.clientY});
|
||||
}
|
||||
},
|
||||
dateClick: function(ev) {
|
||||
c.dialog.dismiss();
|
||||
c.dialog.inflate(calEvent);
|
||||
c.dialog.show({"x": originalEvent.clientX,"y": originalEvent.clientY});
|
||||
}
|
||||
},
|
||||
dateClick: function(ev) {
|
||||
var calendar = this;
|
||||
var calendar_dom = $(this.el);
|
||||
if(c.calendar_dom.hasClass("active_picker")){
|
||||
|
@ -208,25 +257,54 @@ var Calendar = function(dom,page_id,event_date=''){
|
|||
calendar_dom.trigger("init_time",[time_str]);
|
||||
calendar_dom.trigger("select_time",[date_str]);
|
||||
}
|
||||
},
|
||||
},
|
||||
views: {
|
||||
dayGridMonth: {
|
||||
dayMaxEvents: false
|
||||
}
|
||||
}
|
||||
timeGridDay: {
|
||||
titleFormat: function(date_info){
|
||||
var date = date_info.date.marker;
|
||||
return getDateString(date, calendar_variable.date_format_with_week);
|
||||
},
|
||||
dayHeaderFormat: function(date_info){
|
||||
return window.calendar_variable.dayNames[date_info.date.marker.getDay()];
|
||||
}
|
||||
},
|
||||
timeGridWeek: {
|
||||
titleFormat: function(date_info){
|
||||
var start = date_info.start.marker,
|
||||
end = date_info.end.marker;
|
||||
return getDateString(start, calendar_variable.date_format) + ' ~ ' + getDateString(end, calendar_variable.date_format);
|
||||
},
|
||||
dayHeaderFormat: function(date_info){
|
||||
return getDateString(date_info.date.marker, calendar_variable.short_date_numeric);
|
||||
}
|
||||
},
|
||||
dayGridMonth: {
|
||||
dayMaxEvents: false,
|
||||
titleFormat: function(date_info){
|
||||
var date = date_info.date.marker;
|
||||
return getDateString(date, calendar_variable.month_year_format);
|
||||
},
|
||||
dayHeaderFormat: function(date_info){
|
||||
return window.calendar_variable.dayNamesShort[date_info.date.marker.getDay()];
|
||||
}
|
||||
}
|
||||
},
|
||||
firstDay: (window.calendar_variable.sunday_first == true ? 0 : 1)
|
||||
});
|
||||
|
||||
c.nextBtn.click(function(){
|
||||
c.dialog.dismiss();
|
||||
c.calendar_dom.calendar.next();
|
||||
c.title.text(c.calendar_dom.calendar.currentData.viewTitle);
|
||||
});
|
||||
c.prevBtn.click(function(){
|
||||
c.dialog.dismiss();
|
||||
c.calendar_dom.calendar.prev();
|
||||
c.title.text(c.calendar_dom.calendar.currentData.viewTitle);
|
||||
});
|
||||
c.todayBtn.click(function(){
|
||||
c.dialog.dismiss();
|
||||
c.calendar_dom.calendar.today();
|
||||
c.title.text(c.calendar_dom.calendar.currentData.viewTitle);
|
||||
});
|
||||
c.modeBtns.click(function(){
|
||||
c.dialog.dismiss();
|
||||
|
@ -239,7 +317,6 @@ var Calendar = function(dom,page_id,event_date=''){
|
|||
else
|
||||
c.calendar_dom.calendar.refetchEvents();
|
||||
});
|
||||
|
||||
var toggleViews = function(view){
|
||||
c.modeBtns.removeClass("active");
|
||||
c.modeBtns.each(function(){
|
||||
|
@ -265,13 +342,8 @@ var Calendar = function(dom,page_id,event_date=''){
|
|||
c.calendar_dom.calendar.refetchEvents();
|
||||
loadeventsonviewchange = false;
|
||||
}
|
||||
if(c.calendar_dom.calendar.currentData){
|
||||
var viewTitle = c.calendar_dom.calendar.currentData.viewTitle;
|
||||
if(view == "timeGridDay" && $('.fc-col-header-cell-cushion ').text() != "")
|
||||
viewTitle = $('.fc-col-header-cell-cushion ').text() + ', ' + viewTitle;
|
||||
$('#current_title').html(viewTitle);
|
||||
}
|
||||
c.calendar_dom.calendar.render(); //Rerender to fix layout
|
||||
c.title.text(c.calendar_dom.calendar.currentData.viewTitle);
|
||||
// c.calendar_dom.calendar.rerenderEvents(); //Rerender to fix layout
|
||||
};
|
||||
if(c.currentView == "agenda"){toggleViews("agenda");loadeventsonviewchange = true;}
|
||||
};
|
||||
|
@ -301,7 +373,7 @@ var Calendar = function(dom,page_id,event_date=''){
|
|||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
this.renderEvent = function(eventStick){
|
||||
if(eventStick.recurring === true)
|
||||
c.calendar_dom.calendar.refetchEvents();
|
||||
|
@ -325,11 +397,8 @@ var EventDialog = function(calendar,event){
|
|||
_event.allDay = _event.event.allDay;
|
||||
_event._start = _event.event.start;
|
||||
_event._end = (_event.event.end ? _event.event.end : _event.event.start);
|
||||
// var start_date = getDateString(_event._start,date_format);
|
||||
// var end_date = getDateString(_event._end,date_format);
|
||||
if(_event._end - _event._start > 86400 * 1000){
|
||||
_event.allDay = true;
|
||||
}
|
||||
// var start_date = getDateString(_event._start,calendar_variable.date_format);
|
||||
// var end_date = getDateString(_event._end,calendar_variable.date_format);
|
||||
_event.title = _event.event.title;
|
||||
var extendedProps = _event.event.extendedProps;
|
||||
Object.keys(extendedProps).forEach(function(k){
|
||||
|
@ -342,15 +411,15 @@ var EventDialog = function(calendar,event){
|
|||
end_time = "",
|
||||
time_string = null;
|
||||
if(_event.allDay) {
|
||||
start_time = getDateString(_event._start,datetime_format, is_chinese);
|
||||
start_time = getDateString(_event._start,calendar_variable.date_format_with_short_month);
|
||||
if(_event._end)
|
||||
end_time = getDateString(_event._end,datetime_format, is_chinese);
|
||||
end_time = getDateString(_event._end,calendar_variable.date_format_with_short_month);
|
||||
time_string = (_event._start === _event._end || !_event._end ? "<p class='start-date'><i class='icons-calendar' /></i>" + start_time + "</p>" : "<i class='icons-calendar' /></i>" + start_time + "<br><i class='icons-arrow-right-5' /></i>" + end_time + "");
|
||||
} else {
|
||||
start_time = getDateString(_event._start,date_format, is_chinese);
|
||||
end_time = getDateString(_event._end,date_format, is_chinese);
|
||||
var stime = getDateString(_event._start,time_format, is_chinese),
|
||||
etime = getDateString(_event._end,time_format, is_chinese),
|
||||
start_time = getDateString(_event._start,calendar_variable.date_format_with_short_month);
|
||||
end_time = getDateString(_event._end,calendar_variable.date_format_with_short_month);
|
||||
var stime = getDateString(_event._start,time_format),
|
||||
etime = getDateString(_event._end,time_format),
|
||||
same = (start_time == end_time);
|
||||
if( same ){
|
||||
time_string = "<p class='date'><i class='icons-calendar' /></i> " +
|
||||
|
@ -366,15 +435,15 @@ var EventDialog = function(calendar,event){
|
|||
}
|
||||
event_quick_view = $('<div class="calendar-modal" style="display:none;"></div>');
|
||||
template = '<div class="modal-content">' +
|
||||
'<div class="modal-header">' +
|
||||
'<button type="button" class="close event-close-btn" data-dismiss="modal" aria-hidden="true">×</button>' +
|
||||
'<h3>' + (_event.url_linked=='' ? _event.title : ("<a href=\"" +_event.url_linked+"\">"+_event.title+"</a>")) + '</h3>' +
|
||||
'</div>' +
|
||||
'<div class="modal-body">' +
|
||||
'<div class="event_summary">' + time_string + '</br>' + _event.hiring_person_name + '</div>' + _event.note +
|
||||
(_event.error_message ? ("<br><span style=\"color: #FC4040;\">" + _event.error_message + "</span>") : "")
|
||||
'</div>' +
|
||||
'<div class="modal-footer" />' +
|
||||
'<div class="modal-header">' +
|
||||
'<button type="button" class="close event-close-btn" data-dismiss="modal" aria-hidden="true">×</button>' +
|
||||
'<h3>' + (_event.url_linked=='' ? _event.title : ("<a href=\"" +_event.url_linked+"\">"+_event.title+"</a>")) + '</h3>' +
|
||||
'</div>' +
|
||||
'<div class="modal-body">' +
|
||||
'<div class="event_summary">' + time_string + '</br>' + _event.hiring_person_name + '</div>' + _event.note +
|
||||
(_event.error_message ? ("<br><span style=\"color: #FC4040;\">" + _event.error_message + "</span>") : "")
|
||||
'</div>' +
|
||||
'<div class="modal-footer" />' +
|
||||
'</div>';
|
||||
}
|
||||
|
||||
|
@ -453,11 +522,11 @@ var EventDialog = function(calendar,event){
|
|||
}
|
||||
|
||||
var UserException = function(message) {
|
||||
this.message = message;
|
||||
this.name = "UserException";
|
||||
this.toString = function(){
|
||||
return this.message;
|
||||
}
|
||||
this.message = message;
|
||||
this.name = "UserException";
|
||||
this.toString = function(){
|
||||
return this.message;
|
||||
}
|
||||
}
|
||||
|
||||
var AgendaView = function(calendar){
|
||||
|
@ -470,20 +539,16 @@ var AgendaView = function(calendar){
|
|||
var start_year = today.getFullYear();
|
||||
var end_month = ((start_month + minDifference) > 11 ? (start_month + minDifference) - 11 : start_month + minDifference);
|
||||
var end_year = ((start_month + minDifference) > 11 ? start_year+1 : start_year);
|
||||
var monthNames = ['January','February','March','April','May','June','July','August','September','October','November','December'];
|
||||
var monthNames = window.calendar_variable.months;
|
||||
var month_template = '<div class="col-md-4">' +
|
||||
'<h4></h4>' +
|
||||
'<div class="tiny_calendar">' +
|
||||
'<table class="table table-condensed table-bordered">' +
|
||||
'<tbody>' +
|
||||
'<tr>' +
|
||||
'<th class="week_title">Sun</th>' +
|
||||
'<th class="week_title">Mon</th>' +
|
||||
'<th class="week_title">Tue</th>' +
|
||||
'<th class="week_title">Wed</th>' +
|
||||
'<th class="week_title">Thu</th>' +
|
||||
'<th class="week_title">Fri</th>' +
|
||||
'<th class="week_title">Sat</th>' +
|
||||
calendar_variable.dayNamesShort.map(function(title){
|
||||
return '<th class="week_title">'+title+'</th>';
|
||||
}).join('') +
|
||||
'</tr>' +
|
||||
'</tbody>' +
|
||||
'</table>' +
|
||||
|
@ -494,10 +559,8 @@ var AgendaView = function(calendar){
|
|||
'<table class="table table-condensed table-bordered event_list">' +
|
||||
'<thead>' +
|
||||
'<tr>' +
|
||||
'<th>Date</th>' +
|
||||
'<th>Time</th>' +
|
||||
'<th>DateTime</th>' +
|
||||
'<th>Events</th>' +
|
||||
'<th>Borrower</th>' +
|
||||
'</tr>' +
|
||||
'</thead>' +
|
||||
'<tbody>' +
|
||||
|
@ -509,20 +572,18 @@ var AgendaView = function(calendar){
|
|||
'</div>';
|
||||
|
||||
var head_template = '<div>' +
|
||||
'<label>From</label>' +
|
||||
'<label>'+(window.calendar_variable.from ? window.calendar_variable.from : 'From')+'</label>' +
|
||||
'<input class="input-large" id="agenda_start" placeholder="YYYY/MM" type="text" value="'+start_year+'/'+('0'+(start_month+1)).substr(-2,2)+'" title="YYYY/MM" autocomplete="off">'+
|
||||
'<label>To</label>' +
|
||||
'<label>'+(window.calendar_variable.to ? window.calendar_variable.to : 'To')+'</label>' +
|
||||
'<input class="input-large" id="agenda_end" placeholder="YYYY/MM" type="text" value="'+end_year+'/'+('0'+(end_month+1)).substr(-2,2)+'" title="YYYY/MM" autocomplete="off">'+
|
||||
'<button id="show_events" class="btn btn-sm bt-filter btn-primary">Show Events</button>' +
|
||||
'</div>';
|
||||
|
||||
var event_template = '<tr>' +
|
||||
'<td />' +
|
||||
'<td class="event_time" />' +
|
||||
'<td class="event_datetime" />' +
|
||||
'<td>' +
|
||||
'<div class="event" />' +
|
||||
'</td>' +
|
||||
'<td class="Borrower">'+
|
||||
'</tr>';
|
||||
// var month_template = '<div class="span4"><h4></h4><div class="tiny_calendar"><table class="table"><tbody><tr><th class="week_title">Sun</th><th class="week_title">Mon</th><th class="week_title">Tue</th><th class="week_title">Wed</th><th class="week_title">Thu</th><th class="week_title">Fri</th><th class="week_title">Sat</th></tr></tbody></table></div></div>';
|
||||
|
||||
|
@ -617,8 +678,9 @@ var AgendaView = function(calendar){
|
|||
type : "get",
|
||||
url : url,
|
||||
dataType : "json",
|
||||
data : {"agenda_start":sd.toLocaleString(),"agenda_end":ed.toLocaleString(),"page_id" : _calendar.page_id,"start":usd,"end":ued},
|
||||
data : {"agenda_start":sd.toLocaleString(),"agenda_end":ed.toLocaleString(),"unix_start":usd,"unix_end":ued},
|
||||
success : function(data){
|
||||
data = data.events;
|
||||
$("#agenda_start,#agenda_end").datepicker({
|
||||
dateFormat: "yy/mm",
|
||||
onChangeMonthYear: function( year, month, inst ){
|
||||
|
@ -641,13 +703,13 @@ var AgendaView = function(calendar){
|
|||
$.datepicker._updateDatepicker(inst);
|
||||
})
|
||||
$("#agenda_start,#agenda_end").focus(function () {
|
||||
$(".ui-datepicker-calendar").hide();
|
||||
$("#ui-datepicker-div").position({
|
||||
my: "center top",
|
||||
at: "center bottom",
|
||||
of: $(this)
|
||||
});
|
||||
});
|
||||
$(".ui-datepicker-calendar").hide();
|
||||
$("#ui-datepicker-div").position({
|
||||
my: "center top",
|
||||
at: "center bottom",
|
||||
of: $(this)
|
||||
});
|
||||
});
|
||||
$.each(data,function(i,e){
|
||||
var ed = eventDom(e),
|
||||
s = new Date(e.start),
|
||||
|
@ -705,16 +767,24 @@ var AgendaView = function(calendar){
|
|||
var e_t = $(event_template),
|
||||
s = new Date(event.start),
|
||||
e = new Date(event.end),
|
||||
dateFormat = "",
|
||||
hiring_person_name = event.hiring_person_name;
|
||||
if(s.getDate() == e.getDate() && s.getMonth() == s.getMonth() && e.getFullYear() == e.getFullYear())
|
||||
dateFormat = getDateString(s, short_day,is_chinese);
|
||||
else
|
||||
dateFormat = getDateString(s,short_date,is_chinese) + ' - ' + getDateString(e,short_date,is_chinese);
|
||||
e_t.find("td:first").text(dateFormat);
|
||||
e_t.find("td.event_time").text((event.diff_day ? (getDateString(s, short_date_time,is_chinese)+"~"+getDateString(e, short_date_time, is_chinese)) : (getDateString(s, time_format)+"~"+getDateString(e, time_format))));
|
||||
datetimeFormat = "";
|
||||
if(s.getDate() == e.getDate() && s.getMonth() == s.getMonth() && e.getFullYear() == e.getFullYear()){
|
||||
datetimeFormat = getDateString(s, calendar_variable.short_day);
|
||||
if(!event.allDay){
|
||||
datetimeFormat += (' ' + getDateString(s,time_format) + ' - ' + getDateString(e,time_format));
|
||||
}
|
||||
}else{
|
||||
console.log(event);
|
||||
console.log(event.start);
|
||||
console.log(event.end);
|
||||
if(event.allDay){
|
||||
datetimeFormat = getDateString(s,calendar_variable.short_date) + ' - ' + getDateString(e,calendar_variable.short_date);
|
||||
}else{
|
||||
datetimeFormat = getDateString(s,calendar_variable.short_date_time) + ' - ' + getDateString(e,calendar_variable.short_date_time);
|
||||
}
|
||||
}
|
||||
e_t.find("td.event_datetime").text(datetimeFormat);
|
||||
e_t.find("div.event").html(event.title).css("color",event.color);
|
||||
e_t.find("td.Borrower").text(hiring_person_name);
|
||||
return e_t;
|
||||
}
|
||||
|
||||
|
@ -773,7 +843,8 @@ var AgendaView = function(calendar){
|
|||
var last_inserted_date = 1;
|
||||
|
||||
var renderMonth = function(){
|
||||
var num_of_rows = getNumberOfRows(year,month)
|
||||
var num_of_rows = getNumberOfRows(year,month);
|
||||
var tbody = template.find("table.table tbody");
|
||||
for(var i = 0; i < num_of_rows; i++){
|
||||
var tr = null;
|
||||
if(i == 0)
|
||||
|
@ -786,29 +857,29 @@ var AgendaView = function(calendar){
|
|||
if(tr == null){
|
||||
break;
|
||||
}
|
||||
template.find("table.table tbody").append(tr);
|
||||
template.find("h4").text(monthNames[firstDay.getMonth()] + " - " + firstDay.getFullYear());
|
||||
tbody.append(tr);
|
||||
}
|
||||
template.find("h4").text(getDateString(firstDay, calendar_variable.month_year_format));
|
||||
_this.monthDom.append(template);
|
||||
_this.monthDom.append(list_template);
|
||||
}
|
||||
|
||||
function getNumberOfRows(year, month) {
|
||||
var day = 1,
|
||||
sat_counter = 0,
|
||||
sunday_counter = 0,
|
||||
date = new Date(year, month, day);
|
||||
var day = 1,
|
||||
sat_counter = 0,
|
||||
sunday_counter = 0,
|
||||
date = new Date(year, month, day);
|
||||
|
||||
while(date.getMonth() === month) {
|
||||
if(date.getDay() === 0) {
|
||||
sunday_counter++;
|
||||
}else if(date.getDay() === 6) {
|
||||
sat_counter++;
|
||||
}
|
||||
day++;
|
||||
date = new Date(year, month, day);
|
||||
}
|
||||
return (sunday_counter == 5 && sat_counter == 5 ? 6 : 5);
|
||||
while(date.getMonth() === month) {
|
||||
if(date.getDay() === 0) {
|
||||
sunday_counter++;
|
||||
}else if(date.getDay() === 6) {
|
||||
sat_counter++;
|
||||
}
|
||||
day++;
|
||||
date = new Date(year, month, day);
|
||||
}
|
||||
return (sunday_counter == 5 && sat_counter == 5 ? 6 : 5);
|
||||
}
|
||||
|
||||
var makeRow = function(position){
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -0,0 +1,6 @@
|
|||
/*!
|
||||
FullCalendar v5.5.0
|
||||
Docs & License: https://fullcalendar.io/
|
||||
(c) 2020 Adam Shaw
|
||||
*/
|
||||
var FullCalendarMoment=function(e,t,a){"use strict";function n(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var r=n(a);var l=t.createPlugin({cmdFormatter:function(e,t){var a=function e(t){var a=t.match(/^(.*?)\{(.*)\}(.*)$/);if(a){var n=e(a[2]);return{head:a[1],middle:n,tail:a[3],whole:a[1]+n.whole+a[3]}}return{head:null,middle:null,tail:null,whole:t}}(e);if(t.end){var n=o(t.start.array,t.timeZone,t.start.timeZoneOffset,t.localeCodes[0]),r=o(t.end.array,t.timeZone,t.end.timeZoneOffset,t.localeCodes[0]);return function e(t,a,n,r){if(t.middle){var l=a(t.head),u=e(t.middle,a,n,r),o=a(t.tail),i=n(t.head),d=e(t.middle,a,n,r),f=n(t.tail);if(l===i&&o===f)return l+(u===d?u:u+r+d)+o}var c=a(t.whole),m=n(t.whole);if(c===m)return c;return c+r+m}(a,u(n),u(r),t.defaultSeparator)}return o(t.date.array,t.timeZone,t.date.timeZoneOffset,t.localeCodes[0]).format(a.whole)}});function u(e){return function(t){return t?e.format(t):""}}function o(e,t,a,n){var l;return"local"===t?l=r.default(e):"UTC"===t?l=r.default.utc(e):r.default.tz?l=r.default.tz(e,t):(l=r.default.utc(e),null!=a&&l.utcOffset(a)),l.locale(n),l}return t.globalPlugins.push(l),e.default=l,e.toMoment=function(e,a){if(!(a instanceof t.CalendarApi))throw new Error("must supply a CalendarApi instance");var n=a.getCurrentData().dateEnv;return o(e,n.timeZone,null,n.locale.codes[0])},e.toMomentDuration=function(e){return r.default.duration(e)},Object.defineProperty(e,"__esModule",{value:!0}),e}({},FullCalendar,moment);
|
|
@ -3,6 +3,7 @@ class Admin::CalendarsController < OrbitAdminController
|
|||
# GET /events.json
|
||||
|
||||
def index
|
||||
@calendar_setting = CalendarSetting.first
|
||||
@events = []
|
||||
tags = @module_app.tags
|
||||
categories = CalendarType.all
|
||||
|
@ -165,6 +166,14 @@ class Admin::CalendarsController < OrbitAdminController
|
|||
# end
|
||||
end
|
||||
|
||||
def calendar_setting
|
||||
@calendar_setting = CalendarSetting.first
|
||||
end
|
||||
def update_calendar_setting
|
||||
@calendar_setting = CalendarSetting.first
|
||||
@calendar_setting.update_attributes(params.require(:calendar_setting).permit!)
|
||||
redirect_to calendar_setting_admin_calendars_path
|
||||
end
|
||||
private
|
||||
def event_page_params
|
||||
params.require(:event).permit!
|
||||
|
|
|
@ -6,7 +6,10 @@ class CalendarsController < ApplicationController
|
|||
def index
|
||||
page = Page.where(page_id: OrbitHelper.params[:page_id]).first
|
||||
style_file = page.layout=='index3' ? '/assets/calendar_widget2' : '/assets/calendar_widget1'
|
||||
@calendar_setting = CalendarSetting.first
|
||||
{
|
||||
"modes_info" => @calendar_setting.get_modes_info.map.with_index{|(trans, mode),i| {trans: trans, mode: mode, active_class: (i ==
|
||||
2 ? 'active' : '')}},
|
||||
"extras" => {
|
||||
"page_id" => OrbitHelper.params[:page_id],
|
||||
'widget_title' => page.name,
|
||||
|
@ -29,7 +32,10 @@ class CalendarsController < ApplicationController
|
|||
|
||||
def widget
|
||||
part = OrbitHelper.get_current_widget
|
||||
@calendar_setting = CalendarSetting.first
|
||||
{
|
||||
"modes_info" => @calendar_setting.get_modes_info.map.with_index{|(trans, mode),i| {trans: trans, mode: mode, active_class: (i ==
|
||||
2 ? 'active' : '')}},
|
||||
"extras" => {
|
||||
"subpart-id" => part.id.to_s,
|
||||
"more_url" => OrbitHelper.widget_more_url,
|
||||
|
@ -84,7 +90,7 @@ class CalendarsController < ApplicationController
|
|||
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).utc)}.to_json({"frontend" => true})
|
||||
render json: {"events" => events,"calendar_title"=>get_calendar_title(Time.at(params[:unix_start].to_i).utc)}.to_json({"frontend" => true})
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -109,7 +115,7 @@ class CalendarsController < ApplicationController
|
|||
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).utc)}.to_json({"frontend" => true})
|
||||
render json: {"events" => events,"calendar_title"=>get_calendar_title(Time.at(params[:unix_start].to_i).utc)}.to_json({"frontend" => true})
|
||||
end
|
||||
end
|
||||
def get_calendar_title(now_date=nil)
|
||||
|
|
|
@ -0,0 +1,81 @@
|
|||
class CalendarSetting
|
||||
include Mongoid::Document
|
||||
include Mongoid::Timestamps
|
||||
field :enable, type: Boolean, default: false
|
||||
field :modes, type: Hash, default: {}, localize: true
|
||||
field :days, type: Array, default: [], localize: true
|
||||
field :sunday_first, type: Boolean, localize: true
|
||||
field :date_type, type: Integer, localize: true, default: 0
|
||||
field :titleFormat, localize: true
|
||||
All_days = (0...7).to_a
|
||||
ModesInfo = {'day'=>'timeGridDay', 'week'=>'timeGridWeek', 'month'=>'dayGridMonth', 'agenda'=>'agenda'}
|
||||
All_modes = ModesInfo.keys
|
||||
DateTypes = {
|
||||
"zh_tw"=>["[LocaleString]: 2022年7月12日 (週三)", "[en-US format]: weekday, monthname dd, YYYY", "[Locale Numeric]: YYYY/mm/dd (weekday)"],
|
||||
"en"=>["[LocaleString]: weekday, monthname dd, YYYY", "[en-US format]: weekday, monthname dd, YYYY", "[Locale Numeric]: weekday, mm/dd/YYYY"]
|
||||
}
|
||||
def week_title
|
||||
if self.days.present?
|
||||
self.days
|
||||
else
|
||||
(0...7).map{|i| I18n.t("calendar.day.#{i}")}
|
||||
end
|
||||
end
|
||||
def get_week_title(locale)
|
||||
tmp = self.days_translations[locale]
|
||||
if tmp.present?
|
||||
tmp
|
||||
else
|
||||
I18n.with_locale(locale){All_days.map{|i| I18n.t("calendar.day.#{i}")}}
|
||||
end
|
||||
end
|
||||
def sunday_first
|
||||
val = super
|
||||
if val.nil?
|
||||
if I18n.locale == :zh_tw
|
||||
val = false
|
||||
else
|
||||
val = true
|
||||
end
|
||||
end
|
||||
val
|
||||
end
|
||||
def get_sunday_first(locale)
|
||||
val = self.sunday_first_translations[locale]
|
||||
if val.nil?
|
||||
if locale == :zh_tw
|
||||
val = false
|
||||
else
|
||||
val = true
|
||||
end
|
||||
end
|
||||
val
|
||||
end
|
||||
def get_mode(mode, locale)
|
||||
tmp = self.modes_translations[locale] || {}
|
||||
val = tmp[mode]
|
||||
if val.nil?
|
||||
val = I18n.with_locale(locale){I18n.t("calendar.mode.#{mode}")}
|
||||
end
|
||||
val
|
||||
end
|
||||
def get_modes(use_default=false)
|
||||
tmp = self.modes_translations[I18n.locale]
|
||||
if tmp.blank? || use_default
|
||||
All_modes.map{|m| [m, I18n.t("calendar.mode.#{m}")]}.to_h
|
||||
else
|
||||
tmp
|
||||
end
|
||||
end
|
||||
def get_modes_info(use_default=false)
|
||||
tmp = self.get_modes(use_default || !(self.enable))
|
||||
tmp.map{|m, trans| [trans, ModesInfo[m]]}
|
||||
end
|
||||
def titleFormat
|
||||
tmp = super
|
||||
if tmp.nil?
|
||||
tmp = 'dddd, MMMM D, YYYY'
|
||||
end
|
||||
tmp
|
||||
end
|
||||
end
|
|
@ -0,0 +1,79 @@
|
|||
<style>
|
||||
.disable_block{
|
||||
display: none;
|
||||
}
|
||||
</style>
|
||||
<%= stylesheet_link_tag "lib/togglebox"%>
|
||||
<%= form_for @calendar_setting, url: update_calendar_setting_admin_calendars_path, html: {class: "form-horizontal main-forms"} do |f| %>
|
||||
<div class="input-area">
|
||||
<div class="control-group">
|
||||
<%= f.label :enable, t("calendar.enable"), :class => "control-label muted", :for=>'calendar_setting_enable' %>
|
||||
<div class="controls">
|
||||
<%= f.check_box :enable , :class=>"toggle-check", :data=> { disabled: true }, :id=>'calendar_setting_enable' %>
|
||||
</div>
|
||||
</div>
|
||||
<div id="calendar_setting_block" class="<%= 'disable_block' unless f.object.enable %>">
|
||||
<!-- Language Tabs -->
|
||||
<div class="nav-name"><strong><%= t(:language) %></strong></div>
|
||||
<ul class="nav nav-pills language-nav">
|
||||
<% @site_in_use_locales.each_with_index do |locale, i| %>
|
||||
<li class="<%= 'active' if i == 0 %>">
|
||||
<a data-toggle="tab" href=".<%= locale %>"><%= t(locale) %></a>
|
||||
</li>
|
||||
<% end %>
|
||||
</ul>
|
||||
|
||||
<!-- Language -->
|
||||
<div class="tab-content language-area">
|
||||
<% @site_in_use_locales.each_with_index do |locale, i| %>
|
||||
<div class="<%= locale %> tab-pane fade <%= ( i == 0 ) ? "in active" : '' %>">
|
||||
<%= f.label :sunday_first, t("calendar.sunday_first"), :class => "control-label muted" %>
|
||||
<div class="controls">
|
||||
<%= f.fields_for :sunday_first_translations ,f.object do |f| %>
|
||||
<%= hidden_field_tag "#{f.object_name}[#{locale}]" , "0" %>
|
||||
<%= check_box_tag "#{f.object_name}[#{locale}]" , "1", f.object.get_sunday_first(locale) , :class=>"toggle-check", :data=> { disabled: true } %>
|
||||
<% end %>
|
||||
</div>
|
||||
<%= f.label :date_type, t("calendar.date_type"), :class => "control-label muted" %>
|
||||
<div class="controls">
|
||||
<%= f.fields_for :date_type_translations ,f.object do |f| %>
|
||||
<%
|
||||
tmp = CalendarSetting::DateTypes[locale.to_s]
|
||||
tmp = CalendarSetting::DateTypes["en"] if tmp.nil?
|
||||
%>
|
||||
<%= select_tag "#{f.object_name}[#{locale}]" , options_for_select(tmp.map.with_index{|t, idx| [t, idx]}, f.object.date_type_translations[locale]), {style: "width: auto;"} %>
|
||||
<% end %>
|
||||
</div>
|
||||
<hr style="margin: 5px 0;border-top: 2px solid black;clear: left;">
|
||||
<h4><%= t('calendar.calendar_mode') %></h4>
|
||||
<% CalendarSetting::All_modes.each do |mode| %>
|
||||
<%= f.label mode, t("calendar.mode.#{mode}"), :class => "control-label muted" %>
|
||||
<div class="controls">
|
||||
<%= f.fields_for :modes_translations ,f.object do |f| %>
|
||||
<%= text_field_tag "#{f.object_name}[#{locale}][#{mode}]" , f.object.get_mode(mode, locale) %>
|
||||
<% end %>
|
||||
</div>
|
||||
<% end %>
|
||||
<hr style="margin: 5px 0;border-top: 2px solid black;clear: left;">
|
||||
<h4><%= t('calendar.day_of_the_week') %></h4>
|
||||
<% CalendarSetting::All_days.each do |idx| %>
|
||||
<%= f.label "days_#{locale}_#{idx}", t("calendar.day.#{idx}"), :class => "control-label muted" %>
|
||||
<% week_title = f.object.get_week_title(locale) %>
|
||||
<div class="controls">
|
||||
<%= f.fields_for :days_translations ,f.object do |f| %>
|
||||
<%= text_field_tag "#{f.object_name}[#{locale}][]" , week_title[idx] %>
|
||||
<% end %>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
<% end %>
|
||||
<div class="form-actions">
|
||||
<%= f.submit t('submit'), class: 'btn btn-primary' %>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
<script>
|
||||
$('#calendar_setting_enable').change(function(){
|
||||
$('#calendar_setting_block').toggleClass('disable_block');
|
||||
})
|
||||
</script>
|
|
@ -1,10 +1,20 @@
|
|||
<% content_for :page_specific_javascript do %>
|
||||
<%= render :partial=>'calendars/calendar_variable' %>
|
||||
<% end %>
|
||||
<%#= javascript_include_tag 'calendar_moment.min' %>
|
||||
<%= javascript_include_tag 'fullcalendar' %>
|
||||
<%#= javascript_include_tag 'fullcalendar_moment.min' %>
|
||||
<%= javascript_include_tag 'calendar' %>
|
||||
<%= javascript_include_tag 'validator' %>
|
||||
|
||||
<%= stylesheet_link_tag "fullcalendar"%>
|
||||
<%= stylesheet_link_tag "calendar"%>
|
||||
<%= render_filter @filter_fields, "view_holder" %>
|
||||
<style type="text/css">
|
||||
.row{
|
||||
margin-left: 0;
|
||||
}
|
||||
</style>
|
||||
<div id="orbit_calendar" class="month_view">
|
||||
<div class="clearfix cal-fn">
|
||||
<div id='sec2'>
|
||||
|
@ -14,7 +24,7 @@
|
|||
<div class="btn-toolbar" id="navigation">
|
||||
<div id="calendar-nav">
|
||||
<div class="btn-group">
|
||||
<button class="btn" id="today_btn">Today</button>
|
||||
<button class="btn" id="today_btn"><%=t('calendar.today')%></button>
|
||||
</div>
|
||||
<div class="btn-group">
|
||||
<button class="btn" id="prev_month_btn">
|
||||
|
@ -31,10 +41,9 @@
|
|||
<div class="pull-right" id='sec3'>
|
||||
<div class="btn-toolbar">
|
||||
<div class="btn-group calendar_mode">
|
||||
<button class="btn mode_switch" data-mode="agendaDay" >day</button>
|
||||
<button class="btn mode_switch" data-mode="agendaWeek" >week</button>
|
||||
<button class="btn active mode_switch" data-mode="month" >month</button>
|
||||
<button class="btn mode_switch" data-mode="agenda" >agenda</button>
|
||||
<%= @calendar_setting.get_modes_info.each_with_index do |(trans, mode), i| %>
|
||||
<button class="btn btn-default mode_switch btn-sm <%= 'active' if i == 2 %>" data-mode="<%= mode %>" ><%= trans %></button>
|
||||
<% end %>
|
||||
</div>
|
||||
<div class="btn-group">
|
||||
<button id="refresh_btn" class="btn">
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
<script>
|
||||
window.calendar_variable = {};
|
||||
window.calendar_variable.from = "<%=t('calendar.from')%>";
|
||||
window.calendar_variable.to = "<%=t('calendar.to')%>";
|
||||
<% if @calendar_setting && @calendar_setting.enable %>
|
||||
window.calendar_variable.sunday_first = <%=@calendar_setting.sunday_first%>;
|
||||
window.calendar_variable.week_title = <%=@calendar_setting.week_title.to_s.html_safe%>;
|
||||
window.calendar_variable.date_type = <%=@calendar_setting.date_type%>;
|
||||
window.calendar_variable.dayNames = <%=@calendar_setting.days.to_s.html_safe%>;
|
||||
<% if I18n.locale == :zh_tw %>
|
||||
window.calendar_variable.dayNamesShort = <%=@calendar_setting.days.map{|d| d[-1]}.to_s.html_safe%>;
|
||||
<% else %>
|
||||
window.calendar_variable.dayNamesShort = <%=@calendar_setting.days.map{|d| d[0...3]}.to_s.html_safe%>;
|
||||
<% end %>
|
||||
<% end %>
|
||||
</script>
|
|
@ -1,6 +1,7 @@
|
|||
<% @calendar_setting = CalendarSetting.first %>
|
||||
<%= render :partial=>'calendars/calendar_variable' %>
|
||||
<%= javascript_include_tag 'fullcalendar' %>
|
||||
<%= javascript_include_tag 'calendar_frontend' %>
|
||||
<%= stylesheet_link_tag "fullcalendar"%>
|
||||
<%= stylesheet_link_tag "calendar"%>
|
||||
|
||||
<%= render_view %>
|
|
@ -2,18 +2,21 @@ $:.push File.expand_path("../lib", __FILE__)
|
|||
|
||||
# Maintain your gem's version:
|
||||
require "calendar/version"
|
||||
dir_pwd = ENV['PWD']
|
||||
template_path = dir_pwd + '/app/templates'
|
||||
app_path = File.expand_path(__dir__)
|
||||
all_template = Dir.glob(template_path+'/*/')
|
||||
bundle_update_flag = ARGV[0]=='update' || ARGV[0]=='install'
|
||||
if bundle_update_flag
|
||||
dir_pwd = ENV['PWD']
|
||||
template_path = dir_pwd + '/app/templates'
|
||||
app_path = File.expand_path(__dir__)
|
||||
all_template = Dir.glob(template_path+'/*/')
|
||||
|
||||
puts 'copying calendar module'
|
||||
all_template.each do |folder|
|
||||
if folder.split('/')[-1] != 'mobile'
|
||||
begin
|
||||
system ('cp -r '+ app_path + '/modules/ ' + folder)
|
||||
rescue
|
||||
puts 'error copy'
|
||||
puts 'copying calendar module'
|
||||
all_template.each do |folder|
|
||||
if folder.split('/')[-1] != 'mobile'
|
||||
begin
|
||||
system ('cp -r '+ app_path + '/modules/ ' + folder)
|
||||
rescue
|
||||
puts 'error copy'
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,5 +1,27 @@
|
|||
en:
|
||||
calendar:
|
||||
date_type: "Date Type"
|
||||
today: "Today"
|
||||
sunday_first: "Sunday First"
|
||||
enable: Enable
|
||||
from: "From"
|
||||
to: "To"
|
||||
calendar_mode: "Calendar Mode"
|
||||
mode:
|
||||
day: "Day"
|
||||
week: "week"
|
||||
month: "Month"
|
||||
agenda: "Agenda"
|
||||
day_of_the_week: "Day of the week"
|
||||
day:
|
||||
"0": "Sunday"
|
||||
"1": "Monday"
|
||||
"2": "Tuesday"
|
||||
"3": "Wednesday"
|
||||
"4": "Thursday"
|
||||
"5": "Friday"
|
||||
"6": "Saturday"
|
||||
calendar_setting: Calendar Setting
|
||||
press_enter: Press enter to add a newline
|
||||
all: All
|
||||
calendar: Calendar
|
||||
|
|
|
@ -1,5 +1,27 @@
|
|||
zh_tw:
|
||||
calendar:
|
||||
date_type: "日期格式"
|
||||
today: "今日"
|
||||
sunday_first: "週日先"
|
||||
enable: 啟用
|
||||
from: "從"
|
||||
to: "到"
|
||||
calendar_mode: "行事曆模式"
|
||||
mode:
|
||||
day: "日曆"
|
||||
week: "週曆"
|
||||
month: "月曆"
|
||||
agenda: "日程"
|
||||
day_of_the_week: "星期幾"
|
||||
day:
|
||||
"0": "週日"
|
||||
"1": "週一"
|
||||
"2": "週二"
|
||||
"3": "週三"
|
||||
"4": "週四"
|
||||
"5": "週五"
|
||||
"6": "週六"
|
||||
calendar_setting: 行事曆設定
|
||||
press_enter: 按下enter可以換行
|
||||
calendar: 行事曆
|
||||
calendars: 我的行事曆
|
||||
|
|
|
@ -6,6 +6,8 @@ Rails.application.routes.draw do
|
|||
s = Site.first
|
||||
update_flag = s.respond_to?(:tmp_flags)
|
||||
need_update = !update_flag || !(s.tmp_flags.include?('cf1'))
|
||||
calendar_setting = CalendarSetting.first
|
||||
calendar_setting = CalendarSetting.create if calendar_setting.nil?
|
||||
if need_update
|
||||
Event.where(:title_translations.in=>[nil,{}]).each do |e|
|
||||
e.title_translations = locales.map{|l| [l.to_s, e[:title]]}.to_h
|
||||
|
@ -31,7 +33,13 @@ Rails.application.routes.draw do
|
|||
scope "(:locale)", locale: Regexp.new(locales.join("|")) do
|
||||
namespace :admin do
|
||||
get "/calendars/agenda" => "calendars#agenda"
|
||||
resources :calendars
|
||||
resources :calendars do
|
||||
collection do
|
||||
get 'calendar_setting'
|
||||
post 'update_calendar_setting'
|
||||
patch 'update_calendar_setting'
|
||||
end
|
||||
end
|
||||
resources :calendar_types
|
||||
end
|
||||
|
||||
|
|
|
@ -28,6 +28,11 @@ module Calendar
|
|||
:priority=>2,
|
||||
:active_for_action=>{'admin/calendar_types'=>'index'},
|
||||
:available_for => 'managers'
|
||||
context_link 'calendar.calendar_setting',
|
||||
:link_path=>"calendar_setting_admin_calendars_path" ,
|
||||
:priority=>3,
|
||||
:active_for_action=>{'admin/calendars'=>'calendar_setting'},
|
||||
:available_for => 'managers'
|
||||
context_link 'tags',
|
||||
:link_path=>"admin_module_app_tags_path" ,
|
||||
:link_arg=>"{:module_app_id=>ModuleApp.find_by(:key=>'calendar').id}",
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
<button class="btn btn-default btn-sm" id="next_month_btn">
|
||||
<i class="icon-chevron-right"></i>
|
||||
</button>
|
||||
<button class="btn btn-default btn-sm" id="today_btn">Today</button>
|
||||
<button class="btn btn-default btn-sm" id="today_btn"><%=t('calendar.today')%></button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -17,10 +17,9 @@
|
|||
</div>
|
||||
<div id='sec3' class="btn-toolbar">
|
||||
<div class="btn-group calendar_mode">
|
||||
<button class="btn btn-default mode_switch btn-sm" data-mode="agendaDay" >day</button>
|
||||
<button class="btn btn-default mode_switch btn-sm" data-mode="agendaWeek" >week</button>
|
||||
<button class="btn btn-default active mode_switch btn-sm" data-mode="month" >month</button>
|
||||
<button class="btn btn-default mode_switch btn-sm" data-mode="agenda" >agenda</button>
|
||||
<div data-list="modes_info" data-level="0">
|
||||
<button class="btn btn-default mode_switch btn-sm {{active_class}}" data-mode="{{mode}}" >{{trans}}</button>
|
||||
</div>
|
||||
</div>
|
||||
<button id="refresh_btn" class="btn btn-default btn-sm">
|
||||
<i class="icons-cycle"></i>
|
||||
|
|
Loading…
Reference in New Issue