monthView to beta
This commit is contained in:
@@ -143,6 +143,37 @@
|
||||
--frcal--event-background: var(--color-red);
|
||||
}
|
||||
|
||||
|
||||
.frcal__mountView {
|
||||
position: relative;
|
||||
display: none;
|
||||
height: 70vh;
|
||||
max-width: 300px;
|
||||
width: 70vw;
|
||||
top: 15vh;
|
||||
left: max(15%, calc( 50% - 150px ));
|
||||
background-color: var(--background-primary);
|
||||
overflow-y: scroll;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.frcal__month_month {
|
||||
border-bottom: 1px solid var(--text-normal);
|
||||
}
|
||||
|
||||
.frcal__weekinmonth {
|
||||
border-right: 1px solid var(--text-normal);
|
||||
}
|
||||
|
||||
.frcal__oddMonth {
|
||||
color: var(--text-muted);
|
||||
}
|
||||
|
||||
.frcal__today {
|
||||
color: var(--color-accent);
|
||||
}
|
||||
|
||||
|
||||
.workspace-leaf-content[data-type='fr-calendar'] .task-list-item-checkbox {
|
||||
vertical-align: middle;
|
||||
border-color: var(--frcal--event-text-color, var(--text-normal));
|
||||
|
||||
34
main.js
34
main.js
@@ -300,9 +300,9 @@ class CalendarView extends ItemView
|
||||
|
||||
let today = this.monthEl.createEl("div", { cls: "frcal__time" });
|
||||
today.append(getIcon('calendar-days'));
|
||||
// today.addEventListener('click', function(e) {
|
||||
// this.gotoThisWeek();
|
||||
// }.bind(this));
|
||||
today.addEventListener('click', function(e) {
|
||||
this.gotoThisWeek();
|
||||
}.bind(this));
|
||||
this.mountFirstEl = this.monthEl.createEl("div", { cls: "frcal__month_first", attr: { style: "flex: 70" } });
|
||||
this.mountFirstSpanEl = this.mountFirstEl.createEl("span");
|
||||
this.mountSecondEl = this.monthEl.createEl("div", { cls: "frcal__month_second", attr: { style: "flex: 0" } });
|
||||
@@ -392,25 +392,41 @@ class CalendarView extends ItemView
|
||||
}
|
||||
}
|
||||
|
||||
let lastMonth = startMonth.year() * 12 + startMonth.month() - 1;
|
||||
console.log("mount view: start = ", startMonth, " end = ", endMonth);
|
||||
|
||||
let lastMonth = moment(startMonth).day(4).year() * 12 + moment(startMonth).day(4).month() - 1;
|
||||
|
||||
let table = this.mountView.createEl('table');
|
||||
for (let week = moment(startMonth); week < endMonth; week.add(1, "weeks"))
|
||||
{
|
||||
let row = table.createEl("tr");
|
||||
|
||||
let thursday = moment(week).day(4);
|
||||
|
||||
if (lastMonth != week.year() * 12 + week.month())
|
||||
if (lastMonth != thursday.year() * 12 + thursday.month())
|
||||
{
|
||||
lastMonth += 1;
|
||||
let span = moment(week).add(1, "months").subtract(1, "day").isoWeek() - week.isoWeek();
|
||||
row.createEl("td", { attr: { rowspan: span } }).innerText = DateFormat.months[week.month()];
|
||||
let lastDayOfMount = moment(thursday);
|
||||
let span = 0;
|
||||
while (lastDayOfMount.month() == thursday.month())
|
||||
{
|
||||
span++;
|
||||
lastDayOfMount.add(1, "weeks");
|
||||
}
|
||||
// let span = moment(week).add(1, "months").date(4).isoWeek() - week.isoWeek();
|
||||
row.createEl("td", { attr: { rowspan: span, cls: 'frcal__month_month' } }).innerText = (thursday.month() + 1).toString() + " - " + DateFormat.months[thursday.month()];
|
||||
}
|
||||
|
||||
row.createEl('td', { cls: 'frcal__weekinmonth' }).innerText = week.isoWeek();
|
||||
|
||||
for (let day=week.date(); day < week.date()+7; day++)
|
||||
let day=moment(week)
|
||||
for (let i = 7; i > 0; i--)
|
||||
{
|
||||
row.createEl('td', { cls: 'frcal__dayinmonth'}).innerText = day.toString();
|
||||
let classes = 'frcal__dayinmonth';
|
||||
classes += ((day.month()%2 == 1) ? ' frcal__evenMonth' : ' frcal__oddMonth');
|
||||
classes += (day.format("y-MM-D") == moment().format("y-MM-D")) ? ' frcal__today' : ''
|
||||
row.createEl('td', { cls: classes }).innerText = day.date().toString();
|
||||
day.add(1, "day");
|
||||
}
|
||||
}
|
||||
this.mountView.style.display = "block";
|
||||
|
||||
Reference in New Issue
Block a user