Release v2.0: URL upload, BBCode sharing, QR codes
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
+160
-1
@@ -420,7 +420,9 @@ body {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 8px;
|
||||
flex-wrap: wrap;
|
||||
gap: 6px;
|
||||
padding: 12px;
|
||||
background: rgba(0, 0, 0, 0.6);
|
||||
opacity: 0;
|
||||
transition: opacity 0.2s;
|
||||
@@ -1160,3 +1162,160 @@ body {
|
||||
.admin-table--groups td {
|
||||
vertical-align: top;
|
||||
}
|
||||
|
||||
.upload-tabs {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
.upload-tabs__btn {
|
||||
border: 1px solid var(--border);
|
||||
background: transparent;
|
||||
color: var(--text-muted);
|
||||
border-radius: 999px;
|
||||
padding: 8px 16px;
|
||||
cursor: pointer;
|
||||
font: inherit;
|
||||
}
|
||||
|
||||
.upload-tabs__btn--active {
|
||||
background: var(--accent);
|
||||
border-color: var(--accent);
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.upload-panel {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.upload-panel--active {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.url-upload {
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
.url-upload__label {
|
||||
display: block;
|
||||
margin-bottom: 8px;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.url-upload__input {
|
||||
width: 100%;
|
||||
min-height: 120px;
|
||||
padding: 12px;
|
||||
border: 1px solid var(--border);
|
||||
border-radius: var(--radius-sm);
|
||||
background: var(--bg-card);
|
||||
color: inherit;
|
||||
font: inherit;
|
||||
resize: vertical;
|
||||
}
|
||||
|
||||
.url-upload__hint {
|
||||
margin-top: 8px;
|
||||
font-size: 0.85rem;
|
||||
color: var(--text-muted);
|
||||
}
|
||||
|
||||
.share-modal[hidden] {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.share-modal {
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
z-index: 1000;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
.share-modal__backdrop {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
background: rgba(0, 0, 0, 0.65);
|
||||
}
|
||||
|
||||
.share-modal__dialog {
|
||||
position: relative;
|
||||
width: min(100%, 520px);
|
||||
max-height: 90vh;
|
||||
overflow-y: auto;
|
||||
background: var(--bg-card);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: var(--radius);
|
||||
padding: 24px;
|
||||
box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
|
||||
}
|
||||
|
||||
.share-modal__close {
|
||||
position: absolute;
|
||||
top: 12px;
|
||||
right: 12px;
|
||||
border: none;
|
||||
background: transparent;
|
||||
color: var(--text-muted);
|
||||
font-size: 1.5rem;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.share-modal__title {
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
.share-modal__name {
|
||||
margin-bottom: 16px;
|
||||
color: var(--text-muted);
|
||||
font-size: 0.9rem;
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
.share-modal__qr-wrap {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.share-modal__qr {
|
||||
width: 180px;
|
||||
height: 180px;
|
||||
border-radius: var(--radius-sm);
|
||||
background: #fff;
|
||||
padding: 8px;
|
||||
}
|
||||
|
||||
.share-field {
|
||||
margin-bottom: 14px;
|
||||
}
|
||||
|
||||
.share-field label {
|
||||
display: block;
|
||||
margin-bottom: 6px;
|
||||
font-size: 0.85rem;
|
||||
color: var(--text-muted);
|
||||
}
|
||||
|
||||
.share-field__row {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.share-field__row input {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
padding: 10px 12px;
|
||||
border: 1px solid var(--border);
|
||||
border-radius: var(--radius-sm);
|
||||
background: rgba(255, 255, 255, 0.03);
|
||||
color: inherit;
|
||||
font-size: 0.85rem;
|
||||
}
|
||||
|
||||
body.modal-open {
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
+108
-13
@@ -1,10 +1,31 @@
|
||||
document.addEventListener("DOMContentLoaded", () => {
|
||||
initUploadForm();
|
||||
initCopyButtons();
|
||||
initShareModal();
|
||||
});
|
||||
|
||||
function initUploadForm() {
|
||||
const dropzone = document.getElementById("dropzone");
|
||||
const photoInput = document.getElementById("photoInput");
|
||||
const preview = document.getElementById("preview");
|
||||
const previewImg = document.getElementById("previewImg");
|
||||
const previewName = document.getElementById("previewName");
|
||||
const submitBtn = document.getElementById("submitBtn");
|
||||
const uploadForm = document.getElementById("uploadForm");
|
||||
const tabButtons = document.querySelectorAll(".upload-tabs__btn");
|
||||
const panels = document.querySelectorAll(".upload-panel");
|
||||
|
||||
if (!uploadForm) return;
|
||||
|
||||
tabButtons.forEach((btn) => {
|
||||
btn.addEventListener("click", () => {
|
||||
const tab = btn.dataset.tab;
|
||||
tabButtons.forEach((item) => item.classList.toggle("upload-tabs__btn--active", item === btn));
|
||||
panels.forEach((panel) => {
|
||||
panel.classList.toggle("upload-panel--active", panel.dataset.panel === tab);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
if (!dropzone || !photoInput) return;
|
||||
|
||||
@@ -40,6 +61,25 @@ document.addEventListener("DOMContentLoaded", () => {
|
||||
}
|
||||
});
|
||||
|
||||
uploadForm.addEventListener("submit", (e) => {
|
||||
const activePanel = document.querySelector(".upload-panel--active");
|
||||
if (!activePanel) return;
|
||||
|
||||
if (activePanel.dataset.panel === "urls") {
|
||||
const urls = document.getElementById("imageUrls");
|
||||
if (!urls || !urls.value.trim()) {
|
||||
e.preventDefault();
|
||||
showToast("Укажите хотя бы одну ссылку");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (activePanel.dataset.panel === "files" && photoInput.files.length === 0) {
|
||||
e.preventDefault();
|
||||
showToast("Выберите файлы для загрузки");
|
||||
}
|
||||
});
|
||||
|
||||
function assignFiles(fileList) {
|
||||
const dt = new DataTransfer();
|
||||
const limit = Math.min(fileList.length, maxFiles);
|
||||
@@ -68,26 +108,81 @@ document.addEventListener("DOMContentLoaded", () => {
|
||||
};
|
||||
reader.readAsDataURL(first);
|
||||
}
|
||||
}
|
||||
|
||||
function initCopyButtons() {
|
||||
document.querySelectorAll(".copy-btn").forEach((btn) => {
|
||||
btn.addEventListener("click", async (e) => {
|
||||
e.stopPropagation();
|
||||
const url = btn.dataset.url;
|
||||
try {
|
||||
await navigator.clipboard.writeText(url);
|
||||
showToast("Ссылка скопирована!");
|
||||
} catch {
|
||||
const input = document.createElement("input");
|
||||
input.value = url;
|
||||
document.body.appendChild(input);
|
||||
input.select();
|
||||
document.execCommand("copy");
|
||||
document.body.removeChild(input);
|
||||
showToast("Ссылка скопирована!");
|
||||
const targetId = btn.dataset.target;
|
||||
const url = targetId
|
||||
? document.getElementById(targetId)?.value
|
||||
: btn.dataset.url;
|
||||
|
||||
if (!url) return;
|
||||
|
||||
const copied = await copyText(url);
|
||||
if (copied) {
|
||||
const label = btn.textContent.trim();
|
||||
showToast(label === "BBCode" ? "BBCode скопирован!" : "Скопировано!");
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function initShareModal() {
|
||||
const modal = document.getElementById("shareModal");
|
||||
if (!modal) return;
|
||||
|
||||
const urlInput = document.getElementById("shareModalUrl");
|
||||
const bbcodeInput = document.getElementById("shareModalBbcode");
|
||||
const htmlInput = document.getElementById("shareModalHtml");
|
||||
const qrImg = document.getElementById("shareModalQr");
|
||||
const nameEl = document.getElementById("shareModalName");
|
||||
|
||||
document.querySelectorAll(".share-qr-btn").forEach((btn) => {
|
||||
btn.addEventListener("click", (e) => {
|
||||
e.stopPropagation();
|
||||
urlInput.value = btn.dataset.url || "";
|
||||
bbcodeInput.value = btn.dataset.bbcode || "";
|
||||
htmlInput.value = btn.dataset.html || "";
|
||||
qrImg.src = btn.dataset.qr || "";
|
||||
nameEl.textContent = btn.dataset.name || "";
|
||||
modal.hidden = false;
|
||||
document.body.classList.add("modal-open");
|
||||
});
|
||||
});
|
||||
|
||||
modal.querySelectorAll("[data-close-share]").forEach((el) => {
|
||||
el.addEventListener("click", closeShareModal);
|
||||
});
|
||||
|
||||
document.addEventListener("keydown", (e) => {
|
||||
if (e.key === "Escape" && !modal.hidden) {
|
||||
closeShareModal();
|
||||
}
|
||||
});
|
||||
|
||||
function closeShareModal() {
|
||||
modal.hidden = true;
|
||||
document.body.classList.remove("modal-open");
|
||||
}
|
||||
}
|
||||
|
||||
async function copyText(text) {
|
||||
try {
|
||||
await navigator.clipboard.writeText(text);
|
||||
return true;
|
||||
} catch {
|
||||
const input = document.createElement("input");
|
||||
input.value = text;
|
||||
document.body.appendChild(input);
|
||||
input.select();
|
||||
const ok = document.execCommand("copy");
|
||||
document.body.removeChild(input);
|
||||
return ok;
|
||||
}
|
||||
}
|
||||
|
||||
function showToast(message) {
|
||||
const existing = document.querySelector(".toast");
|
||||
|
||||
Reference in New Issue
Block a user