-
Notifications
You must be signed in to change notification settings - Fork 61
Expand file tree
/
Copy pathCALEXT2_ViewWeekly.js
More file actions
53 lines (50 loc) · 2.12 KB
/
CALEXT2_ViewWeekly.js
File metadata and controls
53 lines (50 loc) · 2.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/* global dayjs SlotDateHelpers */
// eslint-disable-next-line no-unused-vars, no-undef
class ViewWeekly extends ViewPeriod {
constructor (config, events) {
super(config, events);
this.slotUnit = "week";
}
makeSlotDomClass (slot) {
const slotDom = slot.dom;
super.makeSlotDomClass(slot);
slotDom.classList.add("weekly");
const info = SlotDateHelpers.getSlotDateInfo(slot.start.toDate(), slot.end.toDate(), null, this.config.weekStart);
if (info.isSameYear) slotDom.classList.add("thisyear");
if (info.isSameMonth) slotDom.classList.add("thismonth");
if (info.isSameWeek) slotDom.classList.add("thisweek");
if (info.nowInRange) slotDom.classList.add("today");
slotDom.classList.add(`year_${info.year}`);
slotDom.classList.add(`month_${info.month}`);
slotDom.classList.add(`week_${info.week}`);
}
makeSlotHeader (slot) {
const header = slot.headerDom;
const title = header.querySelector(".slotTitle");
const subTitle = header.querySelector(".slotSubTitle");
if (this.config.slotTitle) {
title.innerHTML = this.config.slotTitle;
} else if (
this.config.slotTitleFormat &&
typeof this.config.slotTitleFormat !== "object"
) {
const startDay = this.locale ? dayjs(slot.start).locale(this.locale) : dayjs(slot.start);
title.innerHTML = startDay.format(this.config.slotTitleFormat);
} else {
const startDay = this.locale ? dayjs(slot.start).locale(this.locale) : dayjs(slot.start);
title.innerHTML = startDay.calendar(null, this.config.slotTitleFormat);
}
if (this.config.slotSubTitle) {
subTitle.innerHTML = this.config.slotSubTitle;
} else if (
this.config.slotSubTitleFormat &&
typeof this.config.slotSubTitleFormat !== "object"
) {
const startDay = this.locale ? dayjs(slot.start).locale(this.locale) : dayjs(slot.start);
subTitle.innerHTML = startDay.format(this.config.slotSubTitleFormat);
} else {
const startDay = this.locale ? dayjs(slot.start).locale(this.locale) : dayjs(slot.start);
subTitle.innerHTML = startDay.calendar(null, this.config.slotSubTitleFormat);
}
}
}