diff --git a/admin-dashboard.html b/admin-dashboard.html index d897a74..4469683 100644 --- a/admin-dashboard.html +++ b/admin-dashboard.html @@ -751,6 +751,18 @@ + +
+ +
+ + +
+
@@ -995,7 +1007,7 @@ function updateBannerPreview() { // No custom positioning, always right-aligned } -// Initialize template object if not exists +// Initialize template object let template = { containerStyle: '', textStyle: '', @@ -1327,9 +1339,11 @@ const presets = { }; // Variables for image positioning -let currentImagePosition = 'center'; // default position +let currentImagePosition = 'right'; // default position let currentImageX = '0'; let currentImageY = '0'; + +// Load banner data async function loadBanner() { try { const response = await fetch('/api/banner'); @@ -1358,10 +1372,22 @@ async function loadBanner() { } // Initialize image position variables once - currentImagePosition = data.Style?.ImagePosition || 'center'; + currentImagePosition = data.Style?.ImagePosition || 'right'; currentImageX = data.Style?.ImageX || '0'; currentImageY = data.Style?.ImageY || '0'; + // Update position buttons to reflect the loaded position + const positionButtons = document.querySelectorAll('.position-btn'); + if (positionButtons.length > 0) { + positionButtons.forEach(button => { + if (button.dataset.position === currentImagePosition) { + button.classList.add('active'); + } else { + button.classList.remove('active'); + } + }); + } + // Apply the saved template if it exists if (data.Style?.template && templateConfigs[data.Style.template]) { // Apply the template @@ -1553,6 +1579,9 @@ async function saveBanner(event) { formData.append('Style[ImagePosition]', currentImagePosition || 'right'); formData.append('Style[ImageX]', currentImageX || '0'); formData.append('Style[ImageY]', currentImageY || '0'); + formData.append('Style[ImagePosition]', currentImagePosition || 'right'); + formData.append('Style[ImageX]', currentImageX || '0'); + formData.append('Style[ImageY]', currentImageY || '0'); // Add template styles if available if (currentTemplate && templateConfigs[currentTemplate]) { @@ -1850,24 +1879,35 @@ function updateBannerPreview() { const bannerTextContent = bannerText || 'Náhled banneru'; if (hasImage && currentImage) { - // Get image dimensions (position is always right) + // Get image dimensions const imageWidth = parseInt(document.getElementById('bannerImageWidth')?.value || '300'); const imageHeight = parseInt(document.getElementById('bannerImageHeight')?.value || '200'); - const imagePosition = 'right'; // Always right-aligned - // Create image container fixed on the right side + // Get the selected position or default to 'right' + const position = currentImagePosition || 'right'; + + // Set max dimensions based on position const maxWidth = '30%'; const maxHeight = '300px'; - // Create flex container for right-aligned image + // Determine flex direction and alignment based on position + const flexDirection = position === 'left' ? 'row' : 'row-reverse'; + const alignSelf = 'flex-start'; + const marginLeft = position === 'left' ? '0' : 'auto'; + const marginRight = position === 'right' ? '0' : 'auto'; + + // Create flex container for the image let imgContainer = `