diff --git a/admin-dashboard.html b/admin-dashboard.html index 06efad9..bd5b92a 100644 --- a/admin-dashboard.html +++ b/admin-dashboard.html @@ -1003,7 +1003,8 @@ function updateBannerPreview() { // Add image if exists if (hasImage) { - const imagePosition = document.querySelector('.image-pos-btn.active')?.dataset.pos || 'center'; + const activePosBtn = document.querySelector('.image-pos-btn.active, .position-btn.active'); + const imagePosition = activePosBtn ? activePosBtn.dataset.pos : (template?.imagePosition || 'right'); let imageStyle = 'max-width: 100%; max-height: 100%; object-fit: contain;'; // Apply position based on selection @@ -1046,7 +1047,8 @@ let template = { fontSize: 16, padding: 20, margin: 20, - borderRadius: 8 + borderRadius: 8, + imagePosition: 'right' // Default to right }; // Initialize when DOM is loaded @@ -1903,10 +1905,18 @@ function updateBannerPreview() { const bannerTextContent = bannerText || 'Náhled banneru'; if (hasImage && currentImage) { - // Get image dimensions and position from inputs or use defaults + // Get image dimensions from inputs or use defaults const imageWidth = parseInt(document.getElementById('bannerImageWidth')?.value || '300'); const imageHeight = parseInt(document.getElementById('bannerImageHeight')?.value || '200'); - const imagePosition = document.getElementById('bannerImagePosition')?.value || 'right'; + + // Get image position from active button or template + const activePosBtn = document.querySelector('.image-pos-btn.active, .position-btn.active'); + let imagePosition = activePosBtn ? activePosBtn.dataset.pos : (template?.imagePosition || 'right'); + + // Update template with current position + if (template) { + template.imagePosition = imagePosition; + } // Log the current position for debugging console.log('Image position:', imagePosition);