Convert js space to tabs.

This commit is contained in:
BoHung Chiu 2022-07-11 15:26:47 +08:00
parent b3876c00d0
commit 878fc0079d
1 changed files with 105 additions and 105 deletions

View File

@ -44,21 +44,21 @@ FullCalendar.Calendar.prototype.isAnOverlapEvent = function(eventStartDay, event
eventEndDay = new Date(eventEndDay); eventEndDay = new Date(eventEndDay);
var events = this.get_all_events(); var events = this.get_all_events();
for (var i = 0; i < events.length; i++) { for (var i = 0; i < events.length; i++) {
var eventA = events[i]; var eventA = events[i];
// start-time in between any of the events // start-time in between any of the events
if (eventStartDay >= eventA.start && eventStartDay <= eventA.end) { if (eventStartDay >= eventA.start && eventStartDay <= eventA.end) {
return true; return true;
} }
//end-time in between any of the events //end-time in between any of the events
if (eventEndDay >= eventA.start && eventEndDay <= eventA.end) { if (eventEndDay >= eventA.start && eventEndDay <= eventA.end) {
return true; return true;
} }
//any of the events in between/on the start-time and end-time //any of the events in between/on the start-time and end-time
if (eventStartDay <= eventA.start && eventEndDay >= eventA.end) { if (eventStartDay <= eventA.start && eventEndDay >= eventA.end) {
return true; return true;
} }
} }
return false; return false;
} }
window.is_chinese = ( I18n && I18n.locale.indexOf('zh') != -1 ); 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.datetime_format = is_chinese ? 'y M d h:m b' : 'd M, y h:m b';
@ -70,39 +70,39 @@ window.short_day = (is_chinese ? "d (w)" : "w d");
window.short_date = (is_chinese ? "M d (w)" : "w d, M"); 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.short_date_time = (is_chinese ? "M d (w) h:m b" : "w d, M h:m b");
window.getDateString = function(date, format,is_chinese) { window.getDateString = function(date, format,is_chinese) {
var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']; var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
var week_days = ['Sun','Mon','Tue','Wed','Thu','Fri','Sat']; var week_days = ['Sun','Mon','Tue','Wed','Thu','Fri','Sat'];
if(is_chinese){ if(is_chinese){
months = []; months = [];
for(var i=0;i<12;i++){ for(var i=0;i<12;i++){
months.push((i+1)+"月"); months.push((i+1)+"月");
} }
week_days = ["週日","週一","週二","週三","週四","週五","週六"] week_days = ["週日","週一","週二","週三","週四","週五","週六"]
} }
var getPaddedComp = function(comp) { var getPaddedComp = function(comp) {
return ((parseInt(comp) < 10) ? ('0' + comp) : comp) return ((parseInt(comp) < 10) ? ('0' + comp) : comp)
}, },
formattedDate = format, formattedDate = format,
o = { o = {
"y+": date.getFullYear() + (is_chinese ? "年" : ""), // year "y+": date.getFullYear() + (is_chinese ? "年" : ""), // year
"MM+": getPaddedComp(date.getMonth() + 1), //raw month "MM+": getPaddedComp(date.getMonth() + 1), //raw month
"M+": months[date.getMonth()], //month "M+": months[date.getMonth()], //month
"d+": (is_chinese ? (date.getDate() + "日") : getPaddedComp(date.getDate())), //day "d+": (is_chinese ? (date.getDate() + "日") : getPaddedComp(date.getDate())), //day
"w+": week_days[date.getDay()], //weekday "w+": week_days[date.getDay()], //weekday
"h+": getPaddedComp((date.getHours() > 12) ? date.getHours() % 12 : date.getHours()), //hour "h+": getPaddedComp((date.getHours() > 12) ? date.getHours() % 12 : date.getHours()), //hour
"H+": getPaddedComp(date.getHours()), //hour "H+": getPaddedComp(date.getHours()), //hour
"m+": getPaddedComp(date.getMinutes()), //minute "m+": getPaddedComp(date.getMinutes()), //minute
"s+": getPaddedComp(date.getSeconds()), //second "s+": getPaddedComp(date.getSeconds()), //second
"S+": getPaddedComp(date.getMilliseconds()), //millisecond, "S+": getPaddedComp(date.getMilliseconds()), //millisecond,
"b+": (date.getHours() >= 12) ? 'PM' : 'AM' "b+": (date.getHours() >= 12) ? 'PM' : 'AM'
}; };
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]);
} }
} }
return formattedDate; return formattedDate;
}; };
var Calendar = function(dom,property_id,currentView,display_hire_event){ var Calendar = function(dom,property_id,currentView,display_hire_event){
@ -160,7 +160,7 @@ var Calendar = function(dom,property_id,currentView,display_hire_event){
}); });
}, },
// events: 'https://fullcalendar.io/demo-events.json', // events: 'https://fullcalendar.io/demo-events.json',
headerToolbar: false, headerToolbar: false,
fixedWeekCount: false, fixedWeekCount: false,
initialView: dview, initialView: dview,
loading: function(bool) { loading: function(bool) {
@ -173,42 +173,42 @@ var Calendar = function(dom,property_id,currentView,display_hire_event){
c.calendar_dom.calendar.refetchEvents(); c.calendar_dom.calendar.refetchEvents();
}, },
eventTimeFormat: { hour12: true, hour: '2-digit', minute: '2-digit', omitZeroMinute: true, meridiem: 'narrow' }, eventTimeFormat: { hour12: true, hour: '2-digit', minute: '2-digit', omitZeroMinute: true, meridiem: 'narrow' },
eventClick: function(eventClickInfo) { eventClick: function(eventClickInfo) {
var calEvent = {"event": eventClickInfo.event}, var calEvent = {"event": eventClickInfo.event},
originalEvent = eventClickInfo.jsEvent, originalEvent = eventClickInfo.jsEvent,
view = eventClickInfo.view, view = eventClickInfo.view,
el = eventClickInfo.el; el = eventClickInfo.el;
if(el.hasClass("reserve_btn")){ if(el.hasClass("reserve_btn")){
window.calEvent = calEvent; window.calEvent = calEvent;
var start_time = calEvent.event.start; var start_time = calEvent.event.start;
var date_str = window.getDateString(start_time,std_date_format); var date_str = window.getDateString(start_time,std_date_format);
c.dialog.hide(); c.dialog.hide();
var allow_times = calEvent.event._def.extendedProps.allow_times; var allow_times = calEvent.event._def.extendedProps.allow_times;
window.pick_hire_date(date_str,allow_times); window.pick_hire_date(date_str,allow_times);
}else{ }else{
c.dialog.dismiss(); c.dialog.dismiss();
c.dialog.inflate(calEvent); c.dialog.inflate(calEvent);
c.dialog.show({"x":e.originalEvent.clientX,"y":e.originalEvent.clientY}); c.dialog.show({"x":e.originalEvent.clientX,"y":e.originalEvent.clientY});
} }
}, },
dateClick: function(ev) { dateClick: function(ev) {
var calendar = this; var calendar = this;
var calendar_dom = $(this.el); var calendar_dom = $(this.el);
if(c.calendar_dom.hasClass("active_picker")){ if(c.calendar_dom.hasClass("active_picker")){
var date = ev.date, var date = ev.date,
date_str = getDateString(date,date_time_str_format), date_str = getDateString(date,date_time_str_format),
day_element = ev.dayEl, day_element = ev.dayEl,
jsEvent = ev.jsEvent; jsEvent = ev.jsEvent;
var time_str = date_str.split(" ")[1]; var time_str = date_str.split(" ")[1];
var date_str = date_str.split(" ")[0]; var date_str = date_str.split(" ")[0];
calendar_dom.trigger("init_time",[time_str]); calendar_dom.trigger("init_time",[time_str]);
calendar_dom.trigger("select_time",[date_str]); calendar_dom.trigger("select_time",[date_str]);
} }
}, },
views: { views: {
dayGridMonth: { dayGridMonth: {
dayMaxEvents: true dayMaxEvents: true
} }
} }
}); });
@ -342,7 +342,7 @@ var EventDialog = function(calendar,event){
'</div>' + '</div>' +
'<div class="modal-body">' + '<div class="modal-body">' +
'<div class="event_summary">' + time_string + '</br>' + _event.hiring_person_name + '</div>' + _event.note + '<div class="event_summary">' + time_string + '</br>' + _event.hiring_person_name + '</div>' + _event.note +
(_event.error_message ? ("<br><span style=\"color: #FC4040;\">" + _event.error_message + "</span>") : "") (_event.error_message ? ("<br><span style=\"color: #FC4040;\">" + _event.error_message + "</span>") : "")
'</div>' + '</div>' +
'<div class="modal-footer" />' + '<div class="modal-footer" />' +
'</div>'; '</div>';
@ -426,7 +426,7 @@ var UserException = function(message) {
this.message = message; this.message = message;
this.name = "UserException"; this.name = "UserException";
this.toString = function(){ this.toString = function(){
return this.message; return this.message;
} }
} }
@ -611,13 +611,13 @@ var AgendaView = function(calendar){
$.datepicker._updateDatepicker(inst); $.datepicker._updateDatepicker(inst);
}) })
$("#agenda_start,#agenda_end").focus(function () { $("#agenda_start,#agenda_end").focus(function () {
$(".ui-datepicker-calendar").hide(); $(".ui-datepicker-calendar").hide();
$("#ui-datepicker-div").position({ $("#ui-datepicker-div").position({
my: "center top", my: "center top",
at: "center bottom", at: "center bottom",
of: $(this) of: $(this)
}); });
}); });
$.each(data,function(i,e){ $.each(data,function(i,e){
var ed = eventDom(e), var ed = eventDom(e),
s = new Date(e.start), s = new Date(e.start),
@ -764,21 +764,21 @@ var AgendaView = function(calendar){
} }
function getNumberOfRows(year, month) { function getNumberOfRows(year, month) {
var day = 1, var day = 1,
sat_counter = 0, sat_counter = 0,
sunday_counter = 0, sunday_counter = 0,
date = new Date(year, month, day); date = new Date(year, month, day);
while(date.getMonth() === month) { while(date.getMonth() === month) {
if(date.getDay() === 0) { if(date.getDay() === 0) {
sunday_counter++; sunday_counter++;
}else if(date.getDay() === 6) { }else if(date.getDay() === 6) {
sat_counter++; sat_counter++;
} }
day++; day++;
date = new Date(year, month, day); date = new Date(year, month, day);
} }
return (sunday_counter == 5 && sat_counter == 5 ? 6 : 5); return (sunday_counter == 5 && sat_counter == 5 ? 6 : 5);
} }
var makeRow = function(position){ var makeRow = function(position){