|
|
|
@ -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);
|
|
|
|
|
|
|
|
|
|
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 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);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var makeRow = function(position){
|
|
|
|
|