/
CALEXT2_ViewMonth.js
35 lines (32 loc) · 1 KB
/
CALEXT2_ViewMonth.js
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
/* global ViewCell */
// eslint-disable-next-line no-unused-vars
class ViewMonth extends ViewCell {
getSlotCount() {
const startDay = this.getStartDay();
const endDay = this.getEndWeek();
const diff = endDay.diff(startDay, "week");
return diff + 1;
}
getStartDay() {
const { fromNow } = this.config;
const now = moment().locale(this.locale);
return now.add(fromNow, "month").startOf("month").startOf("week");
}
getEndWeek() {
const { fromNow } = this.config;
const now = moment().locale(this.locale);
return now.add(fromNow, "month").endOf("month").startOf("week");
}
makeSlots() {
super.makeSlots();
if (this.config.monthFormat) {
const { fromNow } = this.config;
const now = moment().locale(this.locale);
now.add(fromNow, "month").startOf("month");
const mt = document.createElement("div");
mt.innerHTML = now.format(this.config.monthFormat);
mt.classList.add("monthViewTitle");
this.contentDom.prepend(mt);
}
}
}