Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8a520b84fe | ||
|
|
df5cf0e30e |
+20
-2
@@ -102,7 +102,6 @@ body{font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,sans-serif;b
|
||||
|
||||
.grid{display:flex;flex-direction:column;gap:12px}
|
||||
.card{background:var(--card);border:1px solid var(--border);border-radius:var(--radius);padding:16px;display:flex;gap:16px;align-items:flex-start}
|
||||
.card img{width:80px;height:80px;border-radius:8px;object-fit:cover;flex-shrink:0;cursor:pointer}
|
||||
.card .info{flex:1;min-width:0}
|
||||
.card .name{font-weight:600;font-size:.95rem}
|
||||
.card .group{color:var(--accent);font-size:.8rem;margin-top:2px}
|
||||
@@ -136,8 +135,27 @@ body{font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,sans-serif;b
|
||||
.view-toggle button.active{background:var(--accent);color:#fff}
|
||||
.journal-cards{display:grid;grid-template-columns:repeat(4,1fr);gap:16px}
|
||||
.journal-card{background:var(--card);border:1px solid var(--border);border-radius:var(--radius);overflow:hidden;display:flex;flex-direction:column;position:relative}
|
||||
.journal-card img{width:100%;aspect-ratio:4/3;object-fit:cover;cursor:pointer;display:block;flex-shrink:0}
|
||||
.group-badge{position:absolute;top:8px;left:8px;z-index:2;max-width:calc(100% - 16px);background:rgba(0,0,0,.55);backdrop-filter:blur(4px);color:#fff;font-size:.72rem;font-weight:600;line-height:1.3;padding:3px 9px;border-radius:999px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
||||
|
||||
/* --- Индикатор загрузки фото в журнале --- */
|
||||
.img-media{position:relative;overflow:hidden;flex-shrink:0;display:block;background:var(--bg)}
|
||||
.journal-card .img-media{width:100%;aspect-ratio:4/3}
|
||||
.card > .img-media{width:80px;height:80px;border-radius:8px}
|
||||
.img-media img{width:100%;height:100%;object-fit:cover;cursor:pointer;display:block;position:relative;z-index:1;border-radius:inherit;transition:opacity .25s ease}
|
||||
.journal-card > .img-media img.img-load{opacity:0}
|
||||
.card > .img-media img.img-load{opacity:0}
|
||||
.img-media img.img-loaded{opacity:1}
|
||||
.img-media .img-skeleton{position:absolute;inset:0;z-index:0;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:6px;background:var(--bg);color:var(--muted);font-size:.62rem;text-align:center;padding:4px;line-height:1.2}
|
||||
.img-media .img-skeleton::before{content:'';position:absolute;inset:0;background:linear-gradient(100deg,transparent 20%,rgba(37,99,235,.09) 50%,transparent 80%);background-size:220% 100%;animation:imgShimmer 1.4s ease-in-out infinite}
|
||||
.img-media .img-skeleton .img-spin{position:relative;width:22px;height:22px;border-radius:50%;border:2px solid var(--border);border-top-color:var(--accent);animation:spin .7s linear infinite;flex-shrink:0}
|
||||
.card > .img-media .img-skeleton .img-spin{width:16px;height:16px;border-width:2px}
|
||||
.img-media .img-skeleton span{position:relative}
|
||||
.img-media img.img-error{opacity:0}
|
||||
.img-media img.img-error ~ .img-skeleton::before{animation:none}
|
||||
.img-media img.img-error ~ .img-skeleton .img-spin{display:none}
|
||||
.img-media img.img-error ~ .img-skeleton{color:var(--muted)}
|
||||
@keyframes imgShimmer{from{background-position:120% 0}to{background-position:-120% 0}}
|
||||
@media(prefers-reduced-motion:reduce){.img-media .img-skeleton::before,.img-media .img-skeleton .img-spin{animation:none}}
|
||||
.journal-card .no-photo{aspect-ratio:4/3;background:var(--bg);display:flex;align-items:center;justify-content:center;flex-shrink:0}
|
||||
.journal-card .no-photo svg{width:64%;height:64%;color:#c7cbd0}
|
||||
.journal-card .no-photo svg *{fill:currentColor}
|
||||
|
||||
@@ -537,6 +537,35 @@ function previewPhotoFile() {
|
||||
prev.style.display = 'block';
|
||||
}
|
||||
|
||||
function pasteGroupPhotoFile(e) {
|
||||
const modal = document.getElementById('photoFormModal');
|
||||
if (!modal || !modal.classList.contains('open')) return;
|
||||
if (editingPhotoId) return;
|
||||
const active = document.activeElement;
|
||||
if (active && active.id === 'photoCaption') return;
|
||||
const items = e.clipboardData && e.clipboardData.items;
|
||||
if (!items) return;
|
||||
for (const item of items) {
|
||||
if (item.type && item.type.startsWith('image/')) {
|
||||
const file = item.getAsFile();
|
||||
if (!file) continue;
|
||||
e.preventDefault();
|
||||
let named = file;
|
||||
if (!/\.[a-z0-9]{2,5}$/i.test(file.name || '')) {
|
||||
const m = /^image\/([a-z0-9.+-]+)$/i.exec(file.type || '');
|
||||
let ext = m ? m[1].toLowerCase() : 'png';
|
||||
if (ext === 'jpeg') ext = 'jpg';
|
||||
named = new File([file], `photo-${Date.now()}.${ext}`, { type: file.type || 'image/png', lastModified: file.lastModified });
|
||||
}
|
||||
const dt = new DataTransfer();
|
||||
dt.items.add(named);
|
||||
document.getElementById('photoFile').files = dt.files;
|
||||
previewPhotoFile();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async function savePhotoForm() {
|
||||
const caption = document.getElementById('photoCaption').value.trim();
|
||||
const taken_at = document.getElementById('photoTakenAt').value;
|
||||
@@ -710,6 +739,7 @@ async function downloadGroupFiles() {
|
||||
document.getElementById('newGroup').addEventListener('keydown', e => { if (e.key === 'Enter') addGroup(); });
|
||||
document.getElementById('addGroupBtn').addEventListener('click', addGroup);
|
||||
document.getElementById('photoFile').addEventListener('change', previewPhotoFile);
|
||||
document.addEventListener('paste', pasteGroupPhotoFile);
|
||||
document.getElementById('photoForm').addEventListener('submit', e => {
|
||||
e.preventDefault();
|
||||
savePhotoForm();
|
||||
|
||||
+47
-2
@@ -49,6 +49,10 @@ function mainPhotoPath(e) {
|
||||
return null;
|
||||
}
|
||||
|
||||
function journalImgHTML(mp) {
|
||||
return `<div class="img-media"><img class="img-load" src="${thumbSrc(mp)}" data-img="${API}${mp}" loading="lazy" decoding="async" alt=""><div class="img-skeleton"><span class="img-spin"></span><span>Загрузка…</span></div></div>`;
|
||||
}
|
||||
|
||||
const REPORT_CARD_FIELDS = [
|
||||
{ key: 'photo', label: 'Фото' },
|
||||
{ key: 'lastname', label: 'Фамилия' },
|
||||
@@ -251,7 +255,7 @@ function gridEntryHTML(e) {
|
||||
const mp = mainPhotoPath(e);
|
||||
return `
|
||||
<div class="card${highlightNewIds.has(e.id) ? ' entry-appear' : ' entry-enter'}">
|
||||
${mp ? `<img src="${thumbSrc(mp)}" data-img="${API}${mp}" loading="lazy" decoding="async" alt="">` : ''}
|
||||
${mp ? journalImgHTML(mp) : ''}
|
||||
<div class="info">
|
||||
<div class="name">${esc(e.student_name)}</div>
|
||||
<div class="group">${esc(e.group_name)}${e.module_name ? ' · ' + esc(e.module_name) : ''}</div>
|
||||
@@ -272,7 +276,7 @@ function cardEntryHTML(e) {
|
||||
return `
|
||||
<div class="journal-card${highlightNewIds.has(e.id) ? ' entry-appear' : ' entry-enter'}">
|
||||
${mp
|
||||
? `<img src="${thumbSrc(mp)}" data-img="${API}${mp}" loading="lazy" decoding="async" alt="">`
|
||||
? journalImgHTML(mp)
|
||||
: `<div class="no-photo"><svg viewBox="0 0 240 160" preserveAspectRatio="xMidYMid meet" aria-hidden="true"><circle cx="105" cy="48" r="15"/><path d="M74 140 C74 106 88 92 105 92 C122 92 136 106 136 140 Z"/><circle cx="145" cy="58" r="18"/><path d="M108 144 C108 104 124 88 145 88 C166 88 182 104 182 144 Z"/></svg></div>`}
|
||||
${e.group_name ? `<span class="group-badge" title="${esc(e.group_name)}">${esc(e.group_name)}</span>` : ''}
|
||||
${e.module_name ? `<span class="group-badge" style="left:auto;right:8px;background:rgba(37,99,235,.8)" title="Модуль: ${esc(e.module_name)}">${esc(e.module_name)}</span>` : ''}
|
||||
@@ -320,6 +324,45 @@ function renderGrid() {
|
||||
el.style.animationDelay = `${Math.min(i * 45, 500)}ms`;
|
||||
});
|
||||
renderIcons();
|
||||
settleJournalThumbs(grid);
|
||||
}
|
||||
|
||||
function settleJournalThumbs(root) {
|
||||
if (!root) return;
|
||||
root.querySelectorAll('.img-media img.img-load, .img-media img.img-error').forEach((img) => {
|
||||
if (img.complete && img.naturalWidth > 0) {
|
||||
img.classList.remove('img-load', 'img-error');
|
||||
img.classList.add('img-loaded');
|
||||
} else if (img.complete && img.naturalWidth === 0) {
|
||||
img.classList.remove('img-load');
|
||||
img.classList.add('img-error');
|
||||
const sk = img.parentElement && img.parentElement.querySelector('.img-skeleton');
|
||||
if (sk) sk.innerHTML = '<span>Нет фото</span>';
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function bindJournalThumbLoading() {
|
||||
const grid = document.getElementById('grid');
|
||||
if (!grid) return;
|
||||
const settle = (img) => {
|
||||
if (!img || !img.classList) return;
|
||||
img.classList.remove('img-load', 'img-error');
|
||||
img.classList.add('img-loaded');
|
||||
};
|
||||
const fail = (img) => {
|
||||
if (!img || !img.classList) return;
|
||||
img.classList.remove('img-load');
|
||||
img.classList.add('img-error');
|
||||
const sk = img.parentElement && img.parentElement.querySelector('.img-skeleton');
|
||||
if (sk) sk.innerHTML = '<span>Нет фото</span>';
|
||||
};
|
||||
grid.addEventListener('load', (e) => {
|
||||
if (e.target.tagName === 'IMG') settle(e.target);
|
||||
}, true);
|
||||
grid.addEventListener('error', (e) => {
|
||||
if (e.target.tagName === 'IMG') fail(e.target);
|
||||
}, true);
|
||||
}
|
||||
|
||||
function refreshEntryCardDom(e) {
|
||||
@@ -333,6 +376,7 @@ function refreshEntryCardDom(e) {
|
||||
fresh.style.animationDelay = '';
|
||||
card.replaceWith(fresh);
|
||||
renderIcons();
|
||||
settleJournalThumbs(fresh);
|
||||
}
|
||||
|
||||
async function refreshEntryCard(id) {
|
||||
@@ -1953,6 +1997,7 @@ document.getElementById('linkCopyBtn').addEventListener('click', copyLink);
|
||||
(async () => {
|
||||
if (await checkAuth()) {
|
||||
buildSidebar(document.body.dataset.page);
|
||||
bindJournalThumbLoading();
|
||||
document.querySelectorAll('#viewToggle button').forEach(b => {
|
||||
b.classList.toggle('active', b.dataset.view === view);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user