@@ -805,6 +834,36 @@ body.dark .nat-settings-license-row {
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {% for language in languages %}
+
+ {% endfor %}
+
+
+
+
+
+
+
+ Кликните по элементу в превью, чтобы перейти к его настройке
+
+
+ - Блоки и макет
- Настройки слайда @@ -1320,23 +1379,7 @@ body.dark .nat-settings-license-row {
-
-
-
-
+
-
-
-
-
-
-
-
-
- {% for language in languages %}
-
- {% endfor %}
-
-
@@ -3079,6 +3122,7 @@ function selectBlock(idx, event) {
if (event) event.stopPropagation();
currentBlockIndex = idx;
renderActiveBlocks();
+ if (typeof renderPreview === 'function') { renderPreview(); }
var block = slides[currentSlideIndex].blocks[idx];
$('#block-editor-container').show();
@@ -4419,18 +4463,42 @@ function renderPreview(langId) {
if (typeof currentSlideIndex === 'undefined' || currentSlideIndex < 0 || !slides[currentSlideIndex]) {
$('#slide-preview-bar').html('Выберите или добавьте слайд');
+ $('#preview-active-title').text('');
return;
}
var slide = slides[currentSlideIndex];
var $preview = $('#slide-preview-bar');
+ if (slide.title) {
+ $('#preview-active-title').text('Слайд: ' + slide.title);
+ } else {
+ $('#preview-active-title').text('');
+ }
+
+ // Dynamically load Google Font if specified
+ if (slide.font_family) {
+ var fontSlug = slide.font_family.replace(/\s+/g, '+');
+ if (!document.getElementById('nat-font-link-' + fontSlug)) {
+ var flink = document.createElement('link');
+ flink.id = 'nat-font-link-' + fontSlug;
+ flink.rel = 'stylesheet';
+ flink.href = 'https://fonts.googleapis.com/css2?family=' + fontSlug + ':wght@400;600;700&display=swap';
+ document.head.appendChild(flink);
+ }
+ }
+
// Apply slide styling
- var style = 'min-height: 40px; display: flex; align-items: center; justify-content: center; gap: 15px; padding: 10px 20px; transition: all 0.3s ease;';
+ var style = 'position: relative; min-height: 42px; display: flex; align-items: center; justify-content: center; gap: 15px; padding: 10px 40px 10px 20px; transition: all 0.2s ease;';
// Background
if (slide.bg_type === 'gradient') {
- style += 'background: ' + (slide.bg_gradient || 'linear-gradient(90deg, #ff416c, #ff4b2b)') + ';';
+ var grad = slide.bg_gradient || 'linear-gradient(90deg, #ff416c, #ff4b2b)';
+ if (slide.gradient_animated == '1' || $('#slide-gradient-animated').is(':checked')) {
+ style += 'background: ' + grad + '; background-size: 200% 200%; animation: natGradientShift 4s ease infinite;';
+ } else {
+ style += 'background: ' + grad + ';';
+ }
} else if (slide.bg_type === 'pattern') {
var bgPatternImg = $('#input-slide-bg-pattern').val();
if (bgPatternImg && bgPatternImg.indexOf('placeholder.png') === -1) {
@@ -4454,95 +4522,101 @@ function renderPreview(langId) {
$preview.empty();
if (!slide.blocks || slide.blocks.length === 0) {
- $preview.append('Пустой слайд (добавьте блоки справа)');
- return;
+ $preview.append('Пустой слайд (добавьте блоки в конструкторе)');
+ } else {
+ slide.blocks.forEach(function(block, idx) {
+ var blockHtml = '';
+ var blockStyle = '';
+ if (block.font_size) blockStyle += 'font-size: ' + block.font_size + ';';
+ if (block.font_weight) blockStyle += 'font-weight: ' + block.font_weight + ';';
+ if (block.font_family) blockStyle += 'font-family: "' + block.font_family + '", sans-serif;';
+ if (block.custom_css) blockStyle += block.custom_css + ';';
+
+ if (block.type === 'text') {
+ var isMobileActive = $('#preview-viewport-switch .preview-viewport-btn[data-viewport="mobile"]').hasClass('active');
+ var textVal = '';
+ if (isMobileActive && block.mobile_text && block.mobile_text[previewLangId]) {
+ textVal = block.mobile_text[previewLangId];
+ } else {
+ textVal = (block.text && block.text[previewLangId]) ? block.text[previewLangId] : '';
+ }
+ var textColor = block.color ? 'color: ' + block.color + ';' : '';
+ blockHtml = '' + (textVal || 'Текст') + '';
+
+ } else if (block.type === 'image') {
+ var imgPath = (block.image && block.image[previewLangId]) ? block.image[previewLangId] : '';
+ var imgThumb = (block.thumb && block.thumb[previewLangId]) ? block.thumb[previewLangId] : placeholder;
+ var imgW = block.width ? 'width: ' + block.width + 'px;' : '';
+ var imgH = block.height ? 'height: ' + block.height + 'px;' : 'height: 24px;';
+ if (imgPath) {
+ blockHtml = '
';
+ } else {
+ blockHtml = '
';
+ }
+
+ } else if (block.type === 'button') {
+ var btnText = (block.text && block.text[previewLangId]) ? block.text[previewLangId] : 'Кнопка';
+ var btnBg = block.bg || '#e74c3c';
+ var btnColor = block.color || '#ffffff';
+ var btnStyle = 'background: ' + btnBg + '; color: ' + btnColor + '; padding: 4px 14px; border-radius: 4px; font-weight: bold; text-decoration: none; font-size: 12px; display: inline-block; box-shadow: 0 2px 4px rgba(0,0,0,0.15); transition: all 0.2s ease;';
+ blockHtml = '' + btnText + '';
+
+ } else if (block.type === 'timer') {
+ var timerColor = block.color ? 'color: ' + block.color + ';' : '';
+ var timeStr = block.timer_mode === 'evergreen' ? ((block.timer_minutes || 5) + 'м 00с') : '23:59:59';
+ blockHtml = ' ' + timeStr + '';
+
+ } else if (block.type === 'shipping') {
+ var shText = (block.shipping_text_before && block.shipping_text_before[previewLangId]) ? block.shipping_text_before[previewLangId] : 'До бесплатной доставки осталось {diff}';
+ shText = shText.replace('{diff}', '500 грн');
+ blockHtml = '
';
- } else {
- blockHtml = '
';
- }
-
- } else if (block.type === 'button') {
- var btnText = (block.text && block.text[previewLangId]) ? block.text[previewLangId] : 'Кнопка';
- var btnBg = block.bg || '#e74c3c';
- var btnColor = block.color || '#ffffff';
- var btnStyle = 'background: ' + btnBg + '; color: ' + btnColor + '; padding: 4px 12px; border-radius: 4px; font-weight: bold; text-decoration: none; font-size: 12px; display: inline-block;';
- blockHtml = '' + btnText + '';
-
- } else if (block.type === 'timer') {
- var timerColor = block.color ? 'color: ' + block.color + ';' : '';
- var timeStr = block.timer_mode === 'evergreen' ? (block.timer_minutes + 'м') : '00:00:00';
- blockHtml = ' ' + timeStr + '';
-
- } else if (block.type === 'shipping') {
- var shText = (block.shipping_text_before && block.shipping_text_before[previewLangId]) ? block.shipping_text_before[previewLangId] : 'До бесплатной доставки осталось {diff}';
- shText = shText.replace('{diff}', '1000');
- blockHtml = '
';
+ blockHtml += ' ' + shText + '';
+ blockHtml += '
';
+
+ } else if (block.type === 'subscribe') {
+ var subPl = (block.subscribe_placeholder && block.subscribe_placeholder[previewLangId]) ? block.subscribe_placeholder[previewLangId] : 'Email...';
+ var subBtn = (block.subscribe_button_text && block.subscribe_button_text[previewLangId]) ? block.subscribe_button_text[previewLangId] : 'Ок';
+ blockHtml = '';
+ blockHtml += ' ';
+ blockHtml += '
';
+ blockHtml += '';
+ blockHtml += ' ';
+ blockHtml += ' ' + subBtn + '';
+ blockHtml += '
';
+
+ } else if (block.type === 'coupon') {
+ var cpText = (block.coupon_text && block.coupon_text[previewLangId]) ? block.coupon_text[previewLangId] : (block.coupon_code && block.coupon_code[previewLangId] ? block.coupon_code[previewLangId] : 'SALE20');
+ blockHtml = ' ' + cpText + '';
+
+ } else if (block.type === 'activity') {
+ var actText = (block.activity_text && block.activity_text[previewLangId]) ? block.activity_text[previewLangId] : 'Просмотров сейчас: {count}';
+ actText = actText.replace('{count}', '14');
+ var actColor = block.color ? 'color: ' + block.color + ';' : '';
+ blockHtml = ' ' + actText + '';
+
+ } else if (block.type === 'product') {
+ var pName = block.product_name || 'Товар дня';
+ blockHtml = ' ' + pName + '';
+
+ } else if (block.type === 'anim_icon') {
+ var iconColor = block.icon_color ? 'color: ' + block.icon_color + ';' : '';
+ blockHtml = '';
+ }
+
+ var isBlockActive = (typeof currentBlockIndex !== 'undefined' && currentBlockIndex === idx);
+ var activeOutline = isBlockActive ? 'outline: 2px solid #38bdf8; outline-offset: 3px; background: rgba(56, 189, 248, 0.15);' : '';
+ var blockItemWrapper = '' + blockHtml + '
';
+ $preview.append(blockItemWrapper);
+ });
}
- slide.blocks.forEach(function(block) {
- var blockHtml = '';
-
- // Inline style for block overrides
- var blockStyle = '';
- if (block.font_size) blockStyle += 'font-size: ' + block.font_size + ';';
- if (block.font_weight) blockStyle += 'font-weight: ' + block.font_weight + ';';
- if (block.font_family) blockStyle += 'font-family: "' + block.font_family + '", sans-serif;';
- if (block.custom_css) blockStyle += block.custom_css + ';';
-
- if (block.type === 'text') {
- var isMobileActive = $('#preview-viewport-switch .preview-viewport-btn[data-viewport="mobile"]').hasClass('active');
- var textVal = '';
- if (isMobileActive && block.mobile_text && block.mobile_text[previewLangId]) {
- textVal = block.mobile_text[previewLangId];
- } else {
- textVal = (block.text && block.text[previewLangId]) ? block.text[previewLangId] : '';
- }
- var textColor = block.color ? 'color: ' + block.color + ';' : '';
- blockHtml = '' + (textVal || 'Текст') + '';
-
- } else if (block.type === 'image') {
- var imgPath = (block.image && block.image[previewLangId]) ? block.image[previewLangId] : '';
- var imgThumb = (block.thumb && block.thumb[previewLangId]) ? block.thumb[previewLangId] : placeholder;
- var imgW = block.width ? 'width: ' + block.width + 'px;' : '';
- var imgH = block.height ? 'height: ' + block.height + 'px;' : 'height: 24px;';
- if (imgPath) {
- blockHtml = '';
- blockHtml += ' ' + shText + '';
- blockHtml += '
';
-
- } else if (block.type === 'subscribe') {
- var subPl = (block.subscribe_placeholder && block.subscribe_placeholder[previewLangId]) ? block.subscribe_placeholder[previewLangId] : 'Email...';
- var subBtn = (block.subscribe_button_text && block.subscribe_button_text[previewLangId]) ? block.subscribe_button_text[previewLangId] : 'Ок';
- blockHtml = '';
- blockHtml += ' ';
- blockHtml += '
';
- blockHtml += '';
- blockHtml += ' ';
- blockHtml += ' ' + subBtn + '';
- blockHtml += '
';
-
- } else if (block.type === 'coupon') {
- var cpText = (block.coupon_text && block.coupon_text[previewLangId]) ? block.coupon_text[previewLangId] : 'SALE10';
- blockHtml = ' ' + cpText + '';
-
- } else if (block.type === 'activity') {
- var actText = (block.activity_text && block.activity_text[previewLangId]) ? block.activity_text[previewLangId] : 'Просмотров сегодня: {count}';
- actText = actText.replace('{count}', '123');
- var actColor = block.color ? 'color: ' + block.color + ';' : '';
- blockHtml = ' ' + actText + '';
-
- } else if (block.type === 'product') {
- var pName = block.product_name || 'Товар';
- blockHtml = ' ' + pName + '';
-
- } else if (block.type === 'anim_icon') {
- var iconColor = block.icon_color ? 'color: ' + block.icon_color + ';' : '';
- blockHtml = '';
- }
-
- $preview.append(blockHtml);
- });
+ // Close Button in preview
+ if (slide.show_close !== '0' && $('#slide-show-close-select').val() !== '0') {
+ var closeColor = slide.text_color || '#ffffff';
+ var closeBtnHtml = '';
+ $preview.append(closeBtnHtml);
+ }
}
-
$(document).on('click', '.preview-lang-btn', function(e) {
e.preventDefault();
$('.preview-lang-btn').removeClass('active');
@@ -4562,9 +4636,9 @@ $(document).on('click', '.preview-viewport-btn', function(e) {
$wrapper.css({
'max-width': '375px',
'margin': '0 auto',
- 'border': '8px solid #333',
- 'border-radius': '20px',
- 'box-shadow': '0 4px 16px rgba(0,0,0,0.15)',
+ 'border': '8px solid #1e293b',
+ 'border-radius': '24px',
+ 'box-shadow': '0 8px 24px rgba(0,0,0,0.2)',
'transition': 'all 0.3s ease'
});
} else {
@@ -4572,15 +4646,41 @@ $(document).on('click', '.preview-viewport-btn', function(e) {
'max-width': '100%',
'margin': '0',
'border': '1px solid #cbd5e1',
- 'border-radius': '4px',
+ 'border-radius': '6px',
'box-shadow': 'none',
'transition': 'all 0.3s ease'
});
}
-
renderPreview();
});
+// Click-to-edit listener from within the preview bar
+$(document).on('click', '.preview-clickable-block', function(e) {
+ e.preventDefault();
+ var bIdx = parseInt($(this).attr('data-block-index'));
+ if (!isNaN(bIdx)) {
+ $('#slide-sub-tabs a[href="#slide-sub-blocks"]').tab('show');
+ if (typeof selectBlock === 'function') {
+ selectBlock(bIdx);
+ }
+ if ($('#block-editor-container').length && $('#block-editor-container').is(':visible')) {
+ $('html, body').animate({
+ scrollTop: $('#block-editor-container').offset().top - 140
+ }, 200);
+ }
+ }
+});
+
+// Global reactive listener: instant live updates on any input or change
+$(document).on('input change keyup',
+ '#slide-title-input, #slide-status-select, #slide-text-color, #slide-text-color-hex, #slide-bg-type, #slide-bg-color, #slide-bg-color-hex, #slide-show-close-select, #slide-font-family, #slide-custom-css, #slide-gradient-color1, #slide-gradient-color2, #slide-gradient-angle, #slide-gradient-type, #slide-gradient-animated, #slide-gradient-anim-speed, #input-slide-bg-pattern, .block-field-input, .block-color-picker, .block-color-hex, .block-field-checkbox, select[data-field], #coupon-code-global, .block-field-image-input',
+ function() {
+ if (typeof renderPreview === 'function') {
+ renderPreview();
+ }
+ }
+);
+
var recentColors = [];
try {
recentColors = JSON.parse(localStorage.getItem('nat_recent_colors') || '[]');
diff --git a/promo_top_bar_nat.ocmod.zip b/promo_top_bar_nat.ocmod.zip
index 4e8b4eb..592d1f6 100644
Binary files a/promo_top_bar_nat.ocmod.zip and b/promo_top_bar_nat.ocmod.zip differ