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_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.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.std_date_format = 'y-MM-d';
|
||||||
window.calendar_variable.short_day = (calendar_variable.is_chinese ? "d (W)" : "W d");
|
window.calendar_variable.short_day = (calendar_variable.is_chinese ? "d (W)" : "W d");
|
||||||
$.fn.fullCalendar = function(args){
|
$.fn.fullCalendar = function(args){
|
||||||
|
@ -144,7 +144,6 @@ window.getDateString = function(date, format, is_chinese) {
|
||||||
"S+": getPaddedComp(S), //millisecond,
|
"S+": getPaddedComp(S), //millisecond,
|
||||||
"b+": (H >= 12) ? pm_trans : am_trans
|
"b+": (H >= 12) ? pm_trans : am_trans
|
||||||
};
|
};
|
||||||
|
|
||||||
for (var k in o) {
|
for (var k in o) {
|
||||||
if (new RegExp("(" + k + ")").test(format)) {
|
if (new RegExp("(" + k + ")").test(format)) {
|
||||||
formattedDate = formattedDate.replace(RegExp.$1, o[k]);
|
formattedDate = formattedDate.replace(RegExp.$1, o[k]);
|
||||||
|
@ -581,8 +580,8 @@ var EventDialog = function(calendar,event){
|
||||||
} else {
|
} else {
|
||||||
start_time = getDateString(_event._start,calendar_variable.date_format_with_short_month);
|
start_time = getDateString(_event._start,calendar_variable.date_format_with_short_month);
|
||||||
end_time = getDateString(_event._end,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),
|
var stime = getDateString(_event._start,calendar_variable.time_format),
|
||||||
etime = getDateString(_event._end,time_format),
|
etime = getDateString(_event._end,calendar_variable.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> " +
|
||||||
|
@ -940,7 +939,7 @@ var AgendaView = function(calendar){
|
||||||
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);
|
datetimeFormat = getDateString(s, calendar_variable.short_day);
|
||||||
if(!event.allDay){
|
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{
|
}else{
|
||||||
if(event.allDay){
|
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_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.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.std_date_format = 'y-MM-d';
|
||||||
window.calendar_variable.short_day = (calendar_variable.is_chinese ? "d (W)" : "W d");
|
window.calendar_variable.short_day = (calendar_variable.is_chinese ? "d (W)" : "W d");
|
||||||
$.fn.fullCalendar = function(args){
|
$.fn.fullCalendar = function(args){
|
||||||
|
@ -144,7 +144,6 @@ window.getDateString = function(date, format, is_chinese) {
|
||||||
"S+": getPaddedComp(S), //millisecond,
|
"S+": getPaddedComp(S), //millisecond,
|
||||||
"b+": (H >= 12) ? pm_trans : am_trans
|
"b+": (H >= 12) ? pm_trans : am_trans
|
||||||
};
|
};
|
||||||
|
|
||||||
for (var k in o) {
|
for (var k in o) {
|
||||||
if (new RegExp("(" + k + ")").test(format)) {
|
if (new RegExp("(" + k + ")").test(format)) {
|
||||||
formattedDate = formattedDate.replace(RegExp.$1, o[k]);
|
formattedDate = formattedDate.replace(RegExp.$1, o[k]);
|
||||||
|
@ -418,8 +417,8 @@ var EventDialog = function(calendar,event){
|
||||||
} else {
|
} else {
|
||||||
start_time = getDateString(_event._start,calendar_variable.date_format_with_short_month);
|
start_time = getDateString(_event._start,calendar_variable.date_format_with_short_month);
|
||||||
end_time = getDateString(_event._end,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),
|
var stime = getDateString(_event._start,calendar_variable.time_format),
|
||||||
etime = getDateString(_event._end,time_format),
|
etime = getDateString(_event._end,calendar_variable.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> " +
|
||||||
|
@ -771,7 +770,7 @@ var AgendaView = function(calendar){
|
||||||
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);
|
datetimeFormat = getDateString(s, calendar_variable.short_day);
|
||||||
if(!event.allDay){
|
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{
|
}else{
|
||||||
console.log(event);
|
console.log(event);
|
||||||
|
|
|
@ -1,9 +1,98 @@
|
||||||
|
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 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;
|
_this = this;
|
||||||
var events = {}
|
var events = {}
|
||||||
var template = dom.find(".month_template"),
|
var template = dom.find(".month_template"),
|
||||||
month_names = ["Jan","Feb","March","April","May","June","July","Aug","Sep","Oct","Nov","Dec"],
|
month_names = calendar_variable.months.map(function(m){ return m.substr(0,3);}),
|
||||||
monthNames = ['January','February','March','April','May','June','July','August','September','October','November','December'],
|
|
||||||
initialDate = date,
|
initialDate = date,
|
||||||
subpartid = subpart,
|
subpartid = subpart,
|
||||||
index_url = url,
|
index_url = url,
|
||||||
|
@ -23,11 +112,8 @@
|
||||||
toggle_data;
|
toggle_data;
|
||||||
monthDom.html(template);
|
monthDom.html(template);
|
||||||
var format_time = function(date){
|
var format_time = function(date){
|
||||||
var hours = date.getHours(),
|
date = new Date(date);
|
||||||
minutes = date.getMinutes();
|
return getDateString(date, window.calendar_variable.time_format);
|
||||||
if (hours < 10) {hours = "0"+hours}
|
|
||||||
if (minutes < 10) {minutes = "0"+minutes}
|
|
||||||
return hours+':'+minutes;
|
|
||||||
}
|
}
|
||||||
function rgb2hex(rgb) {
|
function rgb2hex(rgb) {
|
||||||
rgb = rgb.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/);
|
rgb = rgb.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/);
|
||||||
|
@ -65,15 +151,11 @@
|
||||||
return '#'+comp
|
return '#'+comp
|
||||||
}
|
}
|
||||||
var format_date = function(date){
|
var format_date = function(date){
|
||||||
var y = date.getFullYear(),
|
date = new Date(date);
|
||||||
m = date.getMonth() + 1,
|
return getDateString(date, window.calendar_variable.date_format);
|
||||||
d = date.getDate();
|
|
||||||
if (m < 10) {m = "0"+m}
|
|
||||||
if (d < 10) {d = "0"+d}
|
|
||||||
return y+'/'+m+'/'+d;
|
|
||||||
}
|
}
|
||||||
var formate_datetime = function(date){
|
var formate_datetime = function(date){
|
||||||
date = new Date(date)
|
date = new Date(date);
|
||||||
return [format_date(date),format_time(date)]
|
return [format_date(date),format_time(date)]
|
||||||
}
|
}
|
||||||
$(window).resize(function(){
|
$(window).resize(function(){
|
||||||
|
@ -182,7 +264,7 @@
|
||||||
}
|
}
|
||||||
var renderMonth = function(){
|
var renderMonth = function(){
|
||||||
var num_of_rows = getNumberOfRows(),
|
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 = monthDom.find("table.table tbody");
|
||||||
table_body.html("");
|
table_body.html("");
|
||||||
|
|
||||||
|
@ -199,8 +281,8 @@
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
table_body.append(tr);
|
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() {
|
var getNumberOfRows = function() {
|
||||||
|
|
|
@ -1,9 +1,98 @@
|
||||||
|
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 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;
|
_this = this;
|
||||||
var events = {}
|
var events = {}
|
||||||
var template = dom.find(".month_template"),
|
var template = dom.find(".month_template"),
|
||||||
month_names = ["Jan","Feb","March","April","May","June","July","Aug","Sep","Oct","Nov","Dec"],
|
month_names = calendar_variable.months.map(function(m){ return m.substr(0,3);}),
|
||||||
monthNames = ['January','February','March','April','May','June','July','August','September','October','November','December'],
|
|
||||||
initialDate = date,
|
initialDate = date,
|
||||||
subpartid = subpart,
|
subpartid = subpart,
|
||||||
index_url = url,
|
index_url = url,
|
||||||
|
@ -31,11 +120,8 @@
|
||||||
tp2;
|
tp2;
|
||||||
monthDom.html(template);
|
monthDom.html(template);
|
||||||
var format_time = function(date){
|
var format_time = function(date){
|
||||||
var hours = date.getHours(),
|
date = new Date(date);
|
||||||
minutes = date.getMinutes();
|
return getDateString(date, window.calendar_variable.time_format);
|
||||||
if (hours < 10) {hours = "0"+hours}
|
|
||||||
if (minutes < 10) {minutes = "0"+minutes}
|
|
||||||
return hours+':'+minutes;
|
|
||||||
}
|
}
|
||||||
function rgb2hex(rgb) {
|
function rgb2hex(rgb) {
|
||||||
rgb = rgb.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/);
|
rgb = rgb.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/);
|
||||||
|
@ -88,16 +174,12 @@
|
||||||
return '#'+comp
|
return '#'+comp
|
||||||
}
|
}
|
||||||
var format_date = function(date){
|
var format_date = function(date){
|
||||||
var y = date.getFullYear(),
|
date = new Date(date);
|
||||||
m = date.getMonth() + 1,
|
return getDateString(date, window.calendar_variable.date_format);
|
||||||
d = date.getDate();
|
|
||||||
if (m < 10) {m = "0"+m}
|
|
||||||
if (d < 10) {d = "0"+d}
|
|
||||||
return y+'/'+m+'/'+d;
|
|
||||||
}
|
}
|
||||||
var formate_datetime = function(date){
|
var format_datetime = function(date){
|
||||||
date = new Date(date)
|
date = new Date(date)
|
||||||
return [format_date(date),format_time(date)]
|
return getDateString(date, window.calendar_variable.datetime_format);
|
||||||
}
|
}
|
||||||
$(window).resize(function(){
|
$(window).resize(function(){
|
||||||
var window_w = $(window).width()
|
var window_w = $(window).width()
|
||||||
|
@ -138,20 +220,20 @@
|
||||||
var time_string = ''
|
var time_string = ''
|
||||||
if(v.allDay) {
|
if(v.allDay) {
|
||||||
var end_time
|
var end_time
|
||||||
var start_time = formate_datetime(v.start)[0]
|
var start_time = format_date(v.start);
|
||||||
if(v.end)
|
if(v.end)
|
||||||
end_time = formate_datetime(v.end)[0]
|
end_time = format_date(v.end);
|
||||||
else
|
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 + "")
|
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{
|
}else{
|
||||||
var st = formate_datetime(v.start),
|
var st = format_datetime(v.start),
|
||||||
et = formate_datetime(v.end),
|
et = format_datetime(v.end),
|
||||||
start_time = st[0],
|
start_time = format_date(v.start),
|
||||||
end_time = et[0],
|
end_time = format_date(v.end),
|
||||||
same = (start_time==end_time),
|
same = (start_time==end_time),
|
||||||
etime = et[1],
|
etime = format_time(v.end),
|
||||||
stime = st[1]
|
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>");
|
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;">' +
|
var modal_tp = ('<div class="dialog_event" style="display: none;">' +
|
||||||
|
@ -167,8 +249,8 @@
|
||||||
}else{
|
}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)
|
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),
|
var sd = [format_date(v.start), format_time(v.start)],
|
||||||
ed = formate_datetime(v.end),
|
ed = [format_date(v.end), format_time(v.end)],
|
||||||
duration = '';
|
duration = '';
|
||||||
if(v.allDay){
|
if(v.allDay){
|
||||||
if (sd[0]!=ed[0]){
|
if (sd[0]!=ed[0]){
|
||||||
|
@ -339,8 +421,8 @@
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
table_body.append(tr);
|
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() {
|
var getNumberOfRows = function() {
|
||||||
|
@ -467,8 +549,8 @@
|
||||||
$.each(data.events,function(index,eve){
|
$.each(data.events,function(index,eve){
|
||||||
var sd = new Date(eve.start),
|
var sd = new Date(eve.start),
|
||||||
ed = new Date(eve.end),
|
ed = new Date(eve.end),
|
||||||
sd_date = new Date(formate_datetime(eve.start)[0]),
|
sd_date = new Date(format_datetime(eve.start)[0]),
|
||||||
ed_date = new Date(formate_datetime(eve.end)[0]),
|
ed_date = new Date(format_datetime(eve.end)[0]),
|
||||||
timeDiff = ed_date.getTime() - sd_date.getTime(),
|
timeDiff = ed_date.getTime() - sd_date.getTime(),
|
||||||
dayDiff = Math.round(timeDiff / (1000 * 3600 * 24));
|
dayDiff = Math.round(timeDiff / (1000 * 3600 * 24));
|
||||||
if(eve.allDay && dayDiff < 1){
|
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 ==
|
"modes_info" => @calendar_setting.get_modes_info.map.with_index{|(trans, mode),i| {trans: trans, mode: mode, active_class: (i ==
|
||||||
2 ? 'active' : '')}},
|
2 ? 'active' : '')}},
|
||||||
|
"week_title" => @calendar_setting.week_title.map{|t| {'week_title'=> t}},
|
||||||
"extras" => {
|
"extras" => {
|
||||||
"page_id" => OrbitHelper.params[:page_id],
|
"page_id" => OrbitHelper.params[:page_id],
|
||||||
'widget_title' => page.name,
|
'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 ==
|
"modes_info" => @calendar_setting.get_modes_info.map.with_index{|(trans, mode),i| {trans: trans, mode: mode, active_class: (i ==
|
||||||
2 ? 'active' : '')}},
|
2 ? 'active' : '')}},
|
||||||
|
"week_title" => @calendar_setting.week_title.map{|t| {'week_title'=> t}},
|
||||||
"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,
|
||||||
|
@ -53,10 +55,14 @@ class CalendarsController < ApplicationController
|
||||||
locale = params[:locale]||I18n.locale
|
locale = params[:locale]||I18n.locale
|
||||||
locale = 'zh_tw' if locale == 'zh_cn'
|
locale = 'zh_tw' if locale == 'zh_cn'
|
||||||
if !page.nil?
|
if !page.nil?
|
||||||
|
calendar_types = page.categories
|
||||||
|
if calendar_types.include?('all')
|
||||||
|
calendar_types = []
|
||||||
|
end
|
||||||
if params[:start].present? && params[:end].present?
|
if params[:start].present? && params[:end].present?
|
||||||
sdt = Time.at(params[:start].to_i).utc
|
sdt = Time.at(params[:start].to_i).utc
|
||||||
edt = Time.at(params[:end].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
|
||||||
end
|
end
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
|
@ -84,13 +90,9 @@ class CalendarsController < ApplicationController
|
||||||
agenda_start = Time.at(params[:unix_start].to_i).utc.to_s
|
agenda_start = Time.at(params[:unix_start].to_i).utc.to_s
|
||||||
agenda_end = Time.at(params[:unix_end].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=>"")
|
event = Event.where("title_translations.#{locale}".to_sym.ne=>"")
|
||||||
if !calendar_types.blank?
|
events = event.with_categories(calendar_types).agenda_events(agenda_start,agenda_end)
|
||||||
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
|
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,13 +111,9 @@ class CalendarsController < ApplicationController
|
||||||
agenda_start = Time.at(params[:unix_start].to_i).utc.to_s
|
agenda_start = Time.at(params[:unix_start].to_i).utc.to_s
|
||||||
agenda_end = Time.at(params[:unix_end].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=>"")
|
event = Event.where("title_translations.#{locale}".to_sym.ne=>"")
|
||||||
if !calendar_types.blank?
|
events = event.with_categories(calendar_types).agenda_events(agenda_start,agenda_end)
|
||||||
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
|
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)
|
||||||
|
|
|
@ -16,14 +16,8 @@
|
||||||
</div>
|
</div>
|
||||||
<table class="table table-condensed w-calendar-table">
|
<table class="table table-condensed w-calendar-table">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr data-list="week_title" data-level="0">
|
||||||
<th>Sun</th>
|
<th>{{week_title}}</th>
|
||||||
<th>Mon</th>
|
|
||||||
<th>Tue</th>
|
|
||||||
<th>Wed</th>
|
|
||||||
<th>Thu</th>
|
|
||||||
<th>Fri</th>
|
|
||||||
<th>Sat</th>
|
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
|
@ -47,7 +41,7 @@
|
||||||
tag.setAttribute("id", "calendar-widget_module");
|
tag.setAttribute("id", "calendar-widget_module");
|
||||||
tag.src = "<%= asset_path('calendar_widget.js') %>";
|
tag.src = "<%= asset_path('calendar_widget.js') %>";
|
||||||
tag.onload = function(){
|
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),
|
var calendar = $(this),
|
||||||
cmi = new CalendarModuleMonth1(new Date(), calendar,calendar.data("subpart-id"),"{{more_url}}",false);
|
cmi = new CalendarModuleMonth1(new Date(), calendar,calendar.data("subpart-id"),"{{more_url}}",false);
|
||||||
cmi.currentMonth();
|
cmi.currentMonth();
|
||||||
|
|
|
@ -20,14 +20,8 @@
|
||||||
</div>
|
</div>
|
||||||
<table class="table table-condensed w-calendar-table">
|
<table class="table table-condensed w-calendar-table">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr data-list="week_title" data-level="0">
|
||||||
<th>Sun</th>
|
<th>{{week_title}}</th>
|
||||||
<th>Mon</th>
|
|
||||||
<th>Tue</th>
|
|
||||||
<th>Wed</th>
|
|
||||||
<th>Thu</th>
|
|
||||||
<th>Fri</th>
|
|
||||||
<th>Sat</th>
|
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
|
@ -63,7 +57,7 @@
|
||||||
tag.setAttribute("id", "calendar-widget_module2");
|
tag.setAttribute("id", "calendar-widget_module2");
|
||||||
tag.src = "<%= asset_path('calendar_widget2.js') %>";
|
tag.src = "<%= asset_path('calendar_widget2.js') %>";
|
||||||
tag.onload = function(){
|
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),
|
var calendar = $(this),
|
||||||
cmi = new CalendarModuleMonth2(new Date(), calendar,calendar.data("subpart-id"),"{{more_url}}",false);
|
cmi = new CalendarModuleMonth2(new Date(), calendar,calendar.data("subpart-id"),"{{more_url}}",false);
|
||||||
cmi.currentMonth();
|
cmi.currentMonth();
|
||||||
|
|
|
@ -18,14 +18,8 @@
|
||||||
</div>
|
</div>
|
||||||
<table class="table table-condensed w-calendar-table">
|
<table class="table table-condensed w-calendar-table">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr data-list="week_title" data-level="0">
|
||||||
<th>Sun</th>
|
<th>{{week_title}}</th>
|
||||||
<th>Mon</th>
|
|
||||||
<th>Tue</th>
|
|
||||||
<th>Wed</th>
|
|
||||||
<th>Thu</th>
|
|
||||||
<th>Fri</th>
|
|
||||||
<th>Sat</th>
|
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
|
|
Loading…
Reference in New Issue