parent
a2f4c13b61
commit
7ae2d1784b
|
@ -45,7 +45,7 @@ if(window.calendar_variable.date_type == 2){
|
|||
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.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){
|
||||
|
@ -111,46 +111,45 @@ FullCalendar.Calendar.prototype.isAnOverlapEvent = function(eventStartDay, event
|
|||
}
|
||||
|
||||
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 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){
|
||||
|
||||
|
@ -581,8 +580,8 @@ var EventDialog = function(calendar,event){
|
|||
} else {
|
||||
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),
|
||||
var stime = getDateString(_event._start,calendar_variable.time_format),
|
||||
etime = getDateString(_event._end,calendar_variable.time_format),
|
||||
same = (start_time == end_time);
|
||||
if( same ){
|
||||
time_string = "<p class='date'><i class='icons-calendar' /></i> " +
|
||||
|
@ -940,7 +939,7 @@ var AgendaView = function(calendar){
|
|||
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));
|
||||
datetimeFormat += (' ' + getDateString(s,calendar_variable.time_format) + ' - ' + getDateString(e,calendar_variable.time_format));
|
||||
}
|
||||
}else{
|
||||
if(event.allDay){
|
||||
|
|
|
@ -45,7 +45,7 @@ if(window.calendar_variable.date_type == 2){
|
|||
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.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){
|
||||
|
@ -111,46 +111,45 @@ FullCalendar.Calendar.prototype.isAnOverlapEvent = function(eventStartDay, event
|
|||
}
|
||||
|
||||
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 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=''){
|
||||
|
||||
|
@ -418,8 +417,8 @@ var EventDialog = function(calendar,event){
|
|||
} else {
|
||||
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),
|
||||
var stime = getDateString(_event._start,calendar_variable.time_format),
|
||||
etime = getDateString(_event._end,calendar_variable.time_format),
|
||||
same = (start_time == end_time);
|
||||
if( same ){
|
||||
time_string = "<p class='date'><i class='icons-calendar' /></i> " +
|
||||
|
@ -771,7 +770,7 @@ var AgendaView = function(calendar){
|
|||
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));
|
||||
datetimeFormat += (' ' + getDateString(s,calendar_variable.time_format) + ' - ' + getDateString(e,calendar_variable.time_format));
|
||||
}
|
||||
}else{
|
||||
console.log(event);
|
||||
|
|
|
@ -1,9 +1,98 @@
|
|||
var CalendarModuleMonth1 = function(date,dom,subpart,url,index_flag){
|
||||
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.calendar_variable.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");
|
||||
var CalendarModuleMonth1 = function(date,dom,subpart,url,index_flag){
|
||||
var 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;
|
||||
};
|
||||
_this = this;
|
||||
var events = {}
|
||||
var template = dom.find(".month_template"),
|
||||
month_names = ["Jan","Feb","March","April","May","June","July","Aug","Sep","Oct","Nov","Dec"],
|
||||
monthNames = ['January','February','March','April','May','June','July','August','September','October','November','December'],
|
||||
month_names = calendar_variable.months.map(function(m){ return m.substr(0,3);}),
|
||||
initialDate = date,
|
||||
subpartid = subpart,
|
||||
index_url = url,
|
||||
|
@ -23,11 +112,8 @@
|
|||
toggle_data;
|
||||
monthDom.html(template);
|
||||
var format_time = function(date){
|
||||
var hours = date.getHours(),
|
||||
minutes = date.getMinutes();
|
||||
if (hours < 10) {hours = "0"+hours}
|
||||
if (minutes < 10) {minutes = "0"+minutes}
|
||||
return hours+':'+minutes;
|
||||
date = new Date(date);
|
||||
return getDateString(date, window.calendar_variable.time_format);
|
||||
}
|
||||
function rgb2hex(rgb) {
|
||||
rgb = rgb.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/);
|
||||
|
@ -65,15 +151,11 @@
|
|||
return '#'+comp
|
||||
}
|
||||
var format_date = function(date){
|
||||
var y = date.getFullYear(),
|
||||
m = date.getMonth() + 1,
|
||||
d = date.getDate();
|
||||
if (m < 10) {m = "0"+m}
|
||||
if (d < 10) {d = "0"+d}
|
||||
return y+'/'+m+'/'+d;
|
||||
date = new Date(date);
|
||||
return getDateString(date, window.calendar_variable.date_format);
|
||||
}
|
||||
var formate_datetime = function(date){
|
||||
date = new Date(date)
|
||||
date = new Date(date);
|
||||
return [format_date(date),format_time(date)]
|
||||
}
|
||||
$(window).resize(function(){
|
||||
|
@ -182,7 +264,7 @@
|
|||
}
|
||||
var renderMonth = function(){
|
||||
var num_of_rows = getNumberOfRows(),
|
||||
head_title = monthDom.find("h4 span.text"),
|
||||
head_title = monthDom.find(".widget-title span.text"),
|
||||
table_body = monthDom.find("table.table tbody");
|
||||
table_body.html("");
|
||||
|
||||
|
@ -199,8 +281,8 @@
|
|||
break;
|
||||
}
|
||||
table_body.append(tr);
|
||||
head_title.text(monthNames[firstDay.getMonth()] + " " + firstDay.getFullYear());
|
||||
}
|
||||
head_title.text(getDateString(firstDay, calendar_variable.month_year_format));
|
||||
}
|
||||
|
||||
var getNumberOfRows = function() {
|
||||
|
|
|
@ -1,9 +1,98 @@
|
|||
var CalendarModuleMonth2 = function(date,dom,subpart,url,index_flag){
|
||||
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.calendar_variable.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");
|
||||
var CalendarModuleMonth2 = function(date,dom,subpart,url,index_flag){
|
||||
var 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;
|
||||
};
|
||||
_this = this;
|
||||
var events = {}
|
||||
var template = dom.find(".month_template"),
|
||||
month_names = ["Jan","Feb","March","April","May","June","July","Aug","Sep","Oct","Nov","Dec"],
|
||||
monthNames = ['January','February','March','April','May','June','July','August','September','October','November','December'],
|
||||
month_names = calendar_variable.months.map(function(m){ return m.substr(0,3);}),
|
||||
initialDate = date,
|
||||
subpartid = subpart,
|
||||
index_url = url,
|
||||
|
@ -31,11 +120,8 @@
|
|||
tp2;
|
||||
monthDom.html(template);
|
||||
var format_time = function(date){
|
||||
var hours = date.getHours(),
|
||||
minutes = date.getMinutes();
|
||||
if (hours < 10) {hours = "0"+hours}
|
||||
if (minutes < 10) {minutes = "0"+minutes}
|
||||
return hours+':'+minutes;
|
||||
date = new Date(date);
|
||||
return getDateString(date, window.calendar_variable.time_format);
|
||||
}
|
||||
function rgb2hex(rgb) {
|
||||
rgb = rgb.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/);
|
||||
|
@ -88,16 +174,12 @@
|
|||
return '#'+comp
|
||||
}
|
||||
var format_date = function(date){
|
||||
var y = date.getFullYear(),
|
||||
m = date.getMonth() + 1,
|
||||
d = date.getDate();
|
||||
if (m < 10) {m = "0"+m}
|
||||
if (d < 10) {d = "0"+d}
|
||||
return y+'/'+m+'/'+d;
|
||||
date = new Date(date);
|
||||
return getDateString(date, window.calendar_variable.date_format);
|
||||
}
|
||||
var formate_datetime = function(date){
|
||||
var format_datetime = function(date){
|
||||
date = new Date(date)
|
||||
return [format_date(date),format_time(date)]
|
||||
return getDateString(date, window.calendar_variable.datetime_format);
|
||||
}
|
||||
$(window).resize(function(){
|
||||
var window_w = $(window).width()
|
||||
|
@ -138,20 +220,20 @@
|
|||
var time_string = ''
|
||||
if(v.allDay) {
|
||||
var end_time
|
||||
var start_time = formate_datetime(v.start)[0]
|
||||
var start_time = format_date(v.start);
|
||||
if(v.end)
|
||||
end_time = formate_datetime(v.end)[0]
|
||||
end_time = format_date(v.end);
|
||||
else
|
||||
end_time = start_time
|
||||
end_time = start_time;
|
||||
time_string = (start_time==end_time ? "<p class='start-date'><i class='icons-calendar' /> " + start_time + "</p>" : "<i class='icons-calendar' /> " + start_time + " <i class='icons-arrow-right-5' /> " + end_time + "")
|
||||
}else{
|
||||
var st = formate_datetime(v.start),
|
||||
et = formate_datetime(v.end),
|
||||
start_time = st[0],
|
||||
end_time = et[0],
|
||||
var st = format_datetime(v.start),
|
||||
et = format_datetime(v.end),
|
||||
start_time = format_date(v.start),
|
||||
end_time = format_date(v.end),
|
||||
same = (start_time==end_time),
|
||||
etime = et[1],
|
||||
stime = st[1]
|
||||
etime = format_time(v.end),
|
||||
stime = format_time(v.start)
|
||||
time_string = (same ? "<p class='date'><i class='icons-calendar' /> " + start_time + "</p><p class='time'><i class='icons-clock' /> " + stime + " <i class='icons-arrow-right-5' /> " + etime : "<p class='start-date'><i class='icons-arrow-right-2' /> " + start_time + "<span class='pull-right'>" + stime + "</span></p><p class='end-date'><i class='icons-arrow-left-2' /> " + end_time + "<span class='pull-right'>" + etime + "</p>");
|
||||
}
|
||||
var modal_tp = ('<div class="dialog_event" style="display: none;">' +
|
||||
|
@ -167,8 +249,8 @@
|
|||
}else{
|
||||
tp = $('<a class="event-container-one"><div class="title_temp"></div><div class="duration_temp"></div><div class="event-content"></div></a>').attr('href',v.url_linked)
|
||||
}
|
||||
var sd = formate_datetime(v.start),
|
||||
ed = formate_datetime(v.end),
|
||||
var sd = [format_date(v.start), format_time(v.start)],
|
||||
ed = [format_date(v.end), format_time(v.end)],
|
||||
duration = '';
|
||||
if(v.allDay){
|
||||
if (sd[0]!=ed[0]){
|
||||
|
@ -339,8 +421,8 @@
|
|||
break;
|
||||
}
|
||||
table_body.append(tr);
|
||||
head_title.text(monthNames[firstDay.getMonth()] + " " + firstDay.getFullYear());
|
||||
}
|
||||
head_title.text(getDateString(firstDay, calendar_variable.month_year_format));
|
||||
}
|
||||
|
||||
var getNumberOfRows = function() {
|
||||
|
@ -467,8 +549,8 @@
|
|||
$.each(data.events,function(index,eve){
|
||||
var sd = new Date(eve.start),
|
||||
ed = new Date(eve.end),
|
||||
sd_date = new Date(formate_datetime(eve.start)[0]),
|
||||
ed_date = new Date(formate_datetime(eve.end)[0]),
|
||||
sd_date = new Date(format_datetime(eve.start)[0]),
|
||||
ed_date = new Date(format_datetime(eve.end)[0]),
|
||||
timeDiff = ed_date.getTime() - sd_date.getTime(),
|
||||
dayDiff = Math.round(timeDiff / (1000 * 3600 * 24));
|
||||
if(eve.allDay && dayDiff < 1){
|
||||
|
|
|
@ -10,6 +10,7 @@ class CalendarsController < ApplicationController
|
|||
{
|
||||
"modes_info" => @calendar_setting.get_modes_info.map.with_index{|(trans, mode),i| {trans: trans, mode: mode, active_class: (i ==
|
||||
2 ? 'active' : '')}},
|
||||
"week_title" => @calendar_setting.week_title.map{|t| {'week_title'=> t}},
|
||||
"extras" => {
|
||||
"page_id" => OrbitHelper.params[:page_id],
|
||||
'widget_title' => page.name,
|
||||
|
@ -36,6 +37,7 @@ class CalendarsController < ApplicationController
|
|||
{
|
||||
"modes_info" => @calendar_setting.get_modes_info.map.with_index{|(trans, mode),i| {trans: trans, mode: mode, active_class: (i ==
|
||||
2 ? 'active' : '')}},
|
||||
"week_title" => @calendar_setting.week_title.map{|t| {'week_title'=> t}},
|
||||
"extras" => {
|
||||
"subpart-id" => part.id.to_s,
|
||||
"more_url" => OrbitHelper.widget_more_url,
|
||||
|
@ -53,10 +55,14 @@ class CalendarsController < ApplicationController
|
|||
locale = params[:locale]||I18n.locale
|
||||
locale = 'zh_tw' if locale == 'zh_cn'
|
||||
if !page.nil?
|
||||
calendar_types = page.categories
|
||||
if calendar_types.include?('all')
|
||||
calendar_types = []
|
||||
end
|
||||
if params[:start].present? && params[:end].present?
|
||||
sdt = Time.at(params[:start].to_i).utc
|
||||
edt = Time.at(params[:end].to_i).utc
|
||||
events = Event.where("title_translations.#{locale}".to_sym.ne=>"").monthly_event(sdt,edt).convert_front+Event.recurring_event(sdt,edt)
|
||||
events = Event.with_categories(calendar_types).where("title_translations.#{locale}".to_sym.ne=>"").monthly_event(sdt,edt).convert_front+Event.recurring_event(sdt,edt)
|
||||
end
|
||||
end
|
||||
respond_to do |format|
|
||||
|
@ -84,13 +90,9 @@ class CalendarsController < ApplicationController
|
|||
agenda_start = Time.at(params[:unix_start].to_i).utc.to_s
|
||||
agenda_end = Time.at(params[:unix_end].to_i).utc.to_s
|
||||
event = Event.where("title_translations.#{locale}".to_sym.ne=>"")
|
||||
if !calendar_types.blank?
|
||||
events = event.where(:calendar_type_id.in => calendar_types).agenda_events(agenda_start,agenda_end)
|
||||
else
|
||||
events = event.agenda_events(agenda_start,agenda_end)
|
||||
end
|
||||
events = event.with_categories(calendar_types).agenda_events(agenda_start,agenda_end)
|
||||
end
|
||||
render json: {"events" => events,"calendar_title"=>get_calendar_title(Time.at(params[:unix_start].to_i).utc)}.to_json({"frontend" => true})
|
||||
render json: {"events" => events,"calendar_title"=>get_calendar_title(Time.at(params[:month_start].to_i).utc)}.to_json({"frontend" => true})
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -109,13 +111,9 @@ class CalendarsController < ApplicationController
|
|||
agenda_start = Time.at(params[:unix_start].to_i).utc.to_s
|
||||
agenda_end = Time.at(params[:unix_end].to_i).utc.to_s
|
||||
event = Event.where("title_translations.#{locale}".to_sym.ne=>"")
|
||||
if !calendar_types.blank?
|
||||
events = event.where(:calendar_type_id.in => calendar_types).agenda_events(agenda_start,agenda_end)
|
||||
else
|
||||
events = event.agenda_events(agenda_start,agenda_end)
|
||||
end
|
||||
events = event.with_categories(calendar_types).agenda_events(agenda_start,agenda_end)
|
||||
end
|
||||
render json: {"events" => events,"calendar_title"=>get_calendar_title(Time.at(params[:unix_start].to_i).utc)}.to_json({"frontend" => true})
|
||||
render json: {"events" => events,"calendar_title"=>get_calendar_title(Time.at(params[:month_start].to_i).utc)}.to_json({"frontend" => true})
|
||||
end
|
||||
end
|
||||
def get_calendar_title(now_date=nil)
|
||||
|
|
|
@ -16,14 +16,8 @@
|
|||
</div>
|
||||
<table class="table table-condensed w-calendar-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Sun</th>
|
||||
<th>Mon</th>
|
||||
<th>Tue</th>
|
||||
<th>Wed</th>
|
||||
<th>Thu</th>
|
||||
<th>Fri</th>
|
||||
<th>Sat</th>
|
||||
<tr data-list="week_title" data-level="0">
|
||||
<th>{{week_title}}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
@ -47,7 +41,7 @@
|
|||
tag.setAttribute("id", "calendar-widget_module");
|
||||
tag.src = "<%= asset_path('calendar_widget.js') %>";
|
||||
tag.onload = function(){
|
||||
$("div.widget-calendar-1[data-module=calendar]").each(function(index){
|
||||
$('div.widget-calendar-1[data-module=calendar][data-subpart-id="{{subpart-id}}"]').each(function(index){
|
||||
var calendar = $(this),
|
||||
cmi = new CalendarModuleMonth1(new Date(), calendar,calendar.data("subpart-id"),"{{more_url}}",false);
|
||||
cmi.currentMonth();
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
<span>{{widget_title}}</span>
|
||||
</div>
|
||||
<div class='month_template'>
|
||||
<h4 class="widget-title ">
|
||||
<h4 class="widget-title">
|
||||
<span class="text"><span style="display: none;">placeholder</span></span>
|
||||
<i class="fa fa-circle-o-notch fa-spin fa-fw loading hide"></i>
|
||||
</h4>
|
||||
|
@ -20,14 +20,8 @@
|
|||
</div>
|
||||
<table class="table table-condensed w-calendar-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Sun</th>
|
||||
<th>Mon</th>
|
||||
<th>Tue</th>
|
||||
<th>Wed</th>
|
||||
<th>Thu</th>
|
||||
<th>Fri</th>
|
||||
<th>Sat</th>
|
||||
<tr data-list="week_title" data-level="0">
|
||||
<th>{{week_title}}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
@ -63,7 +57,7 @@
|
|||
tag.setAttribute("id", "calendar-widget_module2");
|
||||
tag.src = "<%= asset_path('calendar_widget2.js') %>";
|
||||
tag.onload = function(){
|
||||
$("div.widget-calendar-2[data-module=calendar]").each(function(index){
|
||||
$('div.widget-calendar-2[data-module="calendar"][data-subpart-id="{{subpart-id}}"]').each(function(index){
|
||||
var calendar = $(this),
|
||||
cmi = new CalendarModuleMonth2(new Date(), calendar,calendar.data("subpart-id"),"{{more_url}}",false);
|
||||
cmi.currentMonth();
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
{{style_tag}}
|
||||
<div class="w-calendar widget-calendar-1 index2" data-module="calendar" data-page-id="{{page_id}}">
|
||||
<div class='month_template'>
|
||||
<h4 class="widget-title ">
|
||||
<h4 class="widget-title">
|
||||
<span class="text"><span style="display: none;">placeholder</span></span>
|
||||
<i class="fa fa-circle-o-notch fa-spin fa-fw loading hide"></i>
|
||||
</h4>
|
||||
|
@ -18,14 +18,8 @@
|
|||
</div>
|
||||
<table class="table table-condensed w-calendar-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Sun</th>
|
||||
<th>Mon</th>
|
||||
<th>Tue</th>
|
||||
<th>Wed</th>
|
||||
<th>Thu</th>
|
||||
<th>Fri</th>
|
||||
<th>Sat</th>
|
||||
<tr data-list="week_title" data-level="0">
|
||||
<th>{{week_title}}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
|
Loading…
Reference in New Issue