upload z zjec z galerii + prettycode
This commit is contained in:
@@ -305,4 +305,10 @@ input.form-control {
|
||||
.fade-out {
|
||||
opacity: 0;
|
||||
transition: opacity 0.5s ease;
|
||||
}
|
||||
|
||||
@media (pointer: fine) {
|
||||
.only-mobile {
|
||||
display: none !important;
|
||||
}
|
||||
}
|
@@ -5,12 +5,24 @@ if (!window.receiptUploaderInitialized) {
|
||||
const form = document.getElementById("receiptForm");
|
||||
const inputCamera = document.getElementById("cameraInput");
|
||||
const inputGallery = document.getElementById("galleryInput");
|
||||
const galleryBtn = document.getElementById("galleryBtn");
|
||||
const galleryBtnText = document.getElementById("galleryBtnText");
|
||||
const cameraBtn = document.getElementById("cameraBtn");
|
||||
const progressContainer = document.getElementById("progressContainer");
|
||||
const progressBar = document.getElementById("progressBar");
|
||||
const gallery = document.getElementById("receiptGallery");
|
||||
|
||||
if (!form || !inputCamera || !inputGallery || !gallery) return;
|
||||
|
||||
const isDesktop = window.matchMedia("(pointer: fine)").matches;
|
||||
|
||||
// 🧼 Jedno miejsce, pełna logika desktopowa
|
||||
if (isDesktop) {
|
||||
if (cameraBtn) cameraBtn.remove(); // całkowicie usuń przycisk
|
||||
if (inputCamera) inputCamera.remove(); // oraz input
|
||||
if (galleryBtnText) galleryBtnText.textContent = "➕ Dodaj paragon";
|
||||
}
|
||||
|
||||
function handleFileUpload(inputElement) {
|
||||
const file = inputElement.files[0];
|
||||
if (!file) {
|
||||
@@ -44,6 +56,7 @@ if (!window.receiptUploaderInitialized) {
|
||||
progressBar.style.width = "0%";
|
||||
progressBar.textContent = "";
|
||||
inputElement.value = "";
|
||||
window.receiptToastShown = false;
|
||||
};
|
||||
|
||||
xhr.onreadystatechange = function () {
|
||||
@@ -83,22 +96,9 @@ if (!window.receiptUploaderInitialized) {
|
||||
xhr.send(formData);
|
||||
}
|
||||
|
||||
inputCamera.addEventListener("change", () => handleFileUpload(inputCamera));
|
||||
inputGallery.addEventListener("change", () => handleFileUpload(inputGallery));
|
||||
inputCamera?.addEventListener("change", () => handleFileUpload(inputCamera));
|
||||
inputGallery?.addEventListener("change", () => handleFileUpload(inputGallery));
|
||||
});
|
||||
|
||||
window.receiptUploaderInitialized = true;
|
||||
}
|
||||
|
||||
document.addEventListener("DOMContentLoaded", function () {
|
||||
const galleryBtn = document.getElementById("galleryBtn");
|
||||
const galleryInput = document.getElementById("galleryInput");
|
||||
|
||||
const isProbablyMobile =
|
||||
window.matchMedia("(pointer: coarse)").matches || /Mobi|Android|iPhone|iPad/i.test(navigator.userAgent);
|
||||
|
||||
if (!isProbablyMobile && galleryBtn && galleryInput) {
|
||||
galleryBtn.style.display = "none";
|
||||
galleryInput.disabled = true;
|
||||
}
|
||||
});
|
||||
|
Reference in New Issue
Block a user