mirror of
https://github.com/Dvorinka/PPve.git
synced 2026-06-05 04:52:58 +00:00
tes
This commit is contained in:
+11
-12
@@ -1542,25 +1542,24 @@ async function saveBanner(event) {
|
|||||||
formData.append('link', bannerLink ? bannerLink.value : '');
|
formData.append('link', bannerLink ? bannerLink.value : '');
|
||||||
formData.append('isVisible', bannerVisible ? bannerVisible.value : 'true');
|
formData.append('isVisible', bannerVisible ? bannerVisible.value : 'true');
|
||||||
|
|
||||||
// Add style.isVisible to the form data for the API
|
// Always send the banner visibility
|
||||||
|
formData.append('isVisible', bannerVisible ? bannerVisible.value : 'true');
|
||||||
formData.append('style[isVisible]', bannerVisible ? bannerVisible.value : 'true');
|
formData.append('style[isVisible]', bannerVisible ? bannerVisible.value : 'true');
|
||||||
|
|
||||||
// Get the current template or use default
|
// Get the current template or use default
|
||||||
const template = currentTemplate ? templateConfigs[currentTemplate] : templateConfigs['modern-minimal'];
|
const template = currentTemplate ? templateConfigs[currentTemplate] : templateConfigs['modern-minimal'];
|
||||||
|
|
||||||
// Add template data
|
// Add template name
|
||||||
if (template) {
|
|
||||||
formData.append('template', currentTemplate || 'modern-minimal');
|
formData.append('template', currentTemplate || 'modern-minimal');
|
||||||
|
|
||||||
// Add template styles
|
// Add styles - use custom values if they exist, otherwise use template defaults
|
||||||
formData.append('style[backgroundColor]', template.bgColor || '#f8f9fa');
|
formData.append('style[backgroundColor]', bannerBgColorPicker ? bannerBgColorPicker.value : (template?.bgColor || '#f8f9fa'));
|
||||||
formData.append('style[textColor]', template.textColor || '#212529');
|
formData.append('style[textColor]', bannerTextColorPicker ? bannerTextColorPicker.value : (template?.textColor || '#212529'));
|
||||||
formData.append('style[textAlign]', template.textAlign || 'left');
|
formData.append('style[textAlign]', template?.textAlign || 'left');
|
||||||
formData.append('style[fontSize]', template.fontSize ? `${template.fontSize}px` : '16px');
|
formData.append('style[fontSize]', template?.fontSize ? `${template.fontSize}px` : '16px');
|
||||||
formData.append('style[padding]', template.padding ? `${template.padding}px` : '20px');
|
formData.append('style[padding]', template?.padding ? `${template.padding}px` : '20px');
|
||||||
formData.append('style[margin]', template.margin ? `${template.margin}px` : '20px');
|
formData.append('style[margin]', template?.margin ? `${template.margin}px` : '20px');
|
||||||
formData.append('style[borderRadius]', template.borderRadius ? `${template.borderRadius}px` : '8px');
|
formData.append('style[borderRadius]', template?.borderRadius ? `${template.borderRadius}px` : '8px');
|
||||||
}
|
|
||||||
|
|
||||||
// Add image position
|
// Add image position
|
||||||
const imagePosition = document.querySelector('.image-pos-btn.active')?.dataset.pos || 'center';
|
const imagePosition = document.querySelector('.image-pos-btn.active')?.dataset.pos || 'center';
|
||||||
|
|||||||
+23
-9
@@ -30,8 +30,19 @@
|
|||||||
// Log the banner data for debugging
|
// Log the banner data for debugging
|
||||||
console.log('Banner data:', JSON.stringify(banner, null, 2));
|
console.log('Banner data:', JSON.stringify(banner, null, 2));
|
||||||
|
|
||||||
// Check if banner should be visible
|
// Check if banner should be visible - handle different cases and string/boolean values
|
||||||
const isVisible = banner.Style?.IsVisible ?? banner.IsVisible ?? true;
|
const isVisible = (() => {
|
||||||
|
// Check all possible locations and formats for visibility flag
|
||||||
|
const visibility = banner.Style?.IsVisible ?? banner.Style?.isVisible ??
|
||||||
|
banner.IsVisible ?? banner.isVisible ?? banner.visible;
|
||||||
|
|
||||||
|
// Handle both string and boolean values
|
||||||
|
if (typeof visibility === 'string') {
|
||||||
|
return visibility.toLowerCase() === 'true';
|
||||||
|
}
|
||||||
|
return Boolean(visibility !== false); // default to true if not explicitly set to false
|
||||||
|
})();
|
||||||
|
|
||||||
if (!isVisible) {
|
if (!isVisible) {
|
||||||
console.log('Banner is not visible');
|
console.log('Banner is not visible');
|
||||||
return;
|
return;
|
||||||
@@ -45,11 +56,11 @@
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get style values with fallbacks
|
// Get style values with fallbacks - handle both nested style and direct properties
|
||||||
const style = banner.style || {};
|
const style = banner.Style || banner.style || {};
|
||||||
const borderRadius = style.borderRadius || '8';
|
const borderRadius = style.borderRadius || '8';
|
||||||
const backgroundColor = style.backgroundColor || '#f8f9fa';
|
const backgroundColor = style.backgroundColor || style.background || '#f8f9fa';
|
||||||
const textColor = style.textColor || '#212529';
|
const textColor = style.textColor || style.color || '#212529';
|
||||||
const textAlign = style.textAlign || 'left';
|
const textAlign = style.textAlign || 'left';
|
||||||
const fontSize = style.fontSize || '16px';
|
const fontSize = style.fontSize || '16px';
|
||||||
const padding = style.padding || '20px';
|
const padding = style.padding || '20px';
|
||||||
@@ -82,8 +93,11 @@
|
|||||||
|
|
||||||
if (bannerImage) {
|
if (bannerImage) {
|
||||||
// Ensure the image URL is correct (add leading slash if missing)
|
// Ensure the image URL is correct (add leading slash if missing)
|
||||||
let imageUrl = bannerImage.startsWith('http') ? bannerImage :
|
let imageUrl = bannerImage;
|
||||||
bannerImage.startsWith('/') ? bannerImage : `/${bannerImage}`;
|
if (typeof imageUrl === 'string') {
|
||||||
|
imageUrl = imageUrl.startsWith('http') ? imageUrl :
|
||||||
|
imageUrl.startsWith('/') ? imageUrl : `/${imageUrl}`;
|
||||||
|
}
|
||||||
|
|
||||||
// Use default dimensions if not specified or 0
|
// Use default dimensions if not specified or 0
|
||||||
const imageWidth = (style.imageWidth && style.imageWidth > 0) ? style.imageWidth : 'auto';
|
const imageWidth = (style.imageWidth && style.imageWidth > 0) ? style.imageWidth : 'auto';
|
||||||
@@ -104,7 +118,7 @@
|
|||||||
`;
|
`;
|
||||||
|
|
||||||
// Create image container
|
// Create image container
|
||||||
const imgContainer = `
|
let imgContainer = `
|
||||||
<div class="banner-image-container" style="
|
<div class="banner-image-container" style="
|
||||||
display: block;
|
display: block;
|
||||||
max-width: 100%;
|
max-width: 100%;
|
||||||
|
|||||||
Reference in New Issue
Block a user