feat(inout): 오른쪽 발주·입고 달력·상품 그룹·색상·담당자 아이콘
- 모든 화면 2열, 오른쪽 300x320 달력(프로젝트 달력 모양) — 날짜별 발주·입고, 누르면 목록 - 옵션 → 상품 정보: 그룹(은 함유량·색상 한 번만), 상품별 그룹·색상(마이그레이션 006) - 발주 메일 품목 표에서 색상 있는 품목 줄 배경을 그 색으로(발주 당시 색상 사본) - 옵션 → 담당자 = 아이콘 + 이름, 아래 이메일 - 006 확인을 연결 열기 전에 해 동시 발주에서 연결 풀이 바닥나지 않게 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+96
-1
@@ -1,6 +1,6 @@
|
||||
/* 입출고 관리(inout) — ERP 공용(erp.css·erp-shell.css) 위에 이 화면만의 것 */
|
||||
/* 공용 .erp-page 는 width:100% + 안쪽 여백(content-box)이라 표가 넓으면 48px 넘친다 — 이 화면에서만 테두리 기준으로 */
|
||||
.erp-page:has(> .io) { box-sizing: border-box; }
|
||||
.erp-page:has(> .io), .erp-page:has(> .io-split) { box-sizing: border-box; }
|
||||
.io { display: flex; flex-direction: column; gap: 14px; min-width: 0; } /* 넓은 표는 안에서 가로 스크롤(페이지가 화면보다 넓어지지 않게) */
|
||||
.io-nav { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
|
||||
.io-nav-gap { flex: 1 1 auto; }
|
||||
@@ -321,3 +321,98 @@
|
||||
.io-receipt-bar #io-fill-remaining.is-filled { border-color: #1e7a34; color: #1e7a34; background: #f3fbf5; }
|
||||
/* 발주 메일 창 — 입고 담당 발주 알림 자동 발송 안내 */
|
||||
.io-mail-notice { margin: -4px 0 12px; padding: 8px 12px; border-radius: 8px; background: #f0f6ff; border: 1px solid #cfe0fb; color: #1d4f91; font-size: 12.5px; }
|
||||
|
||||
/* ── 2열 — 왼쪽 화면 | 오른쪽 달력(2026-10-21). 오른쪽 열 너비 = 달력 너비(300px), 스크롤해도 위에 붙어 있음.
|
||||
좁은 화면(1100px 미만)은 한 열 — 달력은 아래로. ── */
|
||||
.io-split { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 20px; align-items: start; }
|
||||
.io-split > .io { min-width: 0; }
|
||||
.io-side { width: 300px; position: sticky; top: 12px; display: flex; flex-direction: column; gap: 6px; }
|
||||
@media (max-width: 1100px) {
|
||||
.io-split { grid-template-columns: minmax(0, 1fr); }
|
||||
.io-side { position: static; }
|
||||
}
|
||||
/* 달력 300×320 — 프로젝트 달력 모양(.pj-cal)을 작게: 머리(제목 ‹ › 오늘) + 둥근 테두리 안 요일 줄(회색) + 6주 */
|
||||
.io-cal { width: 300px; height: 320px; box-sizing: border-box; display: flex; flex-direction: column; }
|
||||
.io-cal.is-loading .io-cal-days { opacity: .55; }
|
||||
.io-cal-head { flex: none; height: 36px; display: flex; align-items: center; gap: 4px; }
|
||||
.io-cal-title { margin: 0 2px; font-size: 16px; font-weight: 600; letter-spacing: -0.3px; white-space: nowrap; color: #0a0a0a; }
|
||||
.io-cal-nav, .io-cal-today {
|
||||
border: 1px solid var(--color-subtle-ash, #e5e5e5); background: #fff; border-radius: 8px; cursor: pointer; color: #0a0a0a;
|
||||
height: 28px; line-height: 1; padding: 0 9px; font-size: 13px;
|
||||
}
|
||||
.io-cal-nav { font-size: 18px; padding: 0 8px; }
|
||||
.io-cal-nav:hover, .io-cal-today:hover { background: #f5f5f5; }
|
||||
.io-cal-today { margin-left: auto; }
|
||||
.io-cal-box { flex: 1 1 auto; min-height: 0; border: 1px solid #e5e5e5; border-radius: 10px; overflow: hidden; display: flex; flex-direction: column; background: #fff; }
|
||||
.io-cal-wd { flex: none; display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); background: #f2f2f2; border-bottom: 1px solid #e5e5e5; }
|
||||
.io-cal-wd span { text-align: center; padding: 4px 0; font-size: 12px; font-weight: 600; color: #0a0a0a; }
|
||||
.io-cal-wd .is-sun { color: #c22b10; }
|
||||
.io-cal-wd .is-sat { color: #1d4ed8; }
|
||||
.io-cal-days { flex: 1 1 auto; min-height: 0; display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); grid-template-rows: repeat(6, minmax(0, 1fr)); }
|
||||
.io-cal-day {
|
||||
all: unset; box-sizing: border-box; min-width: 0; min-height: 0; padding: 3px 3px 2px; cursor: default;
|
||||
display: flex; flex-direction: column; align-items: center; gap: 1px;
|
||||
border-right: 1px solid #efefef; border-bottom: 1px solid #efefef;
|
||||
}
|
||||
.io-cal-day:nth-child(7n) { border-right: 0; }
|
||||
.io-cal-day:nth-last-child(-n+7) { border-bottom: 0; }
|
||||
.io-cal-day.has-ev { cursor: pointer; }
|
||||
.io-cal-day.has-ev:hover { background: #f2f6ff; }
|
||||
.io-cal-day:focus-visible { outline: 2px solid #1d4ed8; outline-offset: -2px; }
|
||||
.io-cal-num { font-size: 12px; font-weight: 600; color: #0a0a0a; line-height: 18px; min-width: 18px; text-align: center; border-radius: 9999px; }
|
||||
.io-cal-day.is-sun .io-cal-num { color: #c22b10; }
|
||||
.io-cal-day.is-sat .io-cal-num { color: #1d4ed8; }
|
||||
.io-cal-day.is-out { background: #fafafa; }
|
||||
.io-cal-day.is-out .io-cal-num { color: #bbb; }
|
||||
.io-cal-day.is-today { background: #f5f5f5; }
|
||||
.io-cal-day.is-today .io-cal-num { background: #0a0a0a; color: #fff; padding: 0 5px; }
|
||||
.io-cal-day.is-today.is-sun .io-cal-num { background: #c22b10; color: #fff; }
|
||||
.io-cal-day.is-today.is-sat .io-cal-num { background: #1d4ed8; color: #fff; }
|
||||
.io-cal-marks { display: flex; gap: 2px; flex-wrap: wrap; justify-content: center; }
|
||||
.io-cal-m { font-style: normal; display: inline-block; min-width: 14px; height: 14px; line-height: 14px; padding: 0 3px; box-sizing: border-box;
|
||||
border-radius: 7px; font-size: 10px; font-weight: 700; color: #fff; text-align: center; }
|
||||
.io-cal-m.is-order { background: #2f6fde; }
|
||||
.io-cal-m.is-receipt { background: #1e8e5a; }
|
||||
.io-cal-err { grid-column: 1 / -1; margin: auto; font-size: 12px; color: #a1261b; }
|
||||
.io-cal-legend { margin: 0; font-size: 11.5px; color: var(--color-midtone-gray, #666); display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
|
||||
.io-cal-legend .io-cal-m { margin-left: 4px; }
|
||||
.io-cal-legend .io-cal-m:first-child { margin-left: 0; }
|
||||
/* 그날 목록 팝업 — 프로젝트 달력 .pj-daypop 모양 */
|
||||
.io-calpop { position: absolute; z-index: 2100; width: 280px; max-height: 320px; overflow: auto; background: #fff; border: 1px solid #e2e5e9;
|
||||
border-radius: 12px; box-shadow: 0 8px 28px rgba(0,0,0,.16); padding: 8px; box-sizing: border-box; }
|
||||
.io-calpop-head { font-size: 12px; font-weight: 700; color: #525860; padding: 4px 6px 8px; }
|
||||
.io-calpop-head .is-hol { color: #c22b10; }
|
||||
.io-calpop-item { display: grid; grid-template-columns: auto minmax(0, 1fr); column-gap: 8px; align-items: center; padding: 6px; border-radius: 8px;
|
||||
text-decoration: none; color: #1e1f21; font-size: 12.5px; }
|
||||
.io-calpop-item:hover { background: #f2f4f6; }
|
||||
.io-calpop-item .io-cal-m { grid-row: span 2; height: 18px; line-height: 18px; border-radius: 9px; padding: 0 6px; font-size: 11px; }
|
||||
.io-calpop-main { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
||||
.io-calpop-sub { color: #6b6f76; font-size: 11.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
||||
|
||||
/* ── 옵션 → 담당자: 아이콘 + 이름, 아래 이메일(2026-10-21) ── */
|
||||
.io-person { display: inline-flex; align-items: center; gap: 8px; }
|
||||
.io-avatar { flex: none; width: 28px; height: 28px; border-radius: 50%; object-fit: cover; }
|
||||
.io-person-text { display: flex; flex-direction: column; line-height: 1.3; }
|
||||
.io-person-text .io-sub { display: block; }
|
||||
|
||||
/* ── 옵션 → 상품 정보: 그룹·색상(2026-10-21, 006) ── */
|
||||
.io-swatch { display: inline-block; flex: none; width: 14px; height: 14px; border-radius: 3px; border: 1px solid rgba(0,0,0,.18); vertical-align: middle; box-sizing: border-box; }
|
||||
.io-swatch.is-none { background: #fff !important; border-style: dashed; border-color: #b9bdc3; }
|
||||
.io-color { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
|
||||
.io-color .io-color-select { width: auto; min-width: 96px; }
|
||||
.io-groups { margin: 12px 20px 0; border: 1px solid #e6e8eb; border-radius: 10px; padding: 8px 10px; background: #fbfbfc; }
|
||||
.io-groups > summary { cursor: pointer; font-weight: 600; font-size: 13px; padding: 2px 0 6px; }
|
||||
.io-group-table col.w-gname { width: auto; }
|
||||
.io-group-table col.w-num { width: 120px; }
|
||||
.io-group-table col.w-color { width: 170px; }
|
||||
.io-group-table col.w-sort { width: 72px; }
|
||||
.io-group-table col.w-cnt { width: 60px; }
|
||||
.io-group-table col.w-btn { width: 128px; }
|
||||
.io-prod-table col.w-group { width: 130px; }
|
||||
.io-prod-table col.w-color { width: 150px; }
|
||||
.io-prod-table .io-group-select { width: 100%; }
|
||||
.io-prod-table .io-group-val { display: none; color: #4b5563; }
|
||||
.io-prod-table tr.is-grouped .io-own { display: none; }
|
||||
.io-prod-table tr.is-grouped .io-group-val { display: inline-flex; }
|
||||
.io-prod-table tr.is-grouped .io-group-val.io-r { display: block; padding-right: 9px; font-variant-numeric: tabular-nums; }
|
||||
.io-prod-table tr.is-grouped td:has(> .io-group-val) { background: #f6f8fb; }
|
||||
|
||||
+161
-6
@@ -332,6 +332,9 @@
|
||||
e.preventDefault();
|
||||
const sub = e.submitter;
|
||||
if (sub && sub.dataset.confirm && !(await confirmMsg(sub.dataset.confirm))) return;
|
||||
// 그룹 저장은 옵션을 다시 그린다 — 저장 안 한 상품 정보 변경이 사라지기 전에 묻는다
|
||||
if (form.classList.contains("io-group-form") && dirtyRows().length &&
|
||||
!(await confirmMsg("저장 안 한 상품 정보 변경이 있습니다. 버리고 그룹을 저장할까요?"))) return;
|
||||
const action = sub && sub.getAttribute("formaction") ? sub.getAttribute("formaction") : form.getAttribute("action");
|
||||
const buttons = Array.from(dlg.querySelectorAll("button[type=submit]"));
|
||||
buttons.forEach(function (b) { b.disabled = true; });
|
||||
@@ -351,10 +354,43 @@
|
||||
}
|
||||
});
|
||||
// ── 상품 정보 탭(004) — 단가·무게·은 함유량, 바뀐 줄만 [변경 저장], 불러오기·지우기·되살리기 ──
|
||||
// 006: 그룹(select)·색상(select) — 그룹 상품은 은 함유량·색상을 그룹 값으로 보여 준다(자기 값 칸은 숨김, 저장은 그대로).
|
||||
function isChanged(el) {
|
||||
if (el.tagName === "SELECT") {
|
||||
const d = Array.from(el.options).find(function (o) { return o.defaultSelected; }) || el.options[0];
|
||||
return el.value !== (d ? d.value : "");
|
||||
}
|
||||
return el.value.trim() !== el.defaultValue.trim();
|
||||
}
|
||||
function rowChanged(tr) { return Array.from(tr.querySelectorAll("[data-key]")).some(isChanged); }
|
||||
function dirtyRows() {
|
||||
return Array.from(body.querySelectorAll(".io-prod-table tbody tr")).filter(function (tr) {
|
||||
return Array.from(tr.querySelectorAll("input[data-key]")).some(function (i) { return i.value.trim() !== i.defaultValue.trim(); });
|
||||
});
|
||||
return Array.from(body.querySelectorAll(".io-prod-table tbody tr")).filter(rowChanged);
|
||||
}
|
||||
function paintSwatch(sel) {
|
||||
const sw = sel.parentNode && sel.parentNode.querySelector(".io-swatch");
|
||||
const opt = sel.options[sel.selectedIndex];
|
||||
const hex = opt ? opt.dataset.hex : "";
|
||||
if (!sw) return;
|
||||
sw.style.background = hex || "#fff";
|
||||
sw.classList.toggle("is-none", !hex);
|
||||
}
|
||||
// 그룹을 바꾸면 그 줄의 그룹 값(은 함유량·색상)을 고른 그룹 것으로 다시 보여 준다
|
||||
function paintGroup(tr) {
|
||||
const sel = tr.querySelector(".io-group-select");
|
||||
if (!sel) return;
|
||||
const opt = sel.options[sel.selectedIndex];
|
||||
const grouped = !!sel.value;
|
||||
tr.classList.toggle("is-grouped", grouped);
|
||||
const vals = tr.querySelectorAll(".io-group-val");
|
||||
if (vals[0]) vals[0].textContent = (opt && opt.dataset.silver) || "-";
|
||||
if (vals[1]) {
|
||||
const key = (opt && opt.dataset.color) || "none";
|
||||
const csel = tr.querySelector(".io-color-select");
|
||||
const copt = csel && Array.from(csel.options).find(function (o) { return o.value === key; });
|
||||
const sw = vals[1].querySelector(".io-swatch"), nm = vals[1].querySelector(".io-color-name");
|
||||
if (sw) { sw.style.background = (copt && copt.dataset.hex) || "#fff"; sw.classList.toggle("is-none", !(copt && copt.dataset.hex)); }
|
||||
if (nm) nm.textContent = copt ? copt.textContent : "";
|
||||
}
|
||||
}
|
||||
function paintDirty() {
|
||||
const n = dirtyRows().length;
|
||||
@@ -391,12 +427,17 @@
|
||||
if (cnt) cnt.textContent = q ? shown + "개 찾음" : cnt.dataset.base;
|
||||
return;
|
||||
}
|
||||
if (inp.classList && inp.classList.contains("io-color-select")) paintSwatch(inp); // 그룹 표·상품 표 공통
|
||||
if (!inp.dataset || !inp.dataset.key) return;
|
||||
const tr = inp.closest("tr");
|
||||
const w = dec(tr.querySelector('[data-key="weight_g"]').value), pct = dec(tr.querySelector('[data-key="silver_pct"]').value);
|
||||
if (inp.dataset.key === "group_id") paintGroup(tr);
|
||||
const gsel = tr.querySelector(".io-group-select");
|
||||
const gopt = gsel && gsel.value ? gsel.options[gsel.selectedIndex] : null;
|
||||
const w = dec(tr.querySelector('[data-key="weight_g"]').value);
|
||||
const pct = gopt ? dec(gopt.dataset.silver) : dec(tr.querySelector('[data-key="silver_pct"]').value);
|
||||
const ag = tr.querySelector(".io-ag");
|
||||
if (ag) ag.textContent = w !== null && pct !== null ? (Math.round(w * pct / 100 * 10000) / 10000).toLocaleString("ko-KR", { maximumFractionDigits: 4 }) : "-";
|
||||
tr.classList.toggle("is-dirty", Array.from(tr.querySelectorAll("input[data-key]")).some(function (i) { return i.value.trim() !== i.defaultValue.trim(); }));
|
||||
tr.classList.toggle("is-dirty", rowChanged(tr));
|
||||
paintDirty();
|
||||
});
|
||||
body.addEventListener("click", async function (e) {
|
||||
@@ -409,7 +450,9 @@
|
||||
} else if (t.closest("#io-prod-save")) {
|
||||
const rows = dirtyRows().map(function (tr) {
|
||||
const v = function (k) { return tr.querySelector('[data-key="' + k + '"]').value.trim(); };
|
||||
return { code: tr.dataset.code, unit_price: v("unit_price"), weight_g: v("weight_g"), silver_pct: v("silver_pct") };
|
||||
const row = { code: tr.dataset.code, unit_price: v("unit_price"), weight_g: v("weight_g"), silver_pct: v("silver_pct") };
|
||||
if (tr.querySelector('[data-key="group_id"]')) { row.group_id = v("group_id"); row.color = v("color"); } // 006
|
||||
return row;
|
||||
});
|
||||
if (rows.length) await act("/inout/settings/products/save", { rows: rows });
|
||||
} else if (t.dataset && t.dataset.exclude) {
|
||||
@@ -696,4 +739,116 @@
|
||||
});
|
||||
return { open: open };
|
||||
}
|
||||
|
||||
// ── 오른쪽 달력(2026-10-21) — 입출고 모든 화면. 프로젝트 달력과 같은 모양(일요일 시작·오늘 검은 동그라미·토 파랑·일/공휴일 빨강),
|
||||
// 날짜 칸 = 발주(파랑)·입고(초록) 건수, 누르면 그날 목록 팝업(발주서로 이동). 달 이동은 새로고침 없이 GET /inout/api/calendar.
|
||||
const calEl = document.getElementById("io-cal");
|
||||
if (calEl) initCalendar(calEl);
|
||||
|
||||
function initCalendar(cal) {
|
||||
const daysEl = cal.querySelector(".io-cal-days"), titleEl = cal.querySelector(".io-cal-title");
|
||||
let month = cal.dataset.month, data = null, pop = null, seq = 0;
|
||||
const pad = function (n) { return String(n).padStart(2, "0"); };
|
||||
const isoOf = function (d) { return d.getFullYear() + "-" + pad(d.getMonth() + 1) + "-" + pad(d.getDate()); };
|
||||
const escH = function (v) { const d = document.createElement("div"); d.textContent = v == null ? "" : String(v); return d.innerHTML; };
|
||||
const WD = "일월화수목금토";
|
||||
function shift(ym, step) {
|
||||
const p = ym.split("-").map(Number);
|
||||
const d = new Date(p[0], p[1] - 1 + step, 1);
|
||||
return d.getFullYear() + "-" + pad(d.getMonth() + 1);
|
||||
}
|
||||
function closePop() { if (pop) { pop.remove(); pop = null; } }
|
||||
async function load() {
|
||||
closePop();
|
||||
const p = month.split("-").map(Number);
|
||||
titleEl.textContent = p[0] + "년 " + p[1] + "월";
|
||||
const mine = ++seq; // 빠르게 넘기면 늦게 온 앞 달 응답이 덮지 않게
|
||||
cal.classList.add("is-loading");
|
||||
try {
|
||||
const res = await fetch("/inout/api/calendar?month=" + encodeURIComponent(month));
|
||||
if (!res.ok) throw new Error("HTTP " + res.status);
|
||||
const got = await res.json();
|
||||
if (mine !== seq) return;
|
||||
data = got;
|
||||
render();
|
||||
} catch (_) {
|
||||
if (mine !== seq) return;
|
||||
data = null;
|
||||
daysEl.innerHTML = '<p class="io-cal-err">달력을 불러오지 못했습니다.</p>';
|
||||
} finally {
|
||||
if (mine === seq) cal.classList.remove("is-loading");
|
||||
}
|
||||
}
|
||||
function render() {
|
||||
const start = new Date(data.start + "T00:00:00");
|
||||
let html = "";
|
||||
for (let i = 0; i < 42; i++) {
|
||||
const d = new Date(start.getFullYear(), start.getMonth(), start.getDate() + i);
|
||||
const iso = isoOf(d), wd = d.getDay();
|
||||
const ev = data.days[iso] || { orders: [], receipts: [] };
|
||||
const hol = data.holidays[iso] || "";
|
||||
const cls = ["io-cal-day"];
|
||||
if (iso.slice(0, 7) !== data.month) cls.push("is-out");
|
||||
if (iso === data.today) cls.push("is-today");
|
||||
if (wd === 0 || hol) cls.push("is-sun"); else if (wd === 6) cls.push("is-sat");
|
||||
if (ev.orders.length || ev.receipts.length) cls.push("has-ev");
|
||||
const tip = [iso.replace(/-/g, ".") + "(" + WD[wd] + ")" + (hol ? " " + hol : "")];
|
||||
if (ev.orders.length) tip.push("발주 " + ev.orders.length + "건");
|
||||
if (ev.receipts.length) tip.push("입고 " + ev.receipts.length + "건");
|
||||
html += '<button type="button" class="' + cls.join(" ") + '" data-date="' + iso + '" title="' + escH(tip.join(" · ")) + '">' +
|
||||
'<span class="io-cal-num">' + d.getDate() + "</span>" +
|
||||
'<span class="io-cal-marks">' +
|
||||
(ev.orders.length ? '<i class="io-cal-m is-order">' + ev.orders.length + "</i>" : "") +
|
||||
(ev.receipts.length ? '<i class="io-cal-m is-receipt">' + ev.receipts.length + "</i>" : "") +
|
||||
"</span></button>";
|
||||
}
|
||||
daysEl.innerHTML = html;
|
||||
}
|
||||
// 그날 목록 — body 에 붙이는 작은 팝업(달력 칸 아래, 화면 밖이면 위로)
|
||||
function openDay(btn) {
|
||||
closePop();
|
||||
const iso = btn.dataset.date;
|
||||
const ev = (data && data.days[iso]) || { orders: [], receipts: [] };
|
||||
if (!ev.orders.length && !ev.receipts.length) return;
|
||||
const d = new Date(iso + "T00:00:00"), hol = (data.holidays || {})[iso];
|
||||
const item = function (href, kind, label, main, sub) {
|
||||
return '<a class="io-calpop-item" href="' + href + '"><i class="io-cal-m ' + kind + '">' + label + "</i>" +
|
||||
'<span class="io-calpop-main">' + main + '</span><span class="io-calpop-sub">' + sub + "</span></a>";
|
||||
};
|
||||
let html = '<div class="io-calpop-head">' + iso.replace(/-/g, ".") + "(" + WD[d.getDay()] + ")" + (hol ? ' <span class="is-hol">' + escH(hol) + "</span>" : "") + "</div>";
|
||||
ev.orders.forEach(function (o) {
|
||||
html += item("/inout/orders/" + o.id, "is-order", "발주", escH(o.order_no) + " · " + escH(o.factory),
|
||||
escH(o.item) + " · " + Number(o.qty).toLocaleString("ko-KR") + "개");
|
||||
});
|
||||
ev.receipts.forEach(function (r) {
|
||||
html += item("/inout/orders/" + r.order_id, "is-receipt", "입고", escH(r.order_no) + " · " + escH(r.factory),
|
||||
Number(r.qty).toLocaleString("ko-KR") + "개 입고");
|
||||
});
|
||||
pop = document.createElement("div");
|
||||
pop.className = "io-calpop";
|
||||
pop.setAttribute("role", "dialog");
|
||||
pop.setAttribute("aria-label", iso + " 발주·입고");
|
||||
pop.innerHTML = html;
|
||||
document.body.appendChild(pop);
|
||||
const r = btn.getBoundingClientRect(), w = pop.offsetWidth, h = pop.offsetHeight;
|
||||
let left = Math.min(Math.max(8, r.left + r.width / 2 - w / 2), window.innerWidth - w - 8);
|
||||
let top = r.bottom + 6;
|
||||
if (top + h > window.innerHeight - 8) top = Math.max(8, r.top - h - 6);
|
||||
pop.style.left = left + window.scrollX + "px";
|
||||
pop.style.top = top + window.scrollY + "px";
|
||||
}
|
||||
cal.addEventListener("click", function (e) {
|
||||
const nav = e.target.closest(".io-cal-nav");
|
||||
if (nav) { month = shift(month, Number(nav.dataset.step)); load(); return; }
|
||||
if (e.target.closest(".io-cal-today")) { month = (data && data.today ? data.today : cal.dataset.month).slice(0, 7); load(); return; }
|
||||
const day = e.target.closest(".io-cal-day");
|
||||
if (day) { if (pop && pop.dataset.date === day.dataset.date) closePop(); else { openDay(day); if (pop) pop.dataset.date = day.dataset.date; } }
|
||||
});
|
||||
document.addEventListener("mousedown", function (e) {
|
||||
if (pop && !pop.contains(e.target) && !e.target.closest(".io-cal-day")) closePop();
|
||||
});
|
||||
document.addEventListener("keydown", function (e) { if (e.key === "Escape") closePop(); });
|
||||
window.addEventListener("resize", closePop);
|
||||
load();
|
||||
}
|
||||
})();
|
||||
|
||||
Reference in New Issue
Block a user