MCPcopy Create free account
hub / github.com/DHTMLX/scheduler / _renderDayGrid

Method _renderDayGrid

codebase/sources/dhtmlxscheduler.es.js:9119–9191  ·  view source on GitHub ↗
(container)

Source from the content-addressed store, hash-verified

9117 return weeks;
9118 }
9119 _renderDayGrid(container) {
9120 const { date, currentRange, eventDates, minWeeks, filterDays } = this.getState();
9121 let minSchedulerDate = currentRange[0];
9122 let maxSchedulerDate = currentRange[1];
9123 const eventDaysTable = eventDates.reduce((acc, date2) => {
9124 const dayStart = this.scheduler.date.day_start(new Date(date2));
9125 acc[dayStart.valueOf()] = true;
9126 return acc;
9127 }, {});
9128 const daysOfWeekContainer = document.createElement("div");
9129 this._renderDayGridHeader(daysOfWeekContainer);
9130 const weekLength = daysOfWeekContainer.children.length;
9131 container.appendChild(daysOfWeekContainer);
9132 if (weekLength !== 7) {
9133 container.style.setProperty("--dhx-scheduler-week-length", weekLength);
9134 }
9135 const scheduler2 = this.scheduler;
9136 const firstDate = scheduler2.date.week_start(scheduler2.date.month_start(new Date(date)));
9137 const monthStart = scheduler2.date.month_start(new Date(date));
9138 const monthEnd = scheduler2.date.add(scheduler2.date.month_start(new Date(date)), 1, "month");
9139 let lastDate = scheduler2.date.add(scheduler2.date.month_start(new Date(date)), 1, "month");
9140 const currentCalDate = scheduler2.date.date_part(scheduler2._currentDate());
9141 if (lastDate.getDay() !== 0 && scheduler2.config.start_on_monday) {
9142 const dayOfWeek = lastDate.getDay();
9143 const daysToSunday = (7 - dayOfWeek) % 7;
9144 lastDate = scheduler2.date.add(lastDate, daysToSunday + 1, "day");
9145 } else {
9146 lastDate = scheduler2.date.add(scheduler2.date.week_start(lastDate), 1, "week");
9147 }
9148 let weeks = this._weeksBetween(firstDate, lastDate);
9149 if (minWeeks && weeks < minWeeks) {
9150 lastDate = scheduler2.date.add(lastDate, minWeeks - weeks, "week");
9151 }
9152 let currDate = firstDate;
9153 const dayGridContainer = document.createElement("div");
9154 dayGridContainer.classList.add("dhx_cal_datepicker_days");
9155 this._domEvents.attach(dayGridContainer, "click", (event2) => {
9156 const dateCell = event2.target.closest("[data-cell-date]");
9157 const date2 = new Date(dateCell.getAttribute("data-cell-date"));
9158 this.callEvent("onDateClick", [date2, event2]);
9159 });
9160 while (currDate.valueOf() < lastDate.valueOf()) {
9161 if (!(filterDays && filterDays(currDate))) {
9162 const dayElement = document.createElement("div");
9163 dayElement.setAttribute("data-cell-date", scheduler2.templates.format_date(currDate));
9164 dayElement.setAttribute("data-day", currDate.getDay());
9165 dayElement.innerHTML = scheduler2.templates.month_day(currDate);
9166 if (currDate.valueOf() < monthStart.valueOf()) {
9167 dayElement.classList.add("dhx_before");
9168 } else if (currDate.valueOf() >= monthEnd.valueOf()) {
9169 dayElement.classList.add("dhx_after");
9170 }
9171 if (currDate.getDay() === 0 || currDate.getDay() === 6) {
9172 dayElement.classList.add("dhx_cal_datepicker_weekend");
9173 }
9174 if (currDate.valueOf() == currentCalDate.valueOf()) {
9175 dayElement.classList.add("dhx_now");
9176 }

Callers 2

renderMethod · 0.95
year_viewFunction · 0.45

Calls 12

getStateMethod · 0.95
_renderDayGridHeaderMethod · 0.95
_weeksBetweenMethod · 0.95
day_startMethod · 0.65
week_startMethod · 0.65
month_startMethod · 0.65
addMethod · 0.65
date_partMethod · 0.65
callEventMethod · 0.65
format_dateMethod · 0.65
month_dayMethod · 0.65
attachMethod · 0.45

Tested by

no test coverage detected