From d4a98991e181eea28ac8c8e940c678070b6b0c5e Mon Sep 17 00:00:00 2001 From: Tomas Dvorak Date: Fri, 30 May 2025 10:46:40 +0200 Subject: [PATCH] etst --- admin-dashboard.html | 222 +++++++++++++++++++++++++++---------------- 1 file changed, 139 insertions(+), 83 deletions(-) diff --git a/admin-dashboard.html b/admin-dashboard.html index af447dd..b16df08 100644 --- a/admin-dashboard.html +++ b/admin-dashboard.html @@ -2761,17 +2761,23 @@ function updateBannerPreview() { const imagePreview = document.getElementById('imagePreview'); const imagePreviewContainer = document.getElementById('imagePreviewContainer'); - // Get the current template config or use modern as default - const defaultTemplate = templateConfigs['modern'] || {}; + // Get the current template config or use default if none selected + const defaultTemplate = templateConfigs['default'] || {}; const template = currentTemplate ? (templateConfigs[currentTemplate] || defaultTemplate) : defaultTemplate; const fileInput = document.getElementById('bannerImage'); const hasImage = Boolean(currentImage || (fileInput && fileInput.files && fileInput.files.length > 0)); - // Ensure template has required properties - if (!template.background && !template.backgroundColor) { - template.backgroundColor = template.backgroundColor || '#f8f9fa'; - template.background = template.background || template.backgroundColor; - } + // Get all form field values or use template defaults + const bannerBgColor = document.getElementById('bannerBgColor')?.value || template.backgroundColor || '#f8f9fa'; + const bannerTextColor = document.getElementById('bannerTextColor')?.value || template.textColor || '#212529'; + const bannerTextAlign = document.getElementById('bannerTextAlign')?.value || template.textAlign || 'left'; + const bannerFontSize = document.getElementById('bannerFontSize')?.value || template.fontSize || 16; + const bannerPadding = document.getElementById('bannerPadding')?.value || template.padding || 20; + const bannerMargin = document.getElementById('bannerMargin')?.value || template.margin || 20; + const bannerBorderRadius = document.getElementById('bannerBorderRadius')?.value || template.borderRadius || 8; + const bannerButtonBackground = document.getElementById('bannerButtonBackground')?.value || template.buttonBackground || '#4a6cf7'; + const bannerButtonTextColor = document.getElementById('bannerButtonTextColor')?.value || template.buttonTextColor || '#ffffff'; + const bannerButtonBorder = document.getElementById('bannerButtonBorder')?.value || template.buttonBorder || 'none'; // Always show templates section if (bannerTemplates) { @@ -2783,48 +2789,28 @@ function updateBannerPreview() { const bannerLink = document.getElementById('bannerLink')?.value || ''; const bannerTextContent = bannerText || 'Náhled banneru'; - // Get all styles from template or use defaults + // Get all styles from form fields or template defaults const styles = { // Background styles - background: (bannerBgColorPicker?.value || template.background || template.backgroundColor || '#f8f9fa').trim(), - backgroundColor: (bannerBgColorPicker?.value || template.backgroundColor || '#f8f9fa').trim(), + background: template.background || bannerBgColor, + backgroundColor: bannerBgColor, // Text styles - color: (bannerTextColorPicker?.value || template.textColor || template.textStyle?.match(/color:\s*([^;]+)/)?.[1] || '#212529').trim(), - textColor: (bannerTextColorPicker?.value || template.textColor || template.textStyle?.match(/color:\s*([^;]+)/)?.[1] || '#212529').trim(), - textAlign: (document.getElementById('bannerTextAlign')?.value || 'left').trim(), - fontSize: (document.getElementById('bannerFontSize')?.value ? `${document.getElementById('bannerFontSize').value}px` : '16px'), + color: bannerTextColor, + textColor: bannerTextColor, + textAlign: bannerTextAlign, + fontSize: `${bannerFontSize}px`, // Layout styles - padding: (document.getElementById('bannerPadding')?.value ? `${document.getElementById('bannerPadding').value}px` : '20px'), - margin: (document.getElementById('bannerMargin')?.value ? `${document.getElementById('bannerMargin').value}px` : '20px'), - borderRadius: (document.getElementById('bannerBorderRadius')?.value ? `${document.getElementById('bannerBorderRadius').value}px` : '8px'), + padding: `${bannerPadding}px`, + margin: `${bannerMargin}px`, + borderRadius: `${bannerBorderRadius}px`, - // Container styles - containerStyle: (template.containerStyle || '').trim() + // Button styles + buttonBackground: bannerButtonBackground, + buttonTextColor: bannerButtonTextColor, + buttonBorder: bannerButtonBorder }; - - // Special handling for specific templates - if (currentTemplate === 'modern') { - // Apply modern template specific styles - styles.background = template.background || styles.background; - styles.backgroundColor = template.backgroundColor || styles.backgroundColor; - styles.color = template.textColor || styles.color; - styles.textColor = template.textColor || styles.textColor; - - // Add text shadow for better readability - if (template.textStyle && template.textStyle.includes('text-shadow')) { - const match = template.textStyle.match(/text-shadow:\s*([^;]+)/); - if (match && match[1]) { - styles.textShadow = match[1]; - } - } - } else if (currentTemplate === 'dark') { - styles.background = '#2d3748'; - styles.backgroundColor = '#2d3748'; - styles.color = '#e2e8f0'; - styles.textColor = '#e2e8f0'; - } // Create text content with template styles const textStyle = ` @@ -2892,20 +2878,52 @@ function updateBannerPreview() { bannerContent = `