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;
|
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){
|
$.fn.fullCalendar = function(args){
|
||||||
var self = this[0]
|
var self = this[0]
|
||||||
if(!self.calendar_args)
|
if(!self.calendar_args)
|
||||||
|
@ -60,41 +109,40 @@ FullCalendar.Calendar.prototype.isAnOverlapEvent = function(eventStartDay, event
|
||||||
}
|
}
|
||||||
return false;
|
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) {
|
window.getDateString = function(date, format, is_chinese) {
|
||||||
var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
|
var months = calendar_variable.months;
|
||||||
var week_days = ['Sun','Mon','Tue','Wed','Thu','Fri','Sat'];
|
var week_days = calendar_variable.dayNames;
|
||||||
if(is_chinese){
|
|
||||||
months = [];
|
|
||||||
for(var i=0;i<12;i++){
|
|
||||||
months.push((i+1)+"月");
|
|
||||||
}
|
|
||||||
week_days = ["週日","週一","週二","週三","週四","週五","週六"]
|
|
||||||
}
|
|
||||||
var getPaddedComp = function(comp) {
|
var getPaddedComp = function(comp) {
|
||||||
return ((parseInt(comp) < 10) ? ('0' + comp) : comp)
|
return ((parseInt(comp) < 10) ? ('0' + comp) : comp)
|
||||||
},
|
},
|
||||||
formattedDate = format,
|
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 = {
|
o = {
|
||||||
"y+": date.getFullYear() + (is_chinese ? "年" : ""), // year
|
"yy+": y, //raw year
|
||||||
"MM+": getPaddedComp(date.getMonth() + 1), //raw month
|
"y+": y + (calendar_variable.is_chinese ? "年" : ""), // year
|
||||||
"M+": months[date.getMonth()], //month
|
"MMM+": month_name, //month
|
||||||
"d+": (is_chinese ? (date.getDate() + "日") : getPaddedComp(date.getDate())), //day
|
"MM+": getPaddedComp(m + 1), //raw month
|
||||||
"w+": week_days[date.getDay()], //weekday
|
"M+": month_name.substring(0,3), //month
|
||||||
"h+": getPaddedComp((date.getHours() > 12) ? date.getHours() % 12 : date.getHours()), //hour
|
"dd+": getPaddedComp(d), //raw day
|
||||||
"H+": getPaddedComp(date.getHours()), //hour
|
"d+": (calendar_variable.is_chinese ? (d + "日") : getPaddedComp(d)), //day
|
||||||
"m+": getPaddedComp(date.getMinutes()), //minute
|
"W+": week_days[date.getDay()], //weekday
|
||||||
"s+": getPaddedComp(date.getSeconds()), //second
|
"w+": (calendar_variable.is_chinese ? week_days[date.getDay()].substr(-1, 1) : week_days[date.getDay()].substr(0, 3)), //weekday
|
||||||
"S+": getPaddedComp(date.getMilliseconds()), //millisecond,
|
"h+": getPaddedComp((H > 12) ? H % 12 : H), //hour
|
||||||
"b+": (date.getHours() >= 12) ? 'PM' : 'AM'
|
"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) {
|
for (var k in o) {
|
||||||
|
@ -306,10 +354,33 @@ var Calendar = function(dom){
|
||||||
originalEvent = eventClickInfo.jsEvent,
|
originalEvent = eventClickInfo.jsEvent,
|
||||||
view = eventClickInfo.view,
|
view = eventClickInfo.view,
|
||||||
el = $(eventClickInfo.el);
|
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);
|
||||||
|
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.event_create_space.html("").hide();
|
||||||
c.dialog.dismiss();
|
c.dialog.dismiss();
|
||||||
c.dialog.inflate(calEvent);
|
c.dialog.inflate(calEvent);
|
||||||
c.dialog.show({"x": originalEvent.clientX,"y": originalEvent.clientY});
|
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")){
|
||||||
|
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){
|
select : function(selectionInfo){
|
||||||
var jsEvent = selectionInfo.jsEvent,
|
var jsEvent = selectionInfo.jsEvent,
|
||||||
|
@ -338,10 +409,37 @@ var Calendar = function(dom){
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
views: {
|
views: {
|
||||||
|
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: {
|
dayGridMonth: {
|
||||||
dayMaxEvents: false
|
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(){
|
c.create_event_btn.click(function(){
|
||||||
$.ajax({
|
$.ajax({
|
||||||
|
@ -356,14 +454,17 @@ var Calendar = function(dom){
|
||||||
c.nextBtn.click(function(){
|
c.nextBtn.click(function(){
|
||||||
c.dialog.dismiss();
|
c.dialog.dismiss();
|
||||||
c.calendar_dom.calendar.next();
|
c.calendar_dom.calendar.next();
|
||||||
|
c.title.text(c.calendar_dom.calendar.currentData.viewTitle);
|
||||||
});
|
});
|
||||||
c.prevBtn.click(function(){
|
c.prevBtn.click(function(){
|
||||||
c.dialog.dismiss();
|
c.dialog.dismiss();
|
||||||
c.calendar_dom.calendar.prev();
|
c.calendar_dom.calendar.prev();
|
||||||
|
c.title.text(c.calendar_dom.calendar.currentData.viewTitle);
|
||||||
});
|
});
|
||||||
c.todayBtn.click(function(){
|
c.todayBtn.click(function(){
|
||||||
c.dialog.dismiss();
|
c.dialog.dismiss();
|
||||||
c.calendar_dom.calendar.today();
|
c.calendar_dom.calendar.today();
|
||||||
|
c.title.text(c.calendar_dom.calendar.currentData.viewTitle);
|
||||||
});
|
});
|
||||||
c.modeBtns.click(function(){
|
c.modeBtns.click(function(){
|
||||||
c.dialog.dismiss();
|
c.dialog.dismiss();
|
||||||
|
@ -404,13 +505,8 @@ var Calendar = function(dom){
|
||||||
c.calendar_dom.calendar.refetchEvents();
|
c.calendar_dom.calendar.refetchEvents();
|
||||||
loadeventsonviewchange = false;
|
loadeventsonviewchange = false;
|
||||||
}
|
}
|
||||||
if(c.calendar_dom.calendar.currentData){
|
c.title.text(c.calendar_dom.calendar.currentData.viewTitle);
|
||||||
var viewTitle = c.calendar_dom.calendar.currentData.viewTitle;
|
// c.calendar_dom.calendar.rerenderEvents(); //Rerender to fix layout
|
||||||
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
|
|
||||||
};
|
};
|
||||||
if(c.currentView == "agenda"){toggleViews("agenda");loadeventsonviewchange = true;}
|
if(c.currentView == "agenda"){toggleViews("agenda");loadeventsonviewchange = true;}
|
||||||
};
|
};
|
||||||
|
@ -464,11 +560,8 @@ var EventDialog = function(calendar,event){
|
||||||
_event.allDay = _event.event.allDay;
|
_event.allDay = _event.event.allDay;
|
||||||
_event._start = _event.event.start;
|
_event._start = _event.event.start;
|
||||||
_event._end = (_event.event.end ? _event.event.end : _event.event.start);
|
_event._end = (_event.event.end ? _event.event.end : _event.event.start);
|
||||||
// var start_date = getDateString(_event._start,date_format);
|
// var start_date = getDateString(_event._start,calendar_variable.date_format);
|
||||||
// var end_date = getDateString(_event._end,date_format);
|
// var end_date = getDateString(_event._end,calendar_variable.date_format);
|
||||||
if(_event._end - _event._start > 86400 * 1000){
|
|
||||||
_event.allDay = true;
|
|
||||||
}
|
|
||||||
_event.title = _event.event.title;
|
_event.title = _event.event.title;
|
||||||
var extendedProps = _event.event.extendedProps;
|
var extendedProps = _event.event.extendedProps;
|
||||||
Object.keys(extendedProps).forEach(function(k){
|
Object.keys(extendedProps).forEach(function(k){
|
||||||
|
@ -481,15 +574,15 @@ var EventDialog = function(calendar,event){
|
||||||
end_time = "",
|
end_time = "",
|
||||||
time_string = null;
|
time_string = null;
|
||||||
if(_event.allDay) {
|
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)
|
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 + "");
|
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 {
|
} else {
|
||||||
start_time = getDateString(_event._start,date_format, is_chinese);
|
start_time = getDateString(_event._start,calendar_variable.date_format_with_short_month);
|
||||||
end_time = getDateString(_event._end,date_format, is_chinese);
|
end_time = getDateString(_event._end,calendar_variable.date_format_with_short_month);
|
||||||
var stime = getDateString(_event._start,time_format, is_chinese),
|
var stime = getDateString(_event._start,time_format),
|
||||||
etime = getDateString(_event._end,time_format, is_chinese),
|
etime = getDateString(_event._end,time_format),
|
||||||
same = (start_time == end_time);
|
same = (start_time == end_time);
|
||||||
if( same ){
|
if( same ){
|
||||||
time_string = "<p class='date'><i class='icons-calendar' /></i> " +
|
time_string = "<p class='date'><i class='icons-calendar' /></i> " +
|
||||||
|
@ -507,7 +600,7 @@ var EventDialog = function(calendar,event){
|
||||||
template = '<div class="modal-content">' +
|
template = '<div class="modal-content">' +
|
||||||
'<div class="modal-header">' +
|
'<div class="modal-header">' +
|
||||||
'<button type="button" class="close event-close-btn" data-dismiss="modal" aria-hidden="true">×</button>' +
|
'<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>' +
|
||||||
'<div class="modal-body">' +
|
'<div class="modal-body">' +
|
||||||
'<div class="event_summary">' + time_string + '</br>' + _event.hiring_person_name + '</div>' + _event.note +
|
'<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 start_year = today.getFullYear();
|
||||||
var end_month = ((start_month + minDifference) > 11 ? (start_month + minDifference) - 11 : start_month + minDifference);
|
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 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">' +
|
var month_template = '<div class="col-md-4">' +
|
||||||
'<h4></h4>' +
|
'<h4></h4>' +
|
||||||
'<div class="tiny_calendar">' +
|
'<div class="tiny_calendar">' +
|
||||||
'<table class="table table-condensed table-bordered">' +
|
'<table class="table table-condensed table-bordered">' +
|
||||||
'<tbody>' +
|
'<tbody>' +
|
||||||
'<tr>' +
|
'<tr>' +
|
||||||
'<th class="week_title">Sun</th>' +
|
calendar_variable.dayNamesShort.map(function(title){
|
||||||
'<th class="week_title">Mon</th>' +
|
return '<th class="week_title">'+title+'</th>';
|
||||||
'<th class="week_title">Tue</th>' +
|
}).join('') +
|
||||||
'<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>' +
|
'</tr>' +
|
||||||
'</tbody>' +
|
'</tbody>' +
|
||||||
'</table>' +
|
'</table>' +
|
||||||
|
@ -639,10 +728,8 @@ var AgendaView = function(calendar){
|
||||||
'<table class="table table-condensed table-bordered event_list">' +
|
'<table class="table table-condensed table-bordered event_list">' +
|
||||||
'<thead>' +
|
'<thead>' +
|
||||||
'<tr>' +
|
'<tr>' +
|
||||||
'<th>Date</th>' +
|
'<th>DateTime</th>' +
|
||||||
'<th>Time</th>' +
|
|
||||||
'<th>Events</th>' +
|
'<th>Events</th>' +
|
||||||
'<th>Borrower</th>' +
|
|
||||||
'</tr>' +
|
'</tr>' +
|
||||||
'</thead>' +
|
'</thead>' +
|
||||||
'<tbody>' +
|
'<tbody>' +
|
||||||
|
@ -654,20 +741,18 @@ var AgendaView = function(calendar){
|
||||||
'</div>';
|
'</div>';
|
||||||
|
|
||||||
var head_template = '<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">'+
|
'<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">'+
|
'<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>' +
|
'<button id="show_events" class="btn btn-sm bt-filter btn-primary">Show Events</button>' +
|
||||||
'</div>';
|
'</div>';
|
||||||
|
|
||||||
var event_template = '<tr>' +
|
var event_template = '<tr>' +
|
||||||
'<td />' +
|
'<td class="event_datetime" />' +
|
||||||
'<td class="event_time" />' +
|
|
||||||
'<td>' +
|
'<td>' +
|
||||||
'<div class="event" />' +
|
'<div class="event" />' +
|
||||||
'</td>' +
|
'</td>' +
|
||||||
'<td class="Borrower">'+
|
|
||||||
'</tr>';
|
'</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>';
|
// 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",
|
type : "get",
|
||||||
url : url,
|
url : url,
|
||||||
dataType : "json",
|
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){
|
success : function(data){
|
||||||
|
console.log(data)
|
||||||
$("#agenda_start,#agenda_end").datepicker({
|
$("#agenda_start,#agenda_end").datepicker({
|
||||||
dateFormat: "yy/mm",
|
dateFormat: "yy/mm",
|
||||||
onChangeMonthYear: function( year, month, inst ){
|
onChangeMonthYear: function( year, month, inst ){
|
||||||
|
@ -850,16 +936,21 @@ var AgendaView = function(calendar){
|
||||||
var e_t = $(event_template),
|
var e_t = $(event_template),
|
||||||
s = new Date(event.start),
|
s = new Date(event.start),
|
||||||
e = new Date(event.end),
|
e = new Date(event.end),
|
||||||
dateFormat = "",
|
datetimeFormat = "";
|
||||||
hiring_person_name = event.hiring_person_name;
|
if(s.getDate() == e.getDate() && s.getMonth() == s.getMonth() && e.getFullYear() == e.getFullYear()){
|
||||||
if(s.getDate() == e.getDate() && s.getMonth() == s.getMonth() && e.getFullYear() == e.getFullYear())
|
datetimeFormat = getDateString(s, calendar_variable.short_day);
|
||||||
dateFormat = getDateString(s, short_day,is_chinese);
|
if(!event.allDay){
|
||||||
else
|
datetimeFormat += (' ' + getDateString(s,time_format) + ' - ' + getDateString(e,time_format));
|
||||||
dateFormat = getDateString(s,short_date,is_chinese) + ' - ' + getDateString(e,short_date,is_chinese);
|
}
|
||||||
e_t.find("td:first").text(dateFormat);
|
}else{
|
||||||
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))));
|
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("div.event").html(event.title).css("color",event.color);
|
||||||
e_t.find("td.Borrower").text(hiring_person_name);
|
|
||||||
return e_t;
|
return e_t;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -918,7 +1009,8 @@ var AgendaView = function(calendar){
|
||||||
var last_inserted_date = 1;
|
var last_inserted_date = 1;
|
||||||
|
|
||||||
var renderMonth = function(){
|
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++){
|
for(var i = 0; i < num_of_rows; i++){
|
||||||
var tr = null;
|
var tr = null;
|
||||||
if(i == 0)
|
if(i == 0)
|
||||||
|
@ -931,9 +1023,9 @@ var AgendaView = function(calendar){
|
||||||
if(tr == null){
|
if(tr == null){
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
template.find("table.table tbody").append(tr);
|
tbody.append(tr);
|
||||||
template.find("h4").text(monthNames[firstDay.getMonth()] + " - " + firstDay.getFullYear());
|
|
||||||
}
|
}
|
||||||
|
template.find("h4").text(getDateString(firstDay, calendar_variable.month_year_format));
|
||||||
_this.monthDom.append(template);
|
_this.monthDom.append(template);
|
||||||
_this.monthDom.append(list_template);
|
_this.monthDom.append(list_template);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,53 @@
|
||||||
window.auto_close_popup = false;
|
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){
|
$.fn.fullCalendar = function(args){
|
||||||
var self = this[0]
|
var self = this[0]
|
||||||
if(!self.calendar_args)
|
if(!self.calendar_args)
|
||||||
|
@ -60,41 +109,40 @@ FullCalendar.Calendar.prototype.isAnOverlapEvent = function(eventStartDay, event
|
||||||
}
|
}
|
||||||
return false;
|
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) {
|
window.getDateString = function(date, format, is_chinese) {
|
||||||
var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
|
var months = calendar_variable.months;
|
||||||
var week_days = ['Sun','Mon','Tue','Wed','Thu','Fri','Sat'];
|
var week_days = calendar_variable.dayNames;
|
||||||
if(is_chinese){
|
|
||||||
months = [];
|
|
||||||
for(var i=0;i<12;i++){
|
|
||||||
months.push((i+1)+"月");
|
|
||||||
}
|
|
||||||
week_days = ["週日","週一","週二","週三","週四","週五","週六"]
|
|
||||||
}
|
|
||||||
var getPaddedComp = function(comp) {
|
var getPaddedComp = function(comp) {
|
||||||
return ((parseInt(comp) < 10) ? ('0' + comp) : comp)
|
return ((parseInt(comp) < 10) ? ('0' + comp) : comp)
|
||||||
},
|
},
|
||||||
formattedDate = format,
|
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 = {
|
o = {
|
||||||
"y+": date.getFullYear() + (is_chinese ? "年" : ""), // year
|
"yy+": y, //raw year
|
||||||
"MM+": getPaddedComp(date.getMonth() + 1), //raw month
|
"y+": y + (calendar_variable.is_chinese ? "年" : ""), // year
|
||||||
"M+": months[date.getMonth()], //month
|
"MMM+": month_name, //month
|
||||||
"d+": (is_chinese ? (date.getDate() + "日") : getPaddedComp(date.getDate())), //day
|
"MM+": getPaddedComp(m + 1), //raw month
|
||||||
"w+": week_days[date.getDay()], //weekday
|
"M+": month_name.substring(0,3), //month
|
||||||
"h+": getPaddedComp((date.getHours() > 12) ? date.getHours() % 12 : date.getHours()), //hour
|
"dd+": getPaddedComp(d), //raw day
|
||||||
"H+": getPaddedComp(date.getHours()), //hour
|
"d+": (calendar_variable.is_chinese ? (d + "日") : getPaddedComp(d)), //day
|
||||||
"m+": getPaddedComp(date.getMinutes()), //minute
|
"W+": week_days[date.getDay()], //weekday
|
||||||
"s+": getPaddedComp(date.getSeconds()), //second
|
"w+": (calendar_variable.is_chinese ? week_days[date.getDay()].substr(-1, 1) : week_days[date.getDay()].substr(0, 3)), //weekday
|
||||||
"S+": getPaddedComp(date.getMilliseconds()), //millisecond,
|
"h+": getPaddedComp((H > 12) ? H % 12 : H), //hour
|
||||||
"b+": (date.getHours() >= 12) ? 'PM' : 'AM'
|
"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) {
|
for (var k in o) {
|
||||||
|
@ -123,6 +171,7 @@ var Calendar = function(dom,page_id,event_date=''){
|
||||||
this.rangeSelection = $("#range_selection");
|
this.rangeSelection = $("#range_selection");
|
||||||
var agendaView = new AgendaView(c);
|
var agendaView = new AgendaView(c);
|
||||||
var loadeventsonviewchange = false;
|
var loadeventsonviewchange = false;
|
||||||
|
this.success_event = null;
|
||||||
this.initialize = function(){
|
this.initialize = function(){
|
||||||
if (event_date != ''){
|
if (event_date != ''){
|
||||||
var event_dates = event_date.split("-");
|
var event_dates = event_date.split("-");
|
||||||
|
@ -210,23 +259,52 @@ var Calendar = function(dom,page_id,event_date=''){
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
views: {
|
views: {
|
||||||
|
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: {
|
dayGridMonth: {
|
||||||
dayMaxEvents: false
|
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.nextBtn.click(function(){
|
||||||
c.dialog.dismiss();
|
c.dialog.dismiss();
|
||||||
c.calendar_dom.calendar.next();
|
c.calendar_dom.calendar.next();
|
||||||
|
c.title.text(c.calendar_dom.calendar.currentData.viewTitle);
|
||||||
});
|
});
|
||||||
c.prevBtn.click(function(){
|
c.prevBtn.click(function(){
|
||||||
c.dialog.dismiss();
|
c.dialog.dismiss();
|
||||||
c.calendar_dom.calendar.prev();
|
c.calendar_dom.calendar.prev();
|
||||||
|
c.title.text(c.calendar_dom.calendar.currentData.viewTitle);
|
||||||
});
|
});
|
||||||
c.todayBtn.click(function(){
|
c.todayBtn.click(function(){
|
||||||
c.dialog.dismiss();
|
c.dialog.dismiss();
|
||||||
c.calendar_dom.calendar.today();
|
c.calendar_dom.calendar.today();
|
||||||
|
c.title.text(c.calendar_dom.calendar.currentData.viewTitle);
|
||||||
});
|
});
|
||||||
c.modeBtns.click(function(){
|
c.modeBtns.click(function(){
|
||||||
c.dialog.dismiss();
|
c.dialog.dismiss();
|
||||||
|
@ -239,7 +317,6 @@ var Calendar = function(dom,page_id,event_date=''){
|
||||||
else
|
else
|
||||||
c.calendar_dom.calendar.refetchEvents();
|
c.calendar_dom.calendar.refetchEvents();
|
||||||
});
|
});
|
||||||
|
|
||||||
var toggleViews = function(view){
|
var toggleViews = function(view){
|
||||||
c.modeBtns.removeClass("active");
|
c.modeBtns.removeClass("active");
|
||||||
c.modeBtns.each(function(){
|
c.modeBtns.each(function(){
|
||||||
|
@ -265,13 +342,8 @@ var Calendar = function(dom,page_id,event_date=''){
|
||||||
c.calendar_dom.calendar.refetchEvents();
|
c.calendar_dom.calendar.refetchEvents();
|
||||||
loadeventsonviewchange = false;
|
loadeventsonviewchange = false;
|
||||||
}
|
}
|
||||||
if(c.calendar_dom.calendar.currentData){
|
c.title.text(c.calendar_dom.calendar.currentData.viewTitle);
|
||||||
var viewTitle = c.calendar_dom.calendar.currentData.viewTitle;
|
// c.calendar_dom.calendar.rerenderEvents(); //Rerender to fix layout
|
||||||
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
|
|
||||||
};
|
};
|
||||||
if(c.currentView == "agenda"){toggleViews("agenda");loadeventsonviewchange = true;}
|
if(c.currentView == "agenda"){toggleViews("agenda");loadeventsonviewchange = true;}
|
||||||
};
|
};
|
||||||
|
@ -325,11 +397,8 @@ var EventDialog = function(calendar,event){
|
||||||
_event.allDay = _event.event.allDay;
|
_event.allDay = _event.event.allDay;
|
||||||
_event._start = _event.event.start;
|
_event._start = _event.event.start;
|
||||||
_event._end = (_event.event.end ? _event.event.end : _event.event.start);
|
_event._end = (_event.event.end ? _event.event.end : _event.event.start);
|
||||||
// var start_date = getDateString(_event._start,date_format);
|
// var start_date = getDateString(_event._start,calendar_variable.date_format);
|
||||||
// var end_date = getDateString(_event._end,date_format);
|
// var end_date = getDateString(_event._end,calendar_variable.date_format);
|
||||||
if(_event._end - _event._start > 86400 * 1000){
|
|
||||||
_event.allDay = true;
|
|
||||||
}
|
|
||||||
_event.title = _event.event.title;
|
_event.title = _event.event.title;
|
||||||
var extendedProps = _event.event.extendedProps;
|
var extendedProps = _event.event.extendedProps;
|
||||||
Object.keys(extendedProps).forEach(function(k){
|
Object.keys(extendedProps).forEach(function(k){
|
||||||
|
@ -342,15 +411,15 @@ var EventDialog = function(calendar,event){
|
||||||
end_time = "",
|
end_time = "",
|
||||||
time_string = null;
|
time_string = null;
|
||||||
if(_event.allDay) {
|
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)
|
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 + "");
|
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 {
|
} else {
|
||||||
start_time = getDateString(_event._start,date_format, is_chinese);
|
start_time = getDateString(_event._start,calendar_variable.date_format_with_short_month);
|
||||||
end_time = getDateString(_event._end,date_format, is_chinese);
|
end_time = getDateString(_event._end,calendar_variable.date_format_with_short_month);
|
||||||
var stime = getDateString(_event._start,time_format, is_chinese),
|
var stime = getDateString(_event._start,time_format),
|
||||||
etime = getDateString(_event._end,time_format, is_chinese),
|
etime = getDateString(_event._end,time_format),
|
||||||
same = (start_time == end_time);
|
same = (start_time == end_time);
|
||||||
if( same ){
|
if( same ){
|
||||||
time_string = "<p class='date'><i class='icons-calendar' /></i> " +
|
time_string = "<p class='date'><i class='icons-calendar' /></i> " +
|
||||||
|
@ -470,20 +539,16 @@ var AgendaView = function(calendar){
|
||||||
var start_year = today.getFullYear();
|
var start_year = today.getFullYear();
|
||||||
var end_month = ((start_month + minDifference) > 11 ? (start_month + minDifference) - 11 : start_month + minDifference);
|
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 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">' +
|
var month_template = '<div class="col-md-4">' +
|
||||||
'<h4></h4>' +
|
'<h4></h4>' +
|
||||||
'<div class="tiny_calendar">' +
|
'<div class="tiny_calendar">' +
|
||||||
'<table class="table table-condensed table-bordered">' +
|
'<table class="table table-condensed table-bordered">' +
|
||||||
'<tbody>' +
|
'<tbody>' +
|
||||||
'<tr>' +
|
'<tr>' +
|
||||||
'<th class="week_title">Sun</th>' +
|
calendar_variable.dayNamesShort.map(function(title){
|
||||||
'<th class="week_title">Mon</th>' +
|
return '<th class="week_title">'+title+'</th>';
|
||||||
'<th class="week_title">Tue</th>' +
|
}).join('') +
|
||||||
'<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>' +
|
'</tr>' +
|
||||||
'</tbody>' +
|
'</tbody>' +
|
||||||
'</table>' +
|
'</table>' +
|
||||||
|
@ -494,10 +559,8 @@ var AgendaView = function(calendar){
|
||||||
'<table class="table table-condensed table-bordered event_list">' +
|
'<table class="table table-condensed table-bordered event_list">' +
|
||||||
'<thead>' +
|
'<thead>' +
|
||||||
'<tr>' +
|
'<tr>' +
|
||||||
'<th>Date</th>' +
|
'<th>DateTime</th>' +
|
||||||
'<th>Time</th>' +
|
|
||||||
'<th>Events</th>' +
|
'<th>Events</th>' +
|
||||||
'<th>Borrower</th>' +
|
|
||||||
'</tr>' +
|
'</tr>' +
|
||||||
'</thead>' +
|
'</thead>' +
|
||||||
'<tbody>' +
|
'<tbody>' +
|
||||||
|
@ -509,20 +572,18 @@ var AgendaView = function(calendar){
|
||||||
'</div>';
|
'</div>';
|
||||||
|
|
||||||
var head_template = '<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">'+
|
'<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">'+
|
'<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>' +
|
'<button id="show_events" class="btn btn-sm bt-filter btn-primary">Show Events</button>' +
|
||||||
'</div>';
|
'</div>';
|
||||||
|
|
||||||
var event_template = '<tr>' +
|
var event_template = '<tr>' +
|
||||||
'<td />' +
|
'<td class="event_datetime" />' +
|
||||||
'<td class="event_time" />' +
|
|
||||||
'<td>' +
|
'<td>' +
|
||||||
'<div class="event" />' +
|
'<div class="event" />' +
|
||||||
'</td>' +
|
'</td>' +
|
||||||
'<td class="Borrower">'+
|
|
||||||
'</tr>';
|
'</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>';
|
// 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",
|
type : "get",
|
||||||
url : url,
|
url : url,
|
||||||
dataType : "json",
|
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){
|
success : function(data){
|
||||||
|
data = data.events;
|
||||||
$("#agenda_start,#agenda_end").datepicker({
|
$("#agenda_start,#agenda_end").datepicker({
|
||||||
dateFormat: "yy/mm",
|
dateFormat: "yy/mm",
|
||||||
onChangeMonthYear: function( year, month, inst ){
|
onChangeMonthYear: function( year, month, inst ){
|
||||||
|
@ -705,16 +767,24 @@ var AgendaView = function(calendar){
|
||||||
var e_t = $(event_template),
|
var e_t = $(event_template),
|
||||||
s = new Date(event.start),
|
s = new Date(event.start),
|
||||||
e = new Date(event.end),
|
e = new Date(event.end),
|
||||||
dateFormat = "",
|
datetimeFormat = "";
|
||||||
hiring_person_name = event.hiring_person_name;
|
if(s.getDate() == e.getDate() && s.getMonth() == s.getMonth() && e.getFullYear() == e.getFullYear()){
|
||||||
if(s.getDate() == e.getDate() && s.getMonth() == s.getMonth() && e.getFullYear() == e.getFullYear())
|
datetimeFormat = getDateString(s, calendar_variable.short_day);
|
||||||
dateFormat = getDateString(s, short_day,is_chinese);
|
if(!event.allDay){
|
||||||
else
|
datetimeFormat += (' ' + getDateString(s,time_format) + ' - ' + getDateString(e,time_format));
|
||||||
dateFormat = getDateString(s,short_date,is_chinese) + ' - ' + getDateString(e,short_date,is_chinese);
|
}
|
||||||
e_t.find("td:first").text(dateFormat);
|
}else{
|
||||||
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))));
|
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("div.event").html(event.title).css("color",event.color);
|
||||||
e_t.find("td.Borrower").text(hiring_person_name);
|
|
||||||
return e_t;
|
return e_t;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -773,7 +843,8 @@ var AgendaView = function(calendar){
|
||||||
var last_inserted_date = 1;
|
var last_inserted_date = 1;
|
||||||
|
|
||||||
var renderMonth = function(){
|
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++){
|
for(var i = 0; i < num_of_rows; i++){
|
||||||
var tr = null;
|
var tr = null;
|
||||||
if(i == 0)
|
if(i == 0)
|
||||||
|
@ -786,9 +857,9 @@ var AgendaView = function(calendar){
|
||||||
if(tr == null){
|
if(tr == null){
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
template.find("table.table tbody").append(tr);
|
tbody.append(tr);
|
||||||
template.find("h4").text(monthNames[firstDay.getMonth()] + " - " + firstDay.getFullYear());
|
|
||||||
}
|
}
|
||||||
|
template.find("h4").text(getDateString(firstDay, calendar_variable.month_year_format));
|
||||||
_this.monthDom.append(template);
|
_this.monthDom.append(template);
|
||||||
_this.monthDom.append(list_template);
|
_this.monthDom.append(list_template);
|
||||||
}
|
}
|
||||||
|
|
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
|
# GET /events.json
|
||||||
|
|
||||||
def index
|
def index
|
||||||
|
@calendar_setting = CalendarSetting.first
|
||||||
@events = []
|
@events = []
|
||||||
tags = @module_app.tags
|
tags = @module_app.tags
|
||||||
categories = CalendarType.all
|
categories = CalendarType.all
|
||||||
|
@ -165,6 +166,14 @@ class Admin::CalendarsController < OrbitAdminController
|
||||||
# end
|
# end
|
||||||
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
|
private
|
||||||
def event_page_params
|
def event_page_params
|
||||||
params.require(:event).permit!
|
params.require(:event).permit!
|
||||||
|
|
|
@ -6,7 +6,10 @@ class CalendarsController < ApplicationController
|
||||||
def index
|
def index
|
||||||
page = Page.where(page_id: OrbitHelper.params[:page_id]).first
|
page = Page.where(page_id: OrbitHelper.params[:page_id]).first
|
||||||
style_file = page.layout=='index3' ? '/assets/calendar_widget2' : '/assets/calendar_widget1'
|
style_file = page.layout=='index3' ? '/assets/calendar_widget2' : '/assets/calendar_widget1'
|
||||||
|
@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" => {
|
"extras" => {
|
||||||
"page_id" => OrbitHelper.params[:page_id],
|
"page_id" => OrbitHelper.params[:page_id],
|
||||||
'widget_title' => page.name,
|
'widget_title' => page.name,
|
||||||
|
@ -29,7 +32,10 @@ class CalendarsController < ApplicationController
|
||||||
|
|
||||||
def widget
|
def widget
|
||||||
part = OrbitHelper.get_current_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" => {
|
"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,
|
||||||
|
@ -84,7 +90,7 @@ class CalendarsController < ApplicationController
|
||||||
events = event.agenda_events(agenda_start,agenda_end)
|
events = event.agenda_events(agenda_start,agenda_end)
|
||||||
end
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -109,7 +115,7 @@ class CalendarsController < ApplicationController
|
||||||
events = event.agenda_events(agenda_start,agenda_end)
|
events = event.agenda_events(agenda_start,agenda_end)
|
||||||
end
|
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
|
||||||
end
|
end
|
||||||
def get_calendar_title(now_date=nil)
|
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' %>
|
||||||
|
<%#= javascript_include_tag 'fullcalendar_moment.min' %>
|
||||||
<%= javascript_include_tag 'calendar' %>
|
<%= javascript_include_tag 'calendar' %>
|
||||||
<%= javascript_include_tag 'validator' %>
|
<%= javascript_include_tag 'validator' %>
|
||||||
|
|
||||||
<%= stylesheet_link_tag "fullcalendar"%>
|
<%= stylesheet_link_tag "fullcalendar"%>
|
||||||
<%= stylesheet_link_tag "calendar"%>
|
<%= stylesheet_link_tag "calendar"%>
|
||||||
<%= render_filter @filter_fields, "view_holder" %>
|
<%= render_filter @filter_fields, "view_holder" %>
|
||||||
|
<style type="text/css">
|
||||||
|
.row{
|
||||||
|
margin-left: 0;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
<div id="orbit_calendar" class="month_view">
|
<div id="orbit_calendar" class="month_view">
|
||||||
<div class="clearfix cal-fn">
|
<div class="clearfix cal-fn">
|
||||||
<div id='sec2'>
|
<div id='sec2'>
|
||||||
|
@ -14,7 +24,7 @@
|
||||||
<div class="btn-toolbar" id="navigation">
|
<div class="btn-toolbar" id="navigation">
|
||||||
<div id="calendar-nav">
|
<div id="calendar-nav">
|
||||||
<div class="btn-group">
|
<div class="btn-group">
|
||||||
<button class="btn" id="today_btn">Today</button>
|
<button class="btn" id="today_btn"><%=t('calendar.today')%></button>
|
||||||
</div>
|
</div>
|
||||||
<div class="btn-group">
|
<div class="btn-group">
|
||||||
<button class="btn" id="prev_month_btn">
|
<button class="btn" id="prev_month_btn">
|
||||||
|
@ -31,10 +41,9 @@
|
||||||
<div class="pull-right" id='sec3'>
|
<div class="pull-right" id='sec3'>
|
||||||
<div class="btn-toolbar">
|
<div class="btn-toolbar">
|
||||||
<div class="btn-group calendar_mode">
|
<div class="btn-group calendar_mode">
|
||||||
<button class="btn mode_switch" data-mode="agendaDay" >day</button>
|
<%= @calendar_setting.get_modes_info.each_with_index do |(trans, mode), i| %>
|
||||||
<button class="btn mode_switch" data-mode="agendaWeek" >week</button>
|
<button class="btn btn-default mode_switch btn-sm <%= 'active' if i == 2 %>" data-mode="<%= mode %>" ><%= trans %></button>
|
||||||
<button class="btn active mode_switch" data-mode="month" >month</button>
|
<% end %>
|
||||||
<button class="btn mode_switch" data-mode="agenda" >agenda</button>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="btn-group">
|
<div class="btn-group">
|
||||||
<button id="refresh_btn" class="btn">
|
<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 'fullcalendar' %>
|
||||||
<%= javascript_include_tag 'calendar_frontend' %>
|
<%= javascript_include_tag 'calendar_frontend' %>
|
||||||
<%= stylesheet_link_tag "fullcalendar"%>
|
<%= stylesheet_link_tag "fullcalendar"%>
|
||||||
<%= stylesheet_link_tag "calendar"%>
|
<%= stylesheet_link_tag "calendar"%>
|
||||||
|
|
||||||
<%= render_view %>
|
<%= render_view %>
|
|
@ -2,6 +2,8 @@ $:.push File.expand_path("../lib", __FILE__)
|
||||||
|
|
||||||
# Maintain your gem's version:
|
# Maintain your gem's version:
|
||||||
require "calendar/version"
|
require "calendar/version"
|
||||||
|
bundle_update_flag = ARGV[0]=='update' || ARGV[0]=='install'
|
||||||
|
if bundle_update_flag
|
||||||
dir_pwd = ENV['PWD']
|
dir_pwd = ENV['PWD']
|
||||||
template_path = dir_pwd + '/app/templates'
|
template_path = dir_pwd + '/app/templates'
|
||||||
app_path = File.expand_path(__dir__)
|
app_path = File.expand_path(__dir__)
|
||||||
|
@ -17,6 +19,7 @@ all_template.each do |folder|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
# Describe your gem and declare its dependencies:
|
# Describe your gem and declare its dependencies:
|
||||||
Gem::Specification.new do |s|
|
Gem::Specification.new do |s|
|
||||||
s.name = "calendar"
|
s.name = "calendar"
|
||||||
|
|
|
@ -1,5 +1,27 @@
|
||||||
en:
|
en:
|
||||||
calendar:
|
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
|
press_enter: Press enter to add a newline
|
||||||
all: All
|
all: All
|
||||||
calendar: Calendar
|
calendar: Calendar
|
||||||
|
|
|
@ -1,5 +1,27 @@
|
||||||
zh_tw:
|
zh_tw:
|
||||||
calendar:
|
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可以換行
|
press_enter: 按下enter可以換行
|
||||||
calendar: 行事曆
|
calendar: 行事曆
|
||||||
calendars: 我的行事曆
|
calendars: 我的行事曆
|
||||||
|
|
|
@ -6,6 +6,8 @@ Rails.application.routes.draw do
|
||||||
s = Site.first
|
s = Site.first
|
||||||
update_flag = s.respond_to?(:tmp_flags)
|
update_flag = s.respond_to?(:tmp_flags)
|
||||||
need_update = !update_flag || !(s.tmp_flags.include?('cf1'))
|
need_update = !update_flag || !(s.tmp_flags.include?('cf1'))
|
||||||
|
calendar_setting = CalendarSetting.first
|
||||||
|
calendar_setting = CalendarSetting.create if calendar_setting.nil?
|
||||||
if need_update
|
if need_update
|
||||||
Event.where(:title_translations.in=>[nil,{}]).each do |e|
|
Event.where(:title_translations.in=>[nil,{}]).each do |e|
|
||||||
e.title_translations = locales.map{|l| [l.to_s, e[:title]]}.to_h
|
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
|
scope "(:locale)", locale: Regexp.new(locales.join("|")) do
|
||||||
namespace :admin do
|
namespace :admin do
|
||||||
get "/calendars/agenda" => "calendars#agenda"
|
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
|
resources :calendar_types
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -28,6 +28,11 @@ module Calendar
|
||||||
:priority=>2,
|
:priority=>2,
|
||||||
:active_for_action=>{'admin/calendar_types'=>'index'},
|
:active_for_action=>{'admin/calendar_types'=>'index'},
|
||||||
:available_for => 'managers'
|
: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',
|
context_link 'tags',
|
||||||
:link_path=>"admin_module_app_tags_path" ,
|
:link_path=>"admin_module_app_tags_path" ,
|
||||||
:link_arg=>"{:module_app_id=>ModuleApp.find_by(:key=>'calendar').id}",
|
: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">
|
<button class="btn btn-default btn-sm" id="next_month_btn">
|
||||||
<i class="icon-chevron-right"></i>
|
<i class="icon-chevron-right"></i>
|
||||||
</button>
|
</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>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -17,10 +17,9 @@
|
||||||
</div>
|
</div>
|
||||||
<div id='sec3' class="btn-toolbar">
|
<div id='sec3' class="btn-toolbar">
|
||||||
<div class="btn-group calendar_mode">
|
<div class="btn-group calendar_mode">
|
||||||
<button class="btn btn-default mode_switch btn-sm" data-mode="agendaDay" >day</button>
|
<div data-list="modes_info" data-level="0">
|
||||||
<button class="btn btn-default mode_switch btn-sm" data-mode="agendaWeek" >week</button>
|
<button class="btn btn-default mode_switch btn-sm {{active_class}}" data-mode="{{mode}}" >{{trans}}</button>
|
||||||
<button class="btn btn-default active mode_switch btn-sm" data-mode="month" >month</button>
|
</div>
|
||||||
<button class="btn btn-default mode_switch btn-sm" data-mode="agenda" >agenda</button>
|
|
||||||
</div>
|
</div>
|
||||||
<button id="refresh_btn" class="btn btn-default btn-sm">
|
<button id="refresh_btn" class="btn btn-default btn-sm">
|
||||||
<i class="icons-cycle"></i>
|
<i class="icons-cycle"></i>
|
||||||
|
|
Loading…
Reference in New Issue