The store will not work correctly when cookies are disabled.
Esqueceu a sua senha?
","submitUrl":"https://www.lineaalimentos.com.br/popupmanager/newsletter/subscribe","sectionsUrl":"https://www.lineaalimentos.com.br/customer/section/load/?sections=messages"};
var urlParams = '';
try { urlParams = window.location.search; } catch(e) {}
var isForce = urlParams.indexOf('force_popup=1') !== -1 || urlParams.indexOf('dizy_preview=1') !== -1 || urlParams.indexOf('preview=1') !== -1;
// Check localStorage retention
var storageKey = 'dizy_popup_manager_seen_' + config.id;
if (config.redisplayDays > 0 && !isForce) {
try {
var savedData = localStorage.getItem(storageKey);
if (savedData) {
var parsed = JSON.parse(savedData);
if (parsed.seen && parsed.timestamp) {
var daysDiff = (Date.now() - parsed.timestamp) / (1000 * 60 * 60 * 24);
if (daysDiff < config.redisplayDays) {
console.log('[DizyPopupManager] Pop-up ' + config.id + ' retido por localStorage (' + daysDiff.toFixed(1) + ' de ' + config.redisplayDays + ' dias). Para forçar a exibição no teste, adicione ?force_popup=1 no URL.');
return;
}
}
}
} catch(e) {}
}
function initPopup() {
if (document.getElementById('dizy-popup-overlay-' + config.id)) {
return; // Prevent duplicate popup injection
}
// Inject CSS Styles
var style = document.createElement('style');
style.type = 'text/css';
style.innerHTML = `
.dizy-popup-overlay {
position: fixed;
top: 0; left: 0; right: 0; bottom: 0;
background-color: ${config.bgOverlayColor};
z-index: 999999;
display: flex;
opacity: 0;
transition: opacity 0.3s ease;
}
.dizy-popup-overlay.dizy-visible { opacity: 1; }
/* Positions */
.dizy-popup-overlay.pos-center { align-items: center; justify-content: center; }
.dizy-popup-overlay.pos-top_left { align-items: flex-start; justify-content: flex-start; padding: 20px; }
.dizy-popup-overlay.pos-top_right { align-items: flex-start; justify-content: flex-end; padding: 20px; }
.dizy-popup-overlay.pos-bottom_left { align-items: flex-end; justify-content: flex-start; padding: 20px; }
.dizy-popup-overlay.pos-bottom_right { align-items: flex-end; justify-content: flex-end; padding: 20px; }
.dizy-popup-container {
position: relative;
width: 100%;
max-width: 780px;
background-color: ${config.bgContainerColor};
border-radius: ${config.borderRadius}px;
box-shadow: 0 20px 40px rgba(0,0,0,0.25);
overflow: hidden;
display: flex;
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
transition: transform 0.3s ease, opacity 0.3s ease;
}
/* Keyframe Animations */
@keyframes dizySlideTop { from { transform: translateY(-50px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@keyframes dizySlideBottom { from { transform: translateY(50px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@keyframes dizySlideLeft { from { transform: translateX(-50px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes dizySlideRight { from { transform: translateX(50px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes dizyFadeIn { from { opacity: 0; } to { opacity: 1; } }
.dizy-popup-container.anim-slide_top { animation: dizySlideTop 0.4s ease forwards; }
.dizy-popup-container.anim-slide_bottom { animation: dizySlideBottom 0.4s ease forwards; }
.dizy-popup-container.anim-slide_left { animation: dizySlideLeft 0.4s ease forwards; }
.dizy-popup-container.anim-slide_right { animation: dizySlideRight 0.4s ease forwards; }
.dizy-popup-container.anim-fade { animation: dizyFadeIn 0.4s ease forwards; }
.dizy-popup-close {
position: absolute;
top: 12px;
right: 16px;
font-size: 24px;
font-weight: 300;
color: #888;
cursor: pointer;
line-height: 1;
z-index: 10;
background: none;
border: none;
padding: 0;
}
.dizy-popup-close:hover { color: #000; }
.dizy-popup-body {
display: flex;
width: 100%;
min-height: 600px;
}
.dizy-popup-body.no-image {
flex-direction: column;
max-width: 500px;
margin: 0 auto;
}
.dizy-popup-body.image-only {
flex-direction: column;
}
.dizy-popup-body.image-only .newsletter-image-container {
width: 100%;
min-height: 380px;
}
.dizy-popup-body.image-only .newsletter-content {
width: 100%;
padding: 20px;
}
.newsletter-image-container {
width: 50%;
min-height: 250px;
background-position: center;
background-repeat: no-repeat;
background-size: cover;
position: relative;
}
.newsletter-image-link {
display: block;
width: 100%;
height: 100%;
}
.newsletter-content {
width: 50%;
padding: 40px 30px;
display: flex;
flex-direction: column;
justify-content: center;
box-sizing: border-box;
}
.dizy-popup-body.no-image .newsletter-content {
width: 100%;
padding: 40px;
text-align: center;
}
.dizy-popup-title {
font-size: 22px;
margin: 0 0 10px 0;
color: ${config.titleColor};
font-weight: ${config.titleFontBold ? '700' : '400'};
font-style: ${config.titleFontItalic ? 'italic' : 'normal'};
line-height: 1.3;
}
.dizy-popup-subtitle {
font-size: 14px;
margin: 0 0 20px 0;
color: ${config.subtitleColor};
font-weight: ${config.subtitleFontBold ? '700' : '400'};
font-style: ${config.subtitleFontItalic ? 'italic' : 'normal'};
line-height: 1.5;
}
.dizy-popup-form {
display: flex;
flex-direction: column;
gap: 12px;
}
.dizy-field-group {
display: flex;
flex-direction: column;
text-align: left;
}
.dizy-field-group label {
font-size: 12px;
font-weight: 600;
margin-bottom: 4px;
color: ${config.inputTextColor};
}
.dizy-input {
width: 100%;
padding: 12px 14px;
border: 1px solid #ccc;
border-radius: 6px;
font-size: 14px;
color: ${config.inputTextColor};
box-sizing: border-box;
outline: none;
transition: border-color 0.2s;
}
.dizy-input:focus { border-color: #333; }
.dizy-input::placeholder { color: ${config.inputTextColor}; opacity: 0.7; }
.dizy-submit-btn {
width: 100%;
padding: 14px;
border: none;
border-radius: 6px;
background-color: ${config.buttonBgColor};
color: ${config.buttonTextColor};
font-weight: ${config.buttonFontBold ? '700' : '400'};
font-style: ${config.buttonFontItalic ? 'italic' : 'normal'};
font-size: 14px;
letter-spacing: 0.5px;
cursor: pointer;
transition: opacity 0.2s;
margin-top: 6px;
}
.dizy-submit-btn:hover { opacity: 0.9; }
.dizy-submit-btn:disabled { opacity: 0.65; cursor: not-allowed; }
.dizy-spinner {
display: inline-block;
width: 14px;
height: 14px;
border: 2px solid currentColor;
border-right-color: transparent;
border-radius: 50%;
animation: dizy-spin 0.75s linear infinite;
vertical-align: middle;
margin-right: 6px;
}
@keyframes dizy-spin {
to { transform: rotate(360deg); }
}
${config.customCss ? config.customCss : ''}
.newsletter-message {
display: none;
font-size: 15px;
color: #2e7d32;
margin-top: 15px;
padding: 12px;
background: #e8f5e9;
border-radius: 6px;
text-align: center;
line-height: 1.4;
}
.newsletter-coupon-box {
display: none;
margin-top: 20px;
padding: 15px;
background-color: ${config.couponBgColor};
color: ${config.couponTextColor};
border: 2px dashed #bbb;
border-radius: 6px;
text-align: center;
cursor: pointer;
transition: background-color 0.2s;
}
.newsletter-coupon-box:hover { background-color: #e5e7eb; }
.newsletter-coupon-code {
font-size: 18px;
font-weight: ${config.couponFontBold ? '700' : '400'};
font-style: ${config.couponFontItalic ? 'italic' : 'normal'};
letter-spacing: 2px;
margin-top: 4px;
display: block;
}
.coupon-copy-hint {
font-size: 11px;
opacity: 0.7;
display: block;
margin-top: 2px;
}
@media (max-width: 767px) {
.dizy-popup-container { max-width: 92%; flex-direction: column; }
.dizy-popup-body { flex-direction: column; }
.newsletter-image-container { width: 100%; min-height: 270px; }
.newsletter-content { width: 100%; padding: 25px 20px; }
}
`;
document.head.appendChild(style);
// Build Modal HTML
var overlay = document.createElement('div');
overlay.id = 'dizy-popup-overlay-' + config.id;
overlay.className = 'dizy-popup-overlay pos-' + config.position;
var hasImage = (window.innerWidth <= 767 ? config.imageMobile : config.imageDesktop);
var bodyClass = !hasImage ? 'dizy-popup-body no-image' : (!config.showInputFields ? 'dizy-popup-body image-only' : 'dizy-popup-body');
var imgHtml = '';
if (hasImage) {
var imgStyle = "background-image: url('" + hasImage + "');";
if (config.imageLink) {
imgHtml = '
';
} else {
imgHtml = '
';
}
}
var formHtml = '';
if (config.showInputFields && config.isNewsletter) {
var nameFieldHtml = '';
if (config.showName) {
if (config.nameDisplayMode === 'label') {
nameFieldHtml = '
';
} else {
nameFieldHtml = '
';
}
}
var phoneFieldHtml = '';
if (config.showPhone) {
if (config.phoneDisplayMode === 'label') {
phoneFieldHtml = '
';
} else {
phoneFieldHtml = '
';
}
}
formHtml = `
`;
}
var couponHtml = '';
if (config.hasCoupon) {
var couponStyle = (!config.showInputFields || !config.showCouponAfterSubmit) ? 'display: block;' : '';
couponHtml = `
Seu cupom de desconto:
${config.couponCode}
(Clique para copiar)
`;
}
var contentHtml = '';
if (config.title || config.subtitle || formHtml || couponHtml) {
contentHtml = `
${config.title ? '' : ''}
${config.subtitle ? '' : ''}
${formHtml}
${config.successMessage}
${couponHtml}
`;
}
overlay.innerHTML = `
`;
document.body.appendChild(overlay);
// Animate overlay display
setTimeout(function() {
overlay.classList.add('dizy-visible');
}, 10);
// Close logic
function closePopup() {
overlay.classList.remove('dizy-visible');
setTimeout(function() {
if (overlay.parentNode) {
overlay.parentNode.removeChild(overlay);
}
}, 300);
try {
localStorage.setItem(storageKey, JSON.stringify({ seen: true, timestamp: Date.now() }));
} catch(e) {}
}
document.getElementById('dizy-close-btn').addEventListener('click', closePopup);
overlay.addEventListener('click', function(e) {
if (e.target === overlay) {
closePopup();
}
});
// Phone Mask Handler
var phoneInput = document.getElementById('dizy-phone-input');
if (phoneInput) {
phoneInput.addEventListener('input', function(e) {
var value = e.target.value.replace(/\D/g, '');
if (value.length > 11) value = value.substring(0, 11);
var formatted = '';
if (value.length > 0) {
formatted = '(' + value.substring(0, 2);
}
if (value.length > 2) {
formatted += ') ';
if (value.length <= 10) {
formatted += value.substring(2, 6);
if (value.length > 6) {
formatted += '-' + value.substring(6, 10);
}
} else {
formatted += value.substring(2, 7);
if (value.length > 7) {
formatted += '-' + value.substring(7, 11);
}
}
}
e.target.value = formatted;
});
}
// Coupon Copy Handler
var couponBox = document.getElementById('dizy-coupon-box');
if (couponBox && config.couponCode) {
couponBox.addEventListener('click', function() {
if (navigator.clipboard) {
navigator.clipboard.writeText(config.couponCode).then(function() {
var hint = document.getElementById('dizy-copy-hint');
if (hint) hint.textContent = '(Copiado!)';
setTimeout(function() {
if (hint) hint.textContent = '(Clique para copiar)';
}, 3000);
});
}
});
}
// AJAX Subscription Handler
var form = document.getElementById('dizy-newsletter-form');
if (form) {
var isSubmitting = false;
form.addEventListener('submit', function(e) {
e.preventDefault();
if (isSubmitting) return;
var submitBtn = form.querySelector('.dizy-submit-btn');
var originalBtnHtml = submitBtn ? submitBtn.innerHTML : '';
if (submitBtn) {
submitBtn.disabled = true;
submitBtn.innerHTML = '
Enviando...';
}
isSubmitting = true;
var emailInput = form.querySelector('input[name="email"]');
var nameInput = form.querySelector('input[name="name"]');
var phoneInput = form.querySelector('input[name="phone"]');
var formData = new FormData();
formData.append('email', emailInput ? emailInput.value : '');
formData.append('isAjax', 'true');
formData.append('popup_id', config.id);
if (nameInput) formData.append('name', nameInput.value);
if (phoneInput) formData.append('phone', phoneInput.value);
function restoreBtn() {
isSubmitting = false;
if (submitBtn) {
submitBtn.disabled = false;
submitBtn.innerHTML = originalBtnHtml;
}
}
fetch(config.submitUrl, {
method: 'POST',
body: formData,
headers: { 'X-Requested-With': 'XMLHttpRequest' }
})
.then(function(res) { return res.json(); })
.then(function(data) {
if (data && data.success === false) {
restoreBtn();
alert(data.message || 'Ocorreu um erro ao assinar.');
return;
}
form.style.display = 'none';
var successMsg = document.getElementById('dizy-success-message');
if (successMsg) {
if (data && data.message) successMsg.textContent = data.message;
successMsg.style.display = 'block';
}
if (config.hasCoupon && config.showCouponAfterSubmit) {
if (couponBox) couponBox.style.display = 'block';
}
// Refresh customer session messages
fetch(config.sectionsUrl).catch(function(){});
try {
localStorage.setItem(storageKey, JSON.stringify({ seen: true, timestamp: Date.now() }));
} catch(err) {}
})
.catch(function(err) {
restoreBtn();
alert('Ocorreu um erro ao assinar. Por favor, tente novamente.');
});
});
}
}
var delayMs = (config.displayDelay > 0 && config.displayDelay <= 60) ? config.displayDelay * 1000 : config.displayDelay;
if (delayMs > 0) {
setTimeout(initPopup, delayMs);
} else {
if (document.readyState === 'complete' || document.readyState === 'interactive') {
initPopup();
} else {
document.addEventListener('DOMContentLoaded', initPopup);
}
}
})();
Search engine powered by ElasticSuite