Update js and templates.

This commit is contained in:
BoHung Chiu 2022-07-13 14:42:33 +08:00
parent 7ae2d1784b
commit e76355a658
3 changed files with 23 additions and 29 deletions

View File

@ -154,9 +154,9 @@ var CalendarModuleMonth1 = function(date,dom,subpart,url,index_flag){
date = new Date(date); date = new Date(date);
return getDateString(date, window.calendar_variable.date_format); return getDateString(date, window.calendar_variable.date_format);
} }
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()
@ -193,20 +193,20 @@ var CalendarModuleMonth1 = function(date,dom,subpart,url,index_flag){
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;">' +
@ -222,17 +222,17 @@ var CalendarModuleMonth1 = function(date,dom,subpart,url,index_flag){
}else{ }else{
tp = $('<a class="event-container"><div class="event-icon"><div class="event-bullet-event"></div></div><div class="event-info"></div></a>').attr('href',v.url_linked) tp = $('<a class="event-container"><div class="event-icon"><div class="event-bullet-event"></div></div><div class="event-info"></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]){
duration = sd[0]+'>'+ed[0] +'<br>' duration = sd[0]+' > '+ed[0] +'<br>'
} }
}else if (sd[0]==ed[0]){ }else if (sd[0]==ed[0]){
duration = sd[1]+'>'+ed[1] +'<br>' duration = sd[1]+'>'+ed[1] +'<br>'
}else{ }else{
duration = sd[0]+' '+sd[1]+'>'+ed[0]+' '+ed[1] +'<br>' duration = sd[0]+' '+sd[1]+' > '+ed[0]+' '+ed[1] +'<br>'
} }
tp.find('.event-info').html(duration+v.title+"<div class=\"event-content\">"+v.note+"</div>") tp.find('.event-info').html(duration+v.title+"<div class=\"event-content\">"+v.note+"</div>")
tp.find('.event-bullet-event').css('background',v.color) tp.find('.event-bullet-event').css('background',v.color)
@ -409,8 +409,8 @@ var CalendarModuleMonth1 = function(date,dom,subpart,url,index_flag){
$.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_date(eve.start)),
ed_date = new Date(formate_datetime(eve.end)[0]), ed_date = new Date(format_date(eve.end)),
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){

View File

@ -257,9 +257,9 @@ var CalendarModuleMonth2 = function(date,dom,subpart,url,index_flag){
duration = sd[0]+'>'+ed[0] +'<br>' duration = sd[0]+'>'+ed[0] +'<br>'
} }
}else if (sd[0]==ed[0]){ }else if (sd[0]==ed[0]){
duration = sd[1]+'>'+ed[1] +'<br>' duration = sd[1]+' > '+ed[1] +'<br>'
}else{ }else{
duration = sd[0]+' '+sd[1]+'>'+ed[0]+' '+ed[1] +'<br>' duration = sd[0]+' '+sd[1]+' > '+ed[0]+' '+ed[1] +'<br>'
} }
tp.css('color',hexToRGB(v.color,0.45)) tp.css('color',hexToRGB(v.color,0.45))
tp.find('.event-content').html(v.note || read_more_text) tp.find('.event-content').html(v.note || read_more_text)
@ -549,8 +549,8 @@ var CalendarModuleMonth2 = function(date,dom,subpart,url,index_flag){
$.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(format_datetime(eve.start)[0]), sd_date = new Date(format_date(eve.start)),
ed_date = new Date(format_datetime(eve.end)[0]), ed_date = new Date(format_date(eve.end)),
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){

View File

@ -22,14 +22,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>