feat(라이브): 달력 보기 오른쪽에 공용 달력과 말레이시아 공휴일
표 오른쪽에 erp-datepop 붙박이 달력을 두고, 날짜를 누르면 그 날이 표 맨 왼쪽에 오게 한다. 다른 달을 누르면 그 달 화면으로 이동해 같은 위치로 맞춘다. 마지막 날도 맨 왼쪽에 오도록 표 끝에 여백을 둔다. 말레이시아 공휴일·대체휴일 표(holidays.py, 쿠알라룸푸르 기준 2026·2027)를 표시한다. 공용 달력에 선택 옵션 locale 을 추가해 영문 화면도 영어로 그린다. 기존 화면 동작은 그대로. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -63,7 +63,8 @@
|
||||
const HOLIDAY_SHORT = { "부처님오신날": "석가탄신일", "추석·개천절": "추석" };
|
||||
|
||||
// 요일 줄 + 6주 날짜 칸(팝업·붙박이 달력 공용). extra(iso) = 그 칸에 더할 클래스 목록
|
||||
function gridHtml(viewY, viewM, holidays, today, extra) {
|
||||
// locale(선택, 라이브 커머스 영문 화면): { weekdays[7], shortName(이름), title(연, 월0), prev, next } — 없으면 한글
|
||||
function gridHtml(viewY, viewM, holidays, today, extra, locale) {
|
||||
const first = new Date(viewY, viewM, 1);
|
||||
const gridStart = new Date(viewY, viewM, 1 - first.getDay());
|
||||
let days = "";
|
||||
@@ -78,14 +79,14 @@
|
||||
if (iso === today) cls.push("is-today");
|
||||
cls.push.apply(cls, extra(iso, d));
|
||||
if (holName) cls.push("has-hol");
|
||||
const holShort = /\s대체$/.test(holName) ? "대체휴일" : (HOLIDAY_SHORT[holName] || holName);
|
||||
const holShort = locale && locale.shortName ? locale.shortName(holName) : /\s대체$/.test(holName) ? "대체휴일" : (HOLIDAY_SHORT[holName] || holName);
|
||||
days += '<button type="button" class="' + cls.join(" ") + '" data-iso="' + iso + '"' +
|
||||
(holName ? ' title="' + esc(holName) + '"' : "") + ">" +
|
||||
'<span class="pj-dp-num">' + d.getDate() + "</span>" +
|
||||
(holName ? '<span class="pj-dp-hol">' + esc(holShort) + "</span>" : "") + "</button>";
|
||||
}
|
||||
return '<div class="pj-dp-grid">' +
|
||||
["일", "월", "화", "수", "목", "금", "토"].map(function (w, i) {
|
||||
((locale && locale.weekdays) || ["일", "월", "화", "수", "목", "금", "토"]).map(function (w, i) {
|
||||
return '<span class="pj-dp-wd' + (i === 0 ? " is-sun" : i === 6 ? " is-sat" : "") + '">' + w + "</span>";
|
||||
}).join("") + days + "</div>";
|
||||
}
|
||||
@@ -355,7 +356,7 @@
|
||||
|
||||
// 화면에 붙박이는 기간 달력(2026-11-02, 휴가 신청) — 팝업과 같은 달력 서식(.pj-dp-*).
|
||||
// 첫 클릭 = 시작일(동그라미), 다음 클릭 = 종료일(둥근 막대), 그다음 클릭 = 새로 시작. 시작일보다 앞을 누르면 그 날이 새 시작일.
|
||||
// opts: { start, end, holidays, single() — true 면 클릭마다 하루, onChange(start, end) }. 반환 { set(start, end) }
|
||||
// opts: { start, end, holidays, single() — true 면 클릭마다 하루, onChange(start, end), locale }. 반환 { set(start, end) }
|
||||
function mountRange(box, opts) {
|
||||
const holidays = opts.holidays || {};
|
||||
const today = isoToday();
|
||||
@@ -373,12 +374,13 @@
|
||||
return c;
|
||||
}
|
||||
function render() {
|
||||
const loc = opts.locale || {};
|
||||
box.innerHTML =
|
||||
'<div class="pj-dp-nav">' +
|
||||
'<button type="button" class="pj-dp-navbtn" data-nav="-1" title="이전 달"><span class="material-symbols-outlined">chevron_left</span></button>' +
|
||||
'<span class="pj-dp-title">' + viewY + "년 " + (viewM + 1) + "월</span>" +
|
||||
'<button type="button" class="pj-dp-navbtn" data-nav="1" title="다음 달"><span class="material-symbols-outlined">chevron_right</span></button>' +
|
||||
"</div>" + gridHtml(viewY, viewM, holidays, today, bandClasses);
|
||||
'<button type="button" class="pj-dp-navbtn" data-nav="-1" title="' + esc(loc.prev || "이전 달") + '"><span class="material-symbols-outlined">chevron_left</span></button>' +
|
||||
'<span class="pj-dp-title">' + esc(loc.title ? loc.title(viewY, viewM) : viewY + "년 " + (viewM + 1) + "월") + "</span>" +
|
||||
'<button type="button" class="pj-dp-navbtn" data-nav="1" title="' + esc(loc.next || "다음 달") + '"><span class="material-symbols-outlined">chevron_right</span></button>' +
|
||||
"</div>" + gridHtml(viewY, viewM, holidays, today, bandClasses, opts.locale);
|
||||
}
|
||||
box.addEventListener("click", function (e) {
|
||||
const nav = e.target.closest(".pj-dp-navbtn");
|
||||
|
||||
@@ -46,6 +46,13 @@
|
||||
.lv-jump-day.is-today { outline: 2px solid #111; outline-offset: -2px; }
|
||||
.lv-tip { margin: 0; padding: 8px 12px; border: 1px solid var(--color-subtle-ash, #e5e5e5); border-radius: 10px; background: #f6f8fb; font-size: 13px; color: #374151; }
|
||||
|
||||
/* 표 + 오른쪽 달력(공용 erp-datepop 서식) */
|
||||
.lv-cal-row { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 14px; align-items: start; }
|
||||
.lv-side-cal { box-sizing: border-box; padding: 12px; border: 1px solid #cfd4dc; border-radius: 10px; background: #fff; font-size: 13px; }
|
||||
@media (max-width: 1100px) {
|
||||
.lv-cal-row { grid-template-columns: minmax(0, 1fr); }
|
||||
.lv-side-cal { max-width: 340px; }
|
||||
}
|
||||
.lv-cal-wrap { overflow: auto; max-height: calc(100vh - 150px); border: 1px solid #cfd4dc; border-radius: 10px; background: #fff; }
|
||||
.lv-cal { border-collapse: separate; border-spacing: 0; min-width: max-content; }
|
||||
.lv-cal th, .lv-cal td { border-right: 1px solid #e3e6eb; border-bottom: 1px solid #e3e6eb; }
|
||||
|
||||
+44
-6
@@ -4,6 +4,7 @@
|
||||
"use strict";
|
||||
const calWrap = document.getElementById("lv-cal-wrap");
|
||||
const CAL_POS = "lv_cal_left";
|
||||
const CAL_JUMP = "lv_cal_jump";
|
||||
function tr(text) { return (window.LV_T && window.LV_T[text]) || text; }
|
||||
const dialogText = function () { return { okText: tr("확인"), cancelText: tr("취소") }; };
|
||||
function reload() {
|
||||
@@ -131,17 +132,54 @@
|
||||
const time = calWrap.querySelector("thead .lv-cal-time");
|
||||
if (col && time) calWrap.scrollLeft += col.getBoundingClientRect().left - time.getBoundingClientRect().right;
|
||||
}
|
||||
// 마지막 날들도 맨 왼쪽까지 오도록 표 끝에 여백(표 상자 너비 − 시간 열 − 날짜 열 하나)
|
||||
function endGap() {
|
||||
const time = calWrap.querySelector("thead .lv-cal-time");
|
||||
const col = calWrap.querySelector("thead th[data-day]");
|
||||
const table = calWrap.querySelector("table");
|
||||
if (time && col && table) table.style.marginRight = Math.max(0, calWrap.clientWidth - time.offsetWidth - col.offsetWidth) + "px";
|
||||
}
|
||||
endGap();
|
||||
window.addEventListener("resize", endGap);
|
||||
|
||||
// ── 오른쪽 달력(공용 erp-datepop, 말레이시아 공휴일): 날짜를 누르면 그 날이 표 맨 왼쪽, 다른 달이면 그 달 화면으로 가서 맨 왼쪽 ──
|
||||
let pending = null;
|
||||
try { pending = sessionStorage.getItem(CAL_JUMP); sessionStorage.removeItem(CAL_JUMP); } catch (_) {}
|
||||
const hasDay = function (iso) { return !!iso && !!calWrap.querySelector('thead th[data-day="' + iso + '"]'); };
|
||||
const todayHead = calWrap.querySelector("thead th[data-today]");
|
||||
const firstHead = calWrap.querySelector("thead th[data-day]");
|
||||
const shownDay = hasDay(pending) ? pending : todayHead ? todayHead.dataset.day : firstHead && firstHead.dataset.day;
|
||||
const sideBox = document.getElementById("lv-side-cal");
|
||||
let sideCal = null;
|
||||
if (sideBox && window.ErpDatePop) {
|
||||
let holidays = {};
|
||||
try { holidays = JSON.parse(document.getElementById("lv-my-holidays").textContent); } catch (_) {}
|
||||
const english = document.querySelector(".lv").lang === "en";
|
||||
sideCal = window.ErpDatePop.mountRange(sideBox, {
|
||||
start: shownDay, end: shownDay, holidays: holidays, single: function () { return true; },
|
||||
locale: english ? {
|
||||
weekdays: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], prev: "Previous month", next: "Next month",
|
||||
title: function (y, m) { return new Date(y, m, 1).toLocaleString("en", { month: "long" }) + " " + y; },
|
||||
shortName: function (name) { return / \(Replacement\)$/.test(name) ? "Replacement" : name; },
|
||||
} : undefined,
|
||||
onChange: function (iso) {
|
||||
if (hasDay(iso)) { jumpTo(iso); return; }
|
||||
try { sessionStorage.setItem(CAL_JUMP, iso); } catch (_) {}
|
||||
location.href = "/live/calendar?month=" + iso.slice(0, 7);
|
||||
},
|
||||
});
|
||||
}
|
||||
document.addEventListener("click", function (e) {
|
||||
const b = e.target.closest("[data-jump]");
|
||||
if (b) jumpTo(b.dataset.jump);
|
||||
if (!b) return;
|
||||
jumpTo(b.dataset.jump);
|
||||
if (sideCal) sideCal.set(b.dataset.jump, b.dataset.jump);
|
||||
});
|
||||
let left = null;
|
||||
try { left = sessionStorage.getItem(CAL_POS); sessionStorage.removeItem(CAL_POS); } catch (_) {}
|
||||
if (left !== null) calWrap.scrollLeft = Number(left);
|
||||
else {
|
||||
const today = calWrap.querySelector("thead th[data-today]");
|
||||
if (today) jumpTo(today.dataset.day);
|
||||
}
|
||||
if (hasDay(pending)) jumpTo(pending);
|
||||
else if (left !== null) calWrap.scrollLeft = Number(left);
|
||||
else if (todayHead) jumpTo(todayHead.dataset.day);
|
||||
|
||||
// ── 달력: 날짜별 광고비 ──
|
||||
document.addEventListener("click", async function (e) {
|
||||
|
||||
Reference in New Issue
Block a user