Model: TTR-FF77A126D3861656

Vi-Vet Ağda Sonrası Temizleme Ve Masaj Yağı Arnica 125ml Sir ağda sonrası cildi kolayca temizler. Bebek yağı saflığındadır. Rahatlatıcı masaj yağı olarak da kullanılır. Arnica: ağda sonrası olabilecek kızarıklığı giderir. 43,90 TL Bioblas Şampuan 360 Ml Yağlı Saçlar İçin Saç dökülmesine karşı etkili formüle sahip Bioblas Şampuan içerdiği sebum dengeleyici ile saçların yağ ve nem dengesini düzeltir, saçlarınızın daha hacimli ve sağlıklı olmasını sağlar. 99,00 TL Siparişlerim | İşlem Rehberi ToptanTR Yeni Nesil B2B Online Tedarik Platformu Kampanya Bildirimlerimizi Anlık Almak İçin E-Posta Listemize Kayıt Olun E-bültene Kayıt Ol Lütfen bekleyin... 3 İŞ GÜNÜ İÇERİSİNDE KARGO Ürünleriniz 3 iş günü içerisinde kargoya verilir. TEK TIKLA GÜVENLİ ALIŞVERİŞ Adres ve ödeme bilgilerinizi kaydedin, en hızlı alışverişi siz yapın MOBİL CEBİNİZDE Dilediğiniz her yerden güvenli alışverişin keyfini çıkarın EN İYİ TOPTAN FİYATLAR Kampanya ürünlerinde en uygun fiyatlar Siparişlerim İletişim İşlem Rehberi ToptanTr.com Gizlilik Politikası ve KVKK Çerez Politikası Kişisel Verilerin İşlenmesi Aydınlatma Metni Taksit Seçenekleri / Banka Komisyon Oranları Hakkımızda Satıcı Başvuruları Sıkça Sorulan Sorular (SSS) E-Ticaret Stopaj Vergisi: Nasıl Ödenecek? Yeni Stopaj Vergisinden Kimler Muaf Olabilecek? Entegrasyonlar Sıkça Sorulan Sorular ToptanTR.com ETBİS Kayıtlı mıdır? ToptanTR.com Güvenilir mi? Bizden Haberler Müşteri Hizmetleri Üye Ol İletişim İade İşlemleri Satıcı Eğitimleri Popüler Sayfalar Markalar En Çok Satan Ürünler Partnerlik Programı ToptanTR Partner Girişimci Sistemi BİZİ TAKİP EDİN Facebook X Instagram Youtube RSS MOBİL UYGULAMALAR APP STORE'dan İNDİREBİLİRSİNİZ GOOGLE PLAY'den İNDİREBİLİRSİNİZ ETBIS SORGULAMASİCİL BİLGİLERİ İNTERNETTE GÜVENLİ ALIŞVERİŞ Tüm hakları saklıdır. Ürün Seçenekleri .admin-popup { position: fixed; top: 0; left: 0; width: 100%; height: 100%; z-index: 9999; display: none; } .admin-popup-overlay { position: absolute; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0, 0, 0, 0.8); z-index: 9998; } .admin-popup-container { position: relative; width: 100%; height: 100%; display: flex; justify-content: center; align-items: center; z-index: 9999; } .admin-popup-content { background: white; border-radius: 12px; box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15); overflow: hidden; display: flex; flex-direction: column; max-height: 90vh; box-sizing: border-box; position: relative; } .admin-popup-header { display: flex; justify-content: space-between; align-items: center; padding: 20px 24px; background: white; color: #1f2d3d; border-radius: 12px 12px 0 0; flex-shrink: 0; } .admin-popup-title { margin: 0; font-size: 20px; font-weight: 600; } .admin-popup-close { background: transparent; border: none; color: black; font-size: 40px; cursor: pointer; padding: 0; width: 32px; height: 32px; display: flex; align-items: center; justify-content: center; border-radius: 4px; transition: background-color 0.2s; } .admin-popup-close:hover { background-color: rgba(255, 255, 255, 0.1); } .admin-popup-body { flex: 1; padding: 24px; overflow-y: auto; min-height: 200px; } .admin-popup-footer { display: flex; justify-content: flex-end; align-items: center; gap: 12px; padding: 20px 24px; border-top: 1px solid #e0e0e0; flex-shrink: 0; } /* BOYUT SINIFLARI */ .admin-popup-fullscreen .admin-popup-container { padding: 0; } .admin-popup-fullscreen .admin-popup-content { width: 100%; height: 100%; border-radius: 0; max-height: 100vh; } .admin-popup-fullscreen .admin-popup-header { border-radius: 0; } .admin-popup-centered-small .admin-popup-content { width: 400px; min-width: 320px; } .admin-popup-centered-medium .admin-popup-content { width: 600px; min-width: 480px; } .admin-popup-centered-large .admin-popup-content { width: 800px; min-width: 640px; } .admin-popup-centered-extralarge .admin-popup-content { width: 1100px; min-width: 640px; } /* GÖRÜNÜRLÜK KONTROLÜ */ .admin-popup-close-visible .admin-popup-close { display: flex; } .admin-popup-close-hidden .admin-popup-close { display: none; } .admin-popup-confirm-btn { background-color: #ffd800; border: none; color: black; padding: 12px 24px; border-radius: 8px; cursor: pointer; font-size: 14px; font-weight: 600; transition: background-color 0.2s; } .admin-popup-confirm-btn:hover:not(:disabled) { background-color: #e6c300; } .admin-popup-confirm-btn:disabled { background-color: #ccc; cursor: not-allowed; opacity: 0.6; } .admin-popup-confirm-visible .admin-popup-confirm-btn { display: inline-flex; } .admin-popup-confirm-hidden .admin-popup-confirm-btn { display: none; } /* TEXTAREA */ .admin-popup-agreement-section { margin-top: 20px; padding: 16px; background-color: #f8f9fa; border-radius: 8px; border: 1px solid #e9ecef; } .admin-popup-agreement-textarea { margin-top: 12px; } .admin-popup-agreement-textarea label { display: block; font-size: 14px; margin-bottom: 8px; font-weight: 500; } .admin-popup-agreement-textarea textarea { width: 100%; min-height: 60px; max-height: 120px; padding: 10px; border: 2px solid #ddd; border-radius: 6px; font-size: 14px; font-family: inherit; resize: vertical; box-sizing: border-box; } .admin-popup-agreement-textarea textarea:focus { outline: none; border-color: #007bff; } .admin-popup-agreement-textarea textarea.valid { border-color: #28a745; background-color: #f8fff8; } .admin-popup-agreement-textarea textarea.invalid { border-color: #dc3545; background-color: #fff8f8; } .admin-popup-textarea-hint { font-size: 12px; color: #666; margin-top: 4px; } .admin-popup-textarea-enabled .admin-popup-agreement-section { display: block; } .admin-popup-textarea-disabled .admin-popup-agreement-section { display: none; } /* SCROLL KONTROLÜ */ .admin-popup-scroll-indicator { position: absolute; top: 0; left: 0; right: 0; height: 4px; background: #e0e0e0; overflow: hidden; z-index: 10; } .admin-popup-scroll-progress { height: 100%; background: #ffd800; width: 0%; transition: width 0.2s ease; } .admin-popup-scroll-required .admin-popup-scroll-indicator { display: block; } .admin-popup-scroll-free .admin-popup-scroll-indicator { display: none; } .admin-popup-scroll-required .admin-popup-body { position: relative; } .admin-popup-scroll-required .admin-popup-footer { position: relative; } /* RESPONSIVE */ @media (max-width: 768px) { .admin-popup-container { padding: 16px; } .admin-popup-centered-small .admin-popup-content, .admin-popup-centered-medium .admin-popup-content, .admin-popup-centered-large .admin-popup-content { width: 100%; min-width: unset; } .admin-popup-header { padding: 16px 20px; } .admin-popup-title { font-size: 18px; } .admin-popup-body { padding: 20px; } .admin-popup-footer { padding: 16px 20px; flex-direction: column-reverse; gap: 8px; } .admin-popup-confirm-btn { width: 100%; justify-content: center; } } /* ANIMASYON */ .admin-popup.show { display: block !important; animation: fadeIn 0.3s ease; } .admin-popup.show .admin-popup-content { animation: slideIn 0.3s ease; } @keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } } @keyframes slideIn { from { opacity: 0; transform: scale(0.9); } to { opacity: 1; transform: scale(1); } } .admin-popup { position: fixed; top: 0; left: 0; width: 100%; height: 100%; z-index: 9999; display: none; } .admin-popup-overlay { position: absolute; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0, 0, 0, 0.8); z-index: 9998; } .admin-popup-container { position: relative; width: 100%; height: 100%; display: flex; justify-content: center; align-items: center; z-index: 9999; } .admin-popup-content { background: white; border-radius: 12px; box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15); overflow: hidden; display: flex; flex-direction: column; max-height: 90vh; box-sizing: border-box; position: relative; } .admin-popup-header { display: flex; justify-content: space-between; align-items: center; padding: 20px 24px; background: white; color: #1f2d3d; border-radius: 12px 12px 0 0; flex-shrink: 0; } .admin-popup-title { margin: 0; font-size: 20px; font-weight: 600; } .admin-popup-close { background: transparent; border: none; color: black; font-size: 40px; cursor: pointer; padding: 0; width: 32px; height: 32px; display: flex; align-items: center; justify-content: center; border-radius: 4px; transition: background-color 0.2s; } .admin-popup-close:hover { background-color: rgba(255, 255, 255, 0.1); } .admin-popup-body { flex: 1; padding: 24px; overflow-y: auto; min-height: 200px; } .admin-popup-footer { display: flex; justify-content: flex-end; align-items: center; gap: 12px; padding: 20px 24px; border-top: 1px solid #e0e0e0; flex-shrink: 0; } /* BOYUT SINIFLARI */ .admin-popup-fullscreen .admin-popup-container { padding: 0; } .admin-popup-fullscreen .admin-popup-content { width: 100%; height: 100%; border-radius: 0; max-height: 100vh; } .admin-popup-fullscreen .admin-popup-header { border-radius: 0; } .admin-popup-centered-small .admin-popup-content { width: 400px; min-width: 320px; } .admin-popup-centered-medium .admin-popup-content { width: 600px; min-width: 480px; } .admin-popup-centered-large .admin-popup-content { width: 800px; min-width: 640px; } .admin-popup-centered-extralarge .admin-popup-content { width: 1100px; min-width: 640px; } /* GÖRÜNÜRLÜK KONTROLÜ */ .admin-popup-close-visible .admin-popup-close { display: flex; } .admin-popup-close-hidden .admin-popup-close { display: none; } .admin-popup-confirm-btn { background-color: #ffd800; border: none; color: black; padding: 12px 24px; border-radius: 8px; cursor: pointer; font-size: 14px; font-weight: 600; transition: background-color 0.2s; } .admin-popup-confirm-btn:hover:not(:disabled) { background-color: #e6c300; } .admin-popup-confirm-btn:disabled { background-color: #ccc; cursor: not-allowed; opacity: 0.6; } .admin-popup-confirm-visible .admin-popup-confirm-btn { display: inline-flex; } .admin-popup-confirm-hidden .admin-popup-confirm-btn { display: none; } /* TEXTAREA */ .admin-popup-agreement-section { margin-top: 20px; padding: 16px; background-color: #f8f9fa; border-radius: 8px; border: 1px solid #e9ecef; } .admin-popup-agreement-textarea { margin-top: 12px; } .admin-popup-agreement-textarea label { display: block; font-size: 14px; margin-bottom: 8px; font-weight: 500; } .admin-popup-agreement-textarea textarea { width: 100%; min-height: 60px; max-height: 120px; padding: 10px; border: 2px solid #ddd; border-radius: 6px; font-size: 14px; font-family: inherit; resize: vertical; box-sizing: border-box; } .admin-popup-agreement-textarea textarea:focus { outline: none; border-color: #007bff; } .admin-popup-agreement-textarea textarea.valid { border-color: #28a745; background-color: #f8fff8; } .admin-popup-agreement-textarea textarea.invalid { border-color: #dc3545; background-color: #fff8f8; } .admin-popup-textarea-hint { font-size: 12px; color: #666; margin-top: 4px; } .admin-popup-textarea-enabled .admin-popup-agreement-section { display: block; } .admin-popup-textarea-disabled .admin-popup-agreement-section { display: none; } /* SCROLL KONTROLÜ */ .admin-popup-scroll-indicator { position: absolute; top: 0; left: 0; right: 0; height: 4px; background: #e0e0e0; overflow: hidden; z-index: 10; } .admin-popup-scroll-progress { height: 100%; background: #ffd800; width: 0%; transition: width 0.2s ease; } .admin-popup-scroll-required .admin-popup-scroll-indicator { display: block; } .admin-popup-scroll-free .admin-popup-scroll-indicator { display: none; } .admin-popup-scroll-required .admin-popup-body { position: relative; } .admin-popup-scroll-required .admin-popup-footer { position: relative; } /* RESPONSIVE */ @media (max-width: 768px) { .admin-popup-container { padding: 16px; } .admin-popup-centered-small .admin-popup-content, .admin-popup-centered-medium .admin-popup-content, .admin-popup-centered-large .admin-popup-content { width: 100%; min-width: unset; } .admin-popup-header { padding: 16px 20px; } .admin-popup-title { font-size: 18px; } .admin-popup-body { padding: 20px; } .admin-popup-footer { padding: 16px 20px; flex-direction: column-reverse; gap: 8px; } .admin-popup-confirm-btn { width: 100%; justify-content: center; } } /* ANIMASYON */ .admin-popup.show { display: block !important; animation: fadeIn 0.3s ease; } .admin-popup.show .admin-popup-content { animation: slideIn 0.3s ease; } @keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } } @keyframes slideIn { from { opacity: 0; transform: scale(0.9); } to { opacity: 1; transform: scale(1); } } @media (max-width: 300px) { body.modal-open { padding-right: 0 !important; } } /* Critical CSS for Option Cards - Inline to avoid cache issues */ #productAttributeModal .options-grid { display: flex !important; flex-wrap: wrap !important; gap: 10px !important; margin-bottom: 20px !important; justify-content: center !important; padding: 5px !important; } @media (max-width: 768px) { #productAttributeModal .options-grid { display: flex !important; flex-wrap: wrap !important; gap: 10px !important; margin-bottom: 20px !important; justify-content: center !important; padding: 5px !important; } } #productAttributeModal .options-grid .new-attribute-card { flex: 0 0 auto; min-width: 160px; max-width: 200px; } #productAttributeModal .attribute-section { margin-bottom: 15px !important; } #productAttributeModal .attribute-section .attribute-label { font-weight: 500 !important; font-size: 14px !important; color: #333 !important; margin-bottom: 8px !important; display: block !important; } #productAttributeModal .attribute-section .attribute-options { display: flex !important; flex-wrap: wrap !important; gap: 8px !important; } #productAttributeModal .attribute-section .attribute-option { padding: 8px 12px !important; cursor: pointer !important; border-radius: 4px !important; font-size: 13px !important; transition: all 0.3s ease !important; background: #fff !important; border: 1px solid #ddd !important; color: #666 !important; } #productAttributeModal .attribute-section .attribute-option.selected { background: #FACB13 !important; border: none !important; color: #000 !important; } /* Product attribute modal content container */ #productAttributeModal .product-attribute-modal-content { padding: 20px !important; } {"@context":"https://schema.org","@type":"Product","name":"Morfose Siyah Ultra Güçlü Saç Köpüğü 350 Ml","sku":"","gtin":"8680678820722","image":"https://imagedelivery.net:443/Dp1lIf5jOJmvQ9N2YPEaog/2dc9ba40-e983-4b43-b655-fc5d75deb800/width550","brand":[{"@type":"Brand","name":"Morfose"}],"offers":{"@type":"Offer","url":"https://www.toptantr.com/1576-morfose-siyah-ultra-guclu-sac-kopugu-350-ml","availability":"https://schema.org/InStock","price":"166.00","priceCurrency":"TRY"},"review":[],"hasVariant":[]} {"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"item":{"@id":"https://www.toptantr.com/kozmetik-ve-kisisel-bakim","name":"KOZMETİK & KİŞİSEL BAKIM"}},{"@type":"ListItem","position":2,"item":{"@id":"https://www.toptantr.com/sac-bakim-urunleri","name":"Saç Bakım Ürünleri"}},{"@type":"ListItem","position":3,"item":{"@id":"https://www.toptantr.com/sac-sekillendiriciler","name":"Saç Şekillendiriciler"}},{"@type":"ListItem","position":4,"item":{"@id":"https://www.toptantr.com/1576-morfose-siyah-ultra-guclu-sac-kopugu-350-ml","name":"Morfose Siyah Ultra Güçlü Saç Köpüğü 350 Ml"}}]} $(function () { // ProductSeName tek tırnaklı bir onclick="...('...')" JS string literaline gömülseydi, // içinde ' geçen bir SeName hem syntax hatasına hem stored XSS'e yol açabilirdi. // Bunun yerine data attribute + event delegation kullanılıyor. var track = document.getElementById("seller-cards-track"); if (track) { track.addEventListener("click", function (event) { var btn = event.target.closest(".add-to-cart-button-new[data-product-se-name]"); if (!btn) { return; } event.preventDefault(); openProductAttributeModal(btn.dataset.productId, btn.dataset.productSeName); }); } }); $(function(){ if($("#product-seller-count").length){ $("#product-seller-count").html("("+2+")"); $("#product-all-seller-count").html( 2 ); } }); var dialog = $("#product-question-dialog").dialog({ resizable: false, classes: { "ui-dialog": "anda-dialog" }, autoOpen: false, width: 550, maxHeight: $(window).height() - 20, modal: true, close: function () { } }); $("#create-product-question-btn").button().on("click", function () { $("#product-question-form-div").html(''); var postData = { productId: '130810' }; addAntiForgeryToken(postData); $.ajax({ cache: false, type: 'POST', data: postData, url: "/ProductQuestion/ProductQuestionForm", beforeSend: function () { displayAjaxLoading(true); }, success: function (data) { if (data.Success) { $("#product-question-form-div").html(data.Html); dialog.dialog("open"); } }, complete: function () { displayAjaxLoading(false); } }) }); function fnSaveAsHelpful(productQuestionId) { var postData = { productQuestionId: productQuestionId, wasHelpful: true }; addAntiForgeryToken(postData); $.ajax({ cache: false, type: 'POST', data: postData, url: "/ProductQuestion/SaveAsHelpfulOrNotHelpful", beforeSend: function () { displayAjaxLoading(true); }, success: function (data) { if (!data.Success) { if (data.Message != undefined || data.Message != null) { displayBarNotification(data.Message, 'error', 0); } }else{ $(".question-like").addClass("voted"); } }, complete: function () { displayAjaxLoading(false); } }); } function fnSaveAsNotHelpful(productQuestionId) { var postData = { productQuestionId: productQuestionId, wasHelpful: false }; addAntiForgeryToken(postData); $.ajax({ cache: false, type: 'POST', data: postData, url: '/ProductQuestion/SaveAsHelpfulOrNotHelpful', beforeSend: function () { displayAjaxLoading(true); }, success: function (data) { if (!data.Success) { if (data.Message != undefined || data.Message != null) { displayBarNotification(data.Message, 'error', 0); } }else{ $(".question-dislike").addClass("voted"); } }, complete: function () { displayAjaxLoading(false); } }); } $(document).ready(function () { var questionCount = '1'; $("#product-questions-count-area").show(); $("#product-question-links").html(questionCount + ' Soru & Cevap'); }); $(document).on("product_attributes_changed", function (data) { var postData = { productId: data.changedData.productId, price: data.changedData.dPrice }; addAntiForgeryToken(postData); $.ajax({ cache: false, type: "POST", url: "/ThreeDPaymentPos/ProductInstallmentOptions", data: postData, success: function (data) { if (data != null) { $("#productInstallmentOptions").html(data); } else { $("#productInstallmentOptions").html(""); } }, error: function (xhr, ajaxOptions, thrownError) { } }); }); $(document).ready(function () { $("#product-review-links").click(function (e) { e.preventDefault(); var element = $("#reviews-area"); if (element.length > 0 && element.offset()) { $('html, body').animate({ scrollTop: element.offset().top - 100 }, 1000); } }); $("#product-question-links").click(function (e) { e.preventDefault(); var element = $("#questions-area"); if (element.length > 0 && element.offset()) { $('html, body').animate({ scrollTop: element.offset().top - 100 }, 1000); } }); $("#product-seller-links").click(function (e) { e.preventDefault(); var element = $("#sellers-area"); if (element.length > 0 && element.offset()) { $('html, body').animate({ scrollTop: element.offset().top - 100 }, 1000); } }); $(document).on('click', '.service-regions-toggle', function (e) { e.preventDefault(); $(this).siblings('.service-regions-collapse').slideToggle(200); }); $(document).on('click', '.service-region-il-toggle', function (e) { e.preventDefault(); $(this).toggleClass('expanded') .closest('.service-region-item').find('.service-region-counties').slideToggle(150); }); // Enhanced product detail view tracking with error handling function trackProductDetailView() { if(typeof DataLayerHelper !== 'undefined'){ DataLayerHelper.getProductData('21738ca1-fc1f-4a73-ace0-e1c7739afb36', function (data) { try { if (!data) { console.error('Product data is null or undefined'); return; } let price = parseFloat(data.Price || 0).toFixed(2); let quantity = parseFloat(data.Quantity || 1).toFixed(2); let totalValue = (parseFloat(price) * parseFloat(quantity)); // Use waitForClarity to ensure Clarity is loaded before sending events DataLayerHelper.waitForClarity(() => { DataLayerHelper.viewItem(data, totalValue, data.Currency); }); } catch (error) { console.error('Error processing product detail view:', error); // Send error event to Clarity for debugging if (typeof DataLayerHelper.pushClarityEvent === 'function') { DataLayerHelper.pushClarityEvent('product_detail_view_error', { product_guid: '21738ca1-fc1f-4a73-ace0-e1c7739afb36', error_message: error.message, error_stack: error.stack }); } } }, '279510').fail(function(xhr, status, error) { console.error('Failed to fetch product data:', error); // Send fallback event with basic product info if (typeof DataLayerHelper.pushClarityEvent === 'function') { DataLayerHelper.pushClarityEvent('product_detail_view_fallback', { product_guid: '21738ca1-fc1f-4a73-ace0-e1c7739afb36', product_id: 130810, product_name: 'Morfose Siyah Ultra G\u00FC\u00E7l\u00FC Sa\u00E7 K\u00F6p\u00FC\u011F\u00FC 350 Ml', error_message: error || 'Failed to fetch product data', xhr_status: xhr.status || 'unknown' }); } }); } else { console.warn('DataLayerHelper not available for product detail view tracking'); } } // Call the tracking function trackProductDetailView(); }); window.cookieSeal = new CookieSeal({ tenantId: '65a12711c8eee6001325197d', siteId: '27a7162e-c118-4740-bc04-6a504f1e5ed7', lang: 'tr', // or 'en' for English showLogo: false, onChangePreference: function (category, allowed) { if (category === 'MarketingCookies' && allowed) { // Initialize marketing scripts / trackers under this comment line } if (category === 'PerformanceCookies' && allowed) { /// Initialize performance analytics scripts under this comment line } if (category === 'FunctionalCookies' && allowed) { // Initialize functional analytics scripts under this comment line } }, }) document.addEventListener('DOMContentLoaded', function() { initializeMobileLinksSlider(); }); function initializeMobileLinksSlider() { } function forceHeaderSticky() { const headerWrapper = document.querySelector('.new-header-wrapper'); const header = document.querySelector('.new-header'); if (!headerWrapper || !header) return; const isMobile = window.innerWidth threshold || window.outerWidth - window.innerWidth > threshold) { if (!devtools.open) { devtools.open = true; } } else { if (devtools.open) { devtools.open = false; setTimeout(forceHeaderSticky, 100); } } }, 500); let activeAccountDropdownId = null; let activeCartDropdownId = null; const headerDropdownMobileQuery = window.matchMedia ? window.matchMedia('(max-width: 1024px)') : null; const mobileCartModalElementId = 'mobile-cart-modal'; const mobileCartModalBodyElementId = 'mobile-cart-modal-body'; let mobileCartModalElement = null; let mobileCartModalBodyElement = null; let mobileCartActiveMenuId = null; let mobileCartOriginalParent = null; // Ürün detay sayfasındaki mobil sabit sepet çubuğu (product-overview-new__mobile-order-bar-footer) // ve sepet sayfasındaki mobil sabit "Ödemeye Geç" çubuğu (mobile-fixed-checkout), header'da açılan // mobil menü/dropdown/modal'ların ARKASINDA kalıp tıklamaları engellemesin diye bu popup'lar // açılırken gizlenir, kapandıklarında geri getirilir. Sayfada ikisinden en fazla biri bulunur, // querySelector diğerinde null döner ve zararsızca atlanır. function hideMobileOrderBar() { var orderBar = document.querySelector('.product-overview-new__mobile-order-bar'); if (orderBar) { orderBar.classList.add('product-overview-new__mobile-order-bar--hidden'); } var mobileCheckout = document.querySelector('.mobile-fixed-checkout'); if (mobileCheckout) { mobileCheckout.classList.add('mobile-fixed-checkout--hidden'); } } function showMobileOrderBar() { var orderBar = document.querySelector('.product-overview-new__mobile-order-bar'); if (orderBar) { orderBar.classList.remove('product-overview-new__mobile-order-bar--hidden'); } var mobileCheckout = document.querySelector('.mobile-fixed-checkout'); if (mobileCheckout) { mobileCheckout.classList.remove('mobile-fixed-checkout--hidden'); } } function toggleAccountDropdown(menuId) { const menu = document.getElementById(menuId); if (!menu) { return; } // Check if this is guest user and mobile/tablet const isGuestUser = menu.querySelector('.account-dropdown-guest') !== null; const isMobile = window.innerWidth closeAccountDropdown(), 100); }); } function closeAccountDropdown() { if (!activeAccountDropdownId) { return; } const openMenu = document.getElementById(activeAccountDropdownId); if (openMenu) { openMenu.classList.remove('show'); const wrapper = openMenu.closest('.account-dropdown-wrapper'); if (wrapper) { wrapper.classList.remove('show'); } resetAccountDropdownInlineStyles(openMenu); showMobileOrderBar(); } activeAccountDropdownId = null; } document.addEventListener('click', function(event) { const closeCartModalTrigger = event.target.closest('[data-mobile-cart-close]'); if (closeCartModalTrigger) { event.preventDefault(); closeMobileCartModal(); return; } const closeAccountModalTrigger = event.target.closest('[data-mobile-account-close]'); if (closeAccountModalTrigger) { event.preventDefault(); closeGuestAccountModal(); return; } if (isMobileCartModalOpen()) { const sheet = mobileCartModalElement ? mobileCartModalElement.querySelector('.mobile-cart-modal-sheet') : null; if (sheet && sheet.contains(event.target)) { return; } return; } if (activeAccountDropdownId) { const accountMenu = document.getElementById(activeAccountDropdownId); if (!accountMenu) { closeAccountDropdown(); } else { const accountWrapper = accountMenu.closest('.account-dropdown-wrapper'); if (!accountWrapper || !accountWrapper.contains(event.target)) { closeAccountDropdown(); } } } if (activeCartDropdownId) { const cartMenu = document.getElementById(activeCartDropdownId); if (!cartMenu) { closeCartDropdown(); } else { const cartWrapper = cartMenu.closest('.cart-dropdown-wrapper'); if (!cartWrapper || !cartWrapper.contains(event.target)) { closeCartDropdown(); } } } }); window.addEventListener('resize', function() { if (activeAccountDropdownId) { closeAccountDropdown(); } if (activeCartDropdownId) { closeCartDropdown(); } }); document.addEventListener('keydown', function(event) { if (event.key === 'Escape') { closeAccountDropdown(); closeCartDropdown(); closeGuestAccountModal(); } }); function isMobileHeaderDropdownViewport() { if (headerDropdownMobileQuery) { return headerDropdownMobileQuery.matches; } return window.innerWidth { updateCartBadges(); }, 100); } } function openCartDropdown(menuId) { const menu = document.getElementById(menuId); if (!menu) { return; } // Hover ile açılışta içeriği lazy yükle. ensureCartDropdownLoaded(menuId); if (isMobileHeaderDropdownViewport()) { if (isMobileCartModalOpen() && mobileCartActiveMenuId === menuId) { closeMobileCartModal(); } else { openMobileCartModal(menu); } return; } closeCartDropdown(); closeAccountDropdown(); menu.classList.add('show'); const wrapper = menu.closest('.cart-dropdown-wrapper'); if (wrapper) { wrapper.classList.add('show'); } activeCartDropdownId = menuId; // Add hover events to dropdown menu to prevent closing menu.addEventListener('mouseenter', function() { clearTimeout(window.cartDropdownTimeout); }); menu.addEventListener('mouseleave', function() { window.cartDropdownTimeout = setTimeout(() => closeCartDropdown(), 100); }); // Update cart badges when opening dropdown setTimeout(() => { updateCartBadges(); }, 100); } function closeCartDropdown() { if (isMobileCartModalOpen()) { closeMobileCartModal(); return; } if (!activeCartDropdownId) { return; } const openMenu = document.getElementById(activeCartDropdownId); if (openMenu) { openMenu.classList.remove('show'); const wrapper = openMenu.closest('.cart-dropdown-wrapper'); if (wrapper) { wrapper.classList.remove('show'); } } activeCartDropdownId = null; } function ensureMobileCartModalElements() { if (!mobileCartModalElement) { mobileCartModalElement = document.getElementById(mobileCartModalElementId); } if (!mobileCartModalBodyElement) { mobileCartModalBodyElement = document.getElementById(mobileCartModalBodyElementId); } } function isMobileCartModalOpen() { ensureMobileCartModalElements(); return mobileCartModalElement && mobileCartModalElement.classList.contains('open'); } function openMobileCartModal(menu) { ensureMobileCartModalElements(); if (!mobileCartModalElement || !mobileCartModalBodyElement) { return; } closeMobileCartModal(); mobileCartOriginalParent = menu.parentElement; mobileCartActiveMenuId = menu.id; menu.classList.add('show'); mobileCartModalBodyElement.innerHTML = ''; mobileCartModalBodyElement.appendChild(menu); const headerCountElement = menu.querySelector('.cart-dropdown-header-count'); const modalCountElement = document.getElementById('mobile-cart-modal-count'); // İçerik lazy yüklenmemişse header-count yoktur; server-render edilmiş modal sayacını koru. if (modalCountElement && headerCountElement) { modalCountElement.textContent = headerCountElement.textContent; } mobileCartModalElement.classList.add('open'); document.body.classList.add('mobile-cart-modal-open'); activeCartDropdownId = menu.id; hideMobileOrderBar(); } function closeMobileCartModal() { ensureMobileCartModalElements(); if (!isMobileCartModalOpen()) { return; } const activeMenu = mobileCartActiveMenuId ? document.getElementById(mobileCartActiveMenuId) : null; if (activeMenu) { activeMenu.classList.remove('show'); if (mobileCartOriginalParent) { mobileCartOriginalParent.appendChild(activeMenu); } } if (mobileCartModalElement) { mobileCartModalElement.classList.remove('open'); } showMobileOrderBar(); const modalCountElement = document.getElementById('mobile-cart-modal-count'); if (modalCountElement) { modalCountElement.textContent = ''; } document.body.classList.remove('mobile-cart-modal-open'); mobileCartActiveMenuId = null; mobileCartOriginalParent = null; activeCartDropdownId = null; } // Mobile Account Modal Functions let mobileAccountModalElement = null; function ensureMobileAccountModalElements() { if (!mobileAccountModalElement) { mobileAccountModalElement = document.getElementById('mobile-account-modal'); } } function isMobileAccountModalOpen() { ensureMobileAccountModalElements(); return mobileAccountModalElement && mobileAccountModalElement.classList.contains('open'); } function openGuestAccountModal() { ensureMobileAccountModalElements(); if (!mobileAccountModalElement || isMobileAccountModalOpen()) { return; } closeAccountDropdown(); closeCartDropdown(); mobileAccountModalElement.classList.add('open'); document.body.classList.add('mobile-account-modal-open'); hideMobileOrderBar(); } function closeGuestAccountModal() { ensureMobileAccountModalElements(); if (!mobileAccountModalElement || !isMobileAccountModalOpen()) { return; } mobileAccountModalElement.classList.remove('open'); document.body.classList.remove('mobile-account-modal-open'); showMobileOrderBar(); } // Mobile Side Menu Functions function toggleMobileSideMenu() { const overlay = document.getElementById('mobile-side-menu-overlay'); const menu = document.getElementById('mobile-side-menu'); if (!overlay || !menu) return; const isOpen = overlay.classList.contains('open'); if (isOpen) { closeMobileSideMenu(); } else { openMobileSideMenu(); } } // CSS vh/dvh birimleri bazı mobil tarayıcılarda (özellikle adres çubuğu/URL bar durumuna // göre) gerçek görünür yüksekliği yansıtmıyor - menü kapanırken alttan boşluk kalabiliyor. // Bunun önüne geçmek için açılış anındaki gerçek window.innerHeight'i inline style olarak // basıyoruz (stylesheet'teki height:100dvh'den daha yüksek özgüllüğe sahip, kesin sonuç verir). function syncMobileSideMenuHeight() { const overlay = document.getElementById('mobile-side-menu-overlay'); const menu = document.getElementById('mobile-side-menu'); if (!menu || !menu.classList.contains('open')) { return; } const viewportHeight = window.innerHeight + 'px'; menu.style.height = viewportHeight; if (overlay) { overlay.style.height = viewportHeight; } } function openMobileSideMenu() { const overlay = document.getElementById('mobile-side-menu-overlay'); const menu = document.getElementById('mobile-side-menu'); if (!overlay || !menu) return; overlay.classList.add('open'); menu.classList.add('open'); document.body.classList.add('mobile-menu-open'); hideMobileOrderBar(); syncMobileSideMenuHeight(); } function closeMobileSideMenu() { const overlay = document.getElementById('mobile-side-menu-overlay'); const menu = document.getElementById('mobile-side-menu'); if (!overlay || !menu) return; overlay.classList.remove('open'); menu.classList.remove('open'); document.body.classList.remove('mobile-menu-open'); menu.style.height = ''; overlay.style.height = ''; showMobileOrderBar(); // Reset mobile menu to level 0 resetMobileMenuToLevel0(); } window.addEventListener('resize', syncMobileSideMenuHeight); window.addEventListener('orientationchange', function () { setTimeout(syncMobileSideMenuHeight, 100); }); // Mobile Menu Nested Navigation let currentMobileMenuLevel = 0; const mobileMenuHistory = []; function initializeMobileCategoryNavigation() { const level0 = document.getElementById('mobile-menu-level-0'); if (!level0) return; const categoryLinks = level0.querySelectorAll('.mega-menu li a'); categoryLinks.forEach(function(link) { link.addEventListener('click', function(e) { e.preventDefault(); // Get category data const categoryName = link.getAttribute('data-categoryname') || link.textContent.trim(); const parentLi = link.closest('li'); const dropdown = parentLi ? parentLi.querySelector('.dropdown') : null; if (dropdown) { // Trigger hover to load data const mouseOverEvent = new Event('mouseover', { bubbles: true }); parentLi.dispatchEvent(mouseOverEvent); setTimeout(function() { showMobileCategoryLevel(1, categoryName, dropdown); }, 200); } }); }); } function showMobileCategoryLevel(level, title, dropdown) { const currentLevel = document.getElementById(`mobile-menu-level-${currentMobileMenuLevel}`); const nextLevel = document.getElementById(`mobile-menu-level-${level}`); const titleElement = document.getElementById(`mobile-menu-level-${level}-title`); const contentElement = document.getElementById(`mobile-menu-level-${level}-content`); if (!nextLevel || !titleElement || !contentElement) return; // Store current level in history mobileMenuHistory.push(currentMobileMenuLevel); // Update title titleElement.textContent = title; // Clear and populate content contentElement.innerHTML = ''; if (dropdown) { const subCatItems = dropdown.querySelectorAll('.picture-title-wrap'); subCatItems.forEach(function(item) { const subLink = item.querySelector('a[href]'); if (subLink) { let subCatName = subLink.getAttribute('title') || subLink.textContent.trim(); // Clean category name if (subCatName.includes('Kategorideki Ürünleri Göster ')) { subCatName = subCatName.replace('Kategorideki Ürünleri Göster ', '').trim(); } const subCatUrl = subLink.getAttribute('href'); if (subCatName && subCatName.length > 0) { const subCatElement = document.createElement('a'); subCatElement.href = subCatUrl; subCatElement.className = 'mobile-side-menu-sub-item'; subCatElement.textContent = subCatName; // Add click event for further nesting subCatElement.addEventListener('click', function(e) { e.preventDefault(); // Check if this subcategory has its own subcategories const categoryBox = item.closest('.box'); if (categoryBox) { const subcategoriesList = categoryBox.querySelector('.subcategories'); if (subcategoriesList && subcategoriesList.querySelectorAll('a[href]').length > 1) { showMobileSubCategoryLevel(2, subCatName, categoryBox); return; } } // If no subcategories, navigate to the category window.location.href = subCatUrl; }); contentElement.appendChild(subCatElement); } } }); } // Show next level if (currentLevel) currentLevel.classList.remove('show'); nextLevel.classList.add('show'); currentMobileMenuLevel = level; } function showMobileSubCategoryLevel(level, title, categoryBox) { const currentLevel = document.getElementById(`mobile-menu-level-${currentMobileMenuLevel}`); const nextLevel = document.getElementById(`mobile-menu-level-${level}`); const titleElement = document.getElementById(`mobile-menu-level-${level}-title`); const contentElement = document.getElementById(`mobile-menu-level-${level}-content`); if (!nextLevel || !titleElement || !contentElement) return; // Store current level in history mobileMenuHistory.push(currentMobileMenuLevel); // Update title titleElement.textContent = title; // Clear and populate content contentElement.innerHTML = ''; const subcategoriesList = categoryBox.querySelector('.subcategories'); if (subcategoriesList) { const subCatLinks = subcategoriesList.querySelectorAll('a[href]'); subCatLinks.forEach(function(subLink) { let subCatName = subLink.getAttribute('title') || subLink.textContent.trim(); // Clean category name if (subCatName.includes('Kategorideki Ürünleri Göster ')) { subCatName = subCatName.replace('Kategorideki Ürünleri Göster ', '').trim(); } const subCatUrl = subLink.getAttribute('href'); if (subCatName && subCatName !== 'Kategoriler' && subCatName !== title && subCatName.length > 0) { const subCatElement = document.createElement('a'); subCatElement.href = subCatUrl; subCatElement.className = 'mobile-side-menu-sub-item'; subCatElement.textContent = subCatName; // Navigate to category (no further nesting for level 2) subCatElement.addEventListener('click', function(e) { // Allow normal navigation }); contentElement.appendChild(subCatElement); } }); } // Show next level if (currentLevel) currentLevel.classList.remove('show'); nextLevel.classList.add('show'); currentMobileMenuLevel = level; } function goBackMobileMenu() { if (mobileMenuHistory.length === 0) return; const currentLevel = document.getElementById(`mobile-menu-level-${currentMobileMenuLevel}`); const previousLevelNumber = mobileMenuHistory.pop(); const previousLevel = document.getElementById(`mobile-menu-level-${previousLevelNumber}`); if (currentLevel && previousLevel) { currentLevel.classList.remove('show'); previousLevel.classList.add('show'); currentMobileMenuLevel = previousLevelNumber; } } function resetMobileMenuToLevel0() { // Hide all levels except level 0 for (let i = 1; i ${titleText} ${descriptionText} `; } function updateCategoryMegaEmptyState(titleText, descriptionText) { const dropdown = document.getElementById('category-mega-dropdown'); if (!dropdown) return; const contentWrapper = dropdown.querySelector('.category-mega-dropdown-content'); const emptyContainer = document.getElementById('category-mega-dropdown-empty'); if (!contentWrapper || !emptyContainer) return; if (titleText && descriptionText) { emptyContainer.innerHTML = renderCategoryMegaEmptyState(titleText, descriptionText); emptyContainer.classList.add('show'); contentWrapper.classList.add('hidden'); } else { emptyContainer.innerHTML = ''; emptyContainer.classList.remove('show'); contentWrapper.classList.remove('hidden'); } } function toggleCategoryMegaDropdown(categoryElement, categoryData) { const dropdown = document.getElementById('category-mega-dropdown'); if (!dropdown) return; const isCurrentlyOpen = dropdown.classList.contains('show') && activeCategoryDropdown === categoryElement; // Close any open dropdown closeCategoryMegaDropdown(); if (!isCurrentlyOpen) { openCategoryMegaDropdown(categoryElement, categoryData); } } let currentCategoryData = null; function openCategoryMegaDropdown(categoryElement, categoryData) { const dropdown = document.getElementById('category-mega-dropdown'); const title = dropdown.querySelector('.category-mega-dropdown-title'); const leftPanel = document.getElementById('category-mega-dropdown-left'); const middlePanel = document.getElementById('category-mega-dropdown-middle'); const rightPanel = document.getElementById('category-mega-dropdown-right'); const subTitle = document.getElementById('category-mega-dropdown-sub-title'); const subTitleText = document.getElementById('category-mega-dropdown-sub-title-text'); const subTitleLink = document.getElementById('category-mega-dropdown-sub-title-link'); const subContent = document.getElementById('category-mega-dropdown-sub-content'); if (!dropdown || !title || !leftPanel || !middlePanel || !rightPanel || !subTitle || !subContent) return; updateCategoryMegaEmptyState(); currentCategoryData = categoryData; // Set title title.textContent = categoryData.name || 'Kategoriler'; // Update right panel with main category info updateMainCategoryDisplay(categoryElement, categoryData); // Clear and populate left panel with main subcategories leftPanel.innerHTML = ''; subContent.innerHTML = ''; subContent.classList.remove('empty-note'); if (categoryData.subCategories && categoryData.subCategories.length > 0) { categoryData.subCategories.forEach(function(subCat, index) { const item = document.createElement('div'); item.className = 'category-mega-dropdown-main-item'; if (index === 0) item.classList.add('active'); // İlk item seçili item.innerHTML = ` ${subCat.name} `; // Click event for left panel items item.addEventListener('click', function(e) { e.preventDefault(); selectMainCategory(subCat, item); }); // Hover event for left panel items item.addEventListener('mouseenter', function(e) { selectMainCategory(subCat, item); }); leftPanel.appendChild(item); }); // Automatically select first category if (categoryData.subCategories.length > 0) { selectMainCategory(categoryData.subCategories[0], leftPanel.querySelector('.category-mega-dropdown-main-item')); } } else { if (subTitleText) { subTitleText.textContent = categoryData.name || 'Alt Kategoriler'; } if (subTitleLink) { subTitleLink.style.display = 'none'; } updateCategoryMegaEmptyState(); activeCategoryDropdown = null; return; } // Show dropdown dropdown.classList.add('show'); activeCategoryDropdown = categoryElement; // Show overlay const overlay = document.getElementById('category-mega-dropdown-overlay'); if (overlay) { overlay.classList.add('show'); } // Mouse leave event ekle dropdown için dropdown.addEventListener('mouseleave', function() { setTimeout(() => { closeCategoryMegaDropdown(); }, 100); }); } function updateMainCategoryDisplay(categoryElement, categoryData) { const mainImage = document.getElementById('category-main-image').querySelector('img'); const mainName = document.getElementById('category-main-name'); // Ana kategorinin görselini bul const parentLi = categoryElement.closest('li'); const mainCategoryImg = parentLi ? parentLi.querySelector('.main-category-img') : null; if (mainCategoryImg && mainCategoryImg.src) { mainImage.src = mainCategoryImg.src; mainImage.alt = categoryData.name; } else { // Fallback görsel mainImage.src = '/Themes/ToptanTr/Content/img/bullet.png'; mainImage.alt = categoryData.name; } mainName.textContent = categoryData.name; } function selectMainCategory(mainCat, selectedElement) { const subTitle = document.getElementById('category-mega-dropdown-sub-title'); const subTitleText = document.getElementById('category-mega-dropdown-sub-title-text'); const subTitleLink = document.getElementById('category-mega-dropdown-sub-title-link'); const subContent = document.getElementById('category-mega-dropdown-sub-content'); const leftPanel = document.getElementById('category-mega-dropdown-left'); // Sağ paneldeki seçili kategori bilgisini güncelle const mainName = document.getElementById('category-main-name'); const mainImage = document.getElementById('category-main-image').querySelector('img'); // Seçili kategorinin görselini güncelle if (mainCat.pictureModel && mainCat.pictureModel.imageUrl) { mainImage.src = mainCat.pictureModel.imageUrl; mainImage.alt = mainCat.name; } mainName.textContent = mainCat.name; // Remove active class from all left items leftPanel.querySelectorAll('.category-mega-dropdown-main-item').forEach(item => { item.classList.remove('active'); }); // Add active class to selected item if (selectedElement) { selectedElement.classList.add('active'); } // Update right panel if (subTitleText) { subTitleText.textContent = mainCat.name; } else if (subTitle) { subTitle.textContent = mainCat.name; } if (subTitleLink) { const seName = mainCat.seName || mainCat.SeName; let viewAllUrl = mainCat.url || mainCat.Url || null; if (!viewAllUrl && seName) { viewAllUrl = seName.startsWith('/') ? seName : `/${seName}`; } if (viewAllUrl) { subTitleLink.href = viewAllUrl; subTitleLink.style.display = 'inline-flex'; } else { subTitleLink.style.display = 'none'; } } subContent.classList.remove('empty-state', 'empty-note'); subContent.innerHTML = ''; let hasSubCategories = false; // Seçilen kategorinin alt kategorilerini orijinal element'ten bul if (mainCat.originalElement) { const categoryBox = mainCat.originalElement.closest('.box'); if (categoryBox) { // Alt kategoriler subcategories ul listesinde olabilir const subcategoriesList = categoryBox.querySelector('.subcategories'); if (subcategoriesList) { const subCatLinks = subcategoriesList.querySelectorAll('a[href]'); subCatLinks.forEach(function(subLink) { let subCatName = subLink.getAttribute('title') || subLink.textContent.trim(); // "Kategorideki Ürünleri Göster" metnini temizle if (subCatName.includes('Kategorideki Ürünleri Göster ')) { subCatName = subCatName.replace('Kategorideki Ürünleri Göster ', '').trim(); } const subCatUrl = subLink.getAttribute('href'); // "Kategoriler" başlığı değilse ekle if (subCatName && subCatName !== 'Kategoriler' && subCatName !== mainCat.name && subCatName.length > 0) { const subSubCat = document.createElement('a'); subSubCat.href = subCatUrl; subSubCat.className = 'category-mega-dropdown-sub-item'; subSubCat.innerHTML = ` ${subCatName} `; subContent.appendChild(subSubCat); hasSubCategories = true; } }); } } } // Eğer alt kategori bulunamazsa boş mesaj göster if (!hasSubCategories) { subContent.classList.add('empty-note'); subContent.innerHTML = ` ${mainCat.name} kategorisine ait alt kategori bulunamadı. `; } } function closeCategoryMegaDropdown() { const dropdown = document.getElementById('category-mega-dropdown'); if (dropdown) { dropdown.classList.remove('show'); } // Hide overlay const overlay = document.getElementById('category-mega-dropdown-overlay'); if (overlay) { overlay.classList.remove('show'); } updateCategoryMegaEmptyState(); // Remove active state from category links const area3 = document.getElementById('area-3-categories'); if (area3) { const activeLinks = area3.querySelectorAll('.mega-menu li a.active-category'); activeLinks.forEach(link => link.classList.remove('active-category')); } activeCategoryDropdown = null; } // Close dropdown when clicking outside document.addEventListener('click', function(event) { const dropdown = document.getElementById('category-mega-dropdown'); const area3 = document.getElementById('area-3-categories'); if (dropdown && area3 && !area3.contains(event.target) && !dropdown.contains(event.target)) { closeCategoryMegaDropdown(); } }); // Escape key to close document.addEventListener('keydown', function(event) { if (event.key === 'Escape') { closeCategoryMegaDropdown(); } }); // Close dropdown when clicking overlay document.addEventListener('click', function(event) { const overlay = document.getElementById('category-mega-dropdown-overlay'); if (overlay && event.target === overlay) { closeCategoryMegaDropdown(); } }); // Initialize category links after DOM is loaded document.addEventListener('DOMContentLoaded', function() { initializeCategoryDropdowns(); updateCartBadges(); }); // Update cart count badges function updateCartBadges() { // Get cart count from dropdown header if available const cartDropdowns = document.querySelectorAll('.cart-dropdown-header-count'); let cartCount = 0; // Dropdown içeriği henüz lazy-load edilmemişse header-count yoktur; server-render edilmiş // rozet değerini sıfırlamamak için burada dokunmadan çık. if (cartDropdowns.length === 0) { return; } const countText = cartDropdowns[0].textContent; const match = countText.match(/\d+/); if (match) { cartCount = parseInt(match[0]); } // Update both mobile and desktop cart badges const mobileBadge = document.getElementById('mobile-cart-count'); const desktopBadge = document.getElementById('desktop-cart-count'); [mobileBadge, desktopBadge].forEach(badge => { if (badge) { badge.textContent = cartCount; if (cartCount > 0) { badge.classList.remove('hidden'); } else { badge.classList.add('hidden'); } } }); } function initializeCategoryDropdowns() { const area3 = document.getElementById('area-3-categories'); if (!area3) return; const categoryLinks = area3.querySelectorAll('.mega-menu li a'); let hoverTimeout = null; categoryLinks.forEach(function(link) { // Mouse hover event için 2sn delay ile link.addEventListener('mouseenter', function(e) { // Önceki timeout'u temizle if (hoverTimeout) { clearTimeout(hoverTimeout); } // 2 saniye bekle hoverTimeout = setTimeout(() => { // Get category data from the link const categoryName = link.getAttribute('data-categoryname') || link.textContent.trim(); const categoryUrl = link.getAttribute('href'); // Find the parent li element to get dropdown data if available const parentLi = link.closest('li'); // Trigger hover/mouseover to load dropdown content if it's lazy loaded if (parentLi) { const mouseOverEvent = new Event('mouseover', { bubbles: true }); const mouseEnterEvent = new Event('mouseenter', { bubbles: true }); parentLi.dispatchEvent(mouseOverEvent); parentLi.dispatchEvent(mouseEnterEvent); } // Wait a bit for potential AJAX loading, then get dropdown setTimeout(function() { const dropdown = parentLi ? parentLi.querySelector('.dropdown') : null; let categoryData = { name: categoryName, url: categoryUrl, subCategories: [] }; // If dropdown exists, extract subcategories if (dropdown) { // Look for subcategories in the dropdown const subCatItems = dropdown.querySelectorAll('.picture-title-wrap'); if (subCatItems.length > 0) { subCatItems.forEach(function(item) { // Look for any link, not just category links const subLink = item.querySelector('a[href]'); if (subLink) { // Get name from title attribute first, then from link text let subCatName = subLink.getAttribute('title') || ''; // If title is like "Kategorideki Ürünleri Göster Çamaşır Yıkama", extract just the category name if (subCatName.includes('Kategorideki Ürünleri Göster ')) { subCatName = subCatName.replace('Kategorideki Ürünleri Göster ', '').trim(); } // Fallback to link text if title doesn't exist or is empty if (!subCatName) { subCatName = subLink.textContent.trim(); if (subCatName.includes('Kategorideki Ürünleri Göster ')) { subCatName = subCatName.replace('Kategorideki Ürünleri Göster ', '').trim(); } } const subCatUrl = subLink.getAttribute('href'); let subCatSeName = ''; // Extract sename from URL if (subCatUrl) { if (subCatUrl.includes('/category/')) { subCatSeName = subCatUrl.split('/category/')[1]; } else { // If it's a direct category URL like /atistirmaliklar subCatSeName = subCatUrl.replace('/', ''); } } // Get image if available const imgElement = item.querySelector('img'); const imageUrl = imgElement ? (imgElement.getAttribute('data-original') || imgElement.getAttribute('src')) : '/Themes/ToptanTr/Content/img/bullet.png'; if (subCatName && subCatName.length > 0) { categoryData.subCategories.push({ name: subCatName, seName: subCatSeName || subCatName.toLowerCase().replace(/\s+/g, '-'), url: subCatUrl, pictureModel: { imageUrl: imageUrl, alternateText: subCatName }, numberOfProducts: Math.floor(Math.random() * 50) + 5, // Demo data originalElement: item // Store reference for getting sub-subcategories }); } } }); } else { // Fallback - look for any links in dropdown const allSubLinks = dropdown.querySelectorAll('a[href]'); allSubLinks.forEach(function(subLink) { const subCatName = subLink.textContent.trim(); const subCatUrl = subLink.getAttribute('href'); const subCatSeName = subCatUrl ? subCatUrl.split('/').pop() : subCatName.toLowerCase().replace(/\s+/g, '-'); if (subCatName && subCatName !== categoryName) { categoryData.subCategories.push({ name: subCatName, seName: subCatSeName, url: subCatUrl, pictureModel: { imageUrl: '/Themes/ToptanTr/Content/img/bullet.png', alternateText: subCatName }, numberOfProducts: Math.floor(Math.random() * 50) + 5 }); } }); } } // Add active class to category link const area3 = document.getElementById('area-3-categories'); if (area3) { const activeLinks = area3.querySelectorAll('.mega-menu li a.active-category'); activeLinks.forEach(activeLink => activeLink.classList.remove('active-category')); } link.classList.add('active-category'); // Toggle dropdown toggleCategoryMegaDropdown(link, categoryData); }, 300); // 300ms bekle ki AJAX yüklensin }, 300); // 300ms hover delay }); // Mouse leave event için - timeout'u iptal et link.addEventListener('mouseleave', function(e) { if (hoverTimeout) { clearTimeout(hoverTimeout); hoverTimeout = null; } }); }); } // Announcement Slider fonksiyonu let announcementIndex = 0; let announcements = []; let announcementInterval; async function loadAnnouncements() { try { const response = await fetch('/api/v3/bannerandslider/mobile/mobile_announcement_page_slider'); if (response.ok) { const data = await response.json(); if (data && data.Data && Array.isArray(data.Data) && data.Data.length > 0) { // SliderList içindeki itemları al let sliderItems = []; data.Data.forEach(slider => { if (slider.SliderList && Array.isArray(slider.SliderList)) { sliderItems = sliderItems.concat(slider.SliderList); } }); announcements = sliderItems; if (announcements.length > 0) { initAnnouncementSlider(); } } } } catch (error) { } } function initAnnouncementSlider() { const container = document.getElementById('announcements-container'); if (!container || announcements.length === 0) { return; } // İlk announcement'ı göster showAnnouncement(0); // Her 3 saniyede bir değiştir if (announcements.length > 1) { announcementInterval = setInterval(() => { const currentItem = container.querySelector('.announcement-item.active'); if (currentItem) { currentItem.classList.add('exiting'); currentItem.classList.remove('active'); } setTimeout(() => { announcementIndex = (announcementIndex + 1) % announcements.length; showAnnouncement(announcementIndex); }, 250); }, 3000); } } function showAllAnnouncements() { const container = document.getElementById('announcements-container'); if (!container) return; // Container'ı temizle container.innerHTML = ''; // Her announcement için bir span oluştur announcements.forEach((announcement, index) => { const item = document.createElement('span'); item.className = 'announcement-text'; // API'den gelen veriye göre metni al let text = announcement.Label || announcement.Display || announcement.title || announcement.text || announcement.name || announcement.content || announcement.description; item.textContent = text; container.appendChild(item); // Son öğe değilse ayırıcı ekle if (index = 769; const container = isDesktop ? containerDesktop : containerMobile; // Önceki announcement'ları temizle container.innerHTML = ''; // Yeni announcement'ı oluştur const item = document.createElement('div'); item.className = 'announcement-item'; const announcement = announcements[index]; // İkon varsa ekle if (announcement.PicturePath || announcement.MobilePicturePath) { const icon = document.createElement('img'); icon.className = 'announcement-icon'; icon.src = announcement.MobilePicturePath || announcement.PicturePath; icon.alt = announcement.Label || 'İkon'; item.appendChild(icon); } // Metni ekle const textSpan = document.createElement('span'); textSpan.className = 'announcement-text-content'; textSpan.textContent = announcement.Label || 'Duyuru'; item.appendChild(textSpan); container.appendChild(item); // Animasyon için kısa delay setTimeout(() => { item.classList.add('active'); }, 50); } document.addEventListener('DOMContentLoaded', function() { loadAnnouncements(); }); // _CartDropdownMenu.cshtml artık AJAX ile enjekte edildiğinden (partial içindeki çalışmaz), // ürün tıklama fonksiyonu global scope'ta burada tanımlanır. function navigateToProduct(seName, productId) { if (seName && seName.trim() !== '') { window.location.href = '/' + seName.trim(); } else if (productId) { window.location.href = '/p/' + productId; } } // Tek bir dropdown'ı MiniCartDropdown endpoint'inden çekip yerine koyar. function fetchCartDropdownInto(targetId) { var target = document.getElementById(targetId); if (!target) { return Promise.resolve(); } var url = '/ShoppingCart/MiniCartDropdown?dropdownId=' + encodeURIComponent(targetId); var wasShown = target.classList.contains('show'); return fetch(url, { cache: 'no-store' }) .then(function(res) { return res.text(); }) .then(function(html) { var current = document.getElementById(targetId); if (!current) return; var shown = wasShown || current.classList.contains('show'); current.outerHTML = html; var newTarget = document.getElementById(targetId); if (newTarget) { newTarget.setAttribute('data-cart-dropdown-loaded', 'true'); if (shown) { newTarget.classList.add('show'); } } updateCartBadges(); }) .catch(function(err) { console.error('Sepet güncellenemedi:', err); updateCartBadges(); }); } // İçeriği yalnızca ilk ihtiyaç anında (açılış/hover) bir kez yükler. function ensureCartDropdownLoaded(targetId) { var target = document.getElementById(targetId); if (!target) { return Promise.resolve(); } if (target.getAttribute('data-cart-dropdown-loaded') === 'true' || target.getAttribute('data-cart-dropdown-loading') === 'true') { return Promise.resolve(); } target.setAttribute('data-cart-dropdown-loading', 'true'); return fetchCartDropdownInto(targetId).then(function() { var el = document.getElementById(targetId); if (el) { el.removeAttribute('data-cart-dropdown-loading'); } }); } // Sepete ekle/çıkar sonrası her iki dropdown'ı zorla tazeler. function refreshCartDropdowns() { ['cart-dropdown-desktop', 'cart-dropdown-mobile'].forEach(function(targetId) { fetchCartDropdownInto(targetId); }); } document.addEventListener('DOMContentLoaded', function() { function isOverCartArea(element) { if (!element || typeof element.closest !== 'function') return false; return element.closest('.cart-dropdown-wrapper--desktop') || element.closest('.cart-dropdown-wrapper--desktop-btn')|| element.closest('.cart-dropdown-desktop'); } document.addEventListener('mouseenter', function(e) { if (!isOverCartArea(e.target)) return; clearTimeout(window.cartDropdownTimeout); var wrapper = e.target.closest('.cart-dropdown-wrapper--desktop'); if (wrapper) { var menu = wrapper.querySelector('.cart-dropdown-desktop'); if (menu) openCartDropdown(menu.id); } }, true); document.addEventListener('mouseleave', function(e) { if (!isOverCartArea(e.target)) return; if (isOverCartArea(e.relatedTarget)) { clearTimeout(window.cartDropdownTimeout); return; } window.cartDropdownTimeout = setTimeout(closeCartDropdown, 400); }, true); document.addEventListener('mousemove', function(e) { if (!isOverCartArea(e.target)) return; clearTimeout(window.cartDropdownTimeout); }); }); var hoveredData = []; var searchInputElement = null; function onMouseOverManufacturer(m) { getHoverSearchBox(0, m); } function onMouseOverCategory(c) { getHoverSearchBox(c, 0); } function getHoverSearchBox(c, m) { if (document.getElementById("search-input").value === "") { var key = c.toString() + "_" + m.toString(); var existing = hoveredData.find(o => o.key === key); if (existing) { renderProducts(existing.data); return false; } } $.ajax({ cache: false, type: "POST", url: '/searchautocomplete-e-products', data: searchAutocompleteAdditionalData(c, m), dataType: "json", success: function (data) { renderProducts(data); var key = c.toString() + "_" + m.toString(); hoveredData.push({ key: key, data: data }); }, error: function (xhr, ajaxOptions, thrownError) { } }); return false; } function searchAutocompleteAdditionalData(c, m) { var data = { CategoryId: c, ManufacturerId: m, Keywords: document.getElementById("search-input").value }; addAntiForgeryToken(data); return data; } function encodeHtmlAttribute(value) { if (!value) return ''; return value .replace(/&/g, '&') .replace(/"/g, '"') .replace(/'/g, ''') .replace(/ /g, '>'); } function extractSeNameFromUrl(url) { if (!url) return ''; try { var relativeUrl = url; if (url.indexOf('http') === 0 || url.indexOf('//') === 0) { var parsedUrl = new URL(url, window.location.origin); relativeUrl = parsedUrl.pathname || ''; } var cleanUrl = relativeUrl.split('?')[0].split('#')[0]; var parts = cleanUrl.split('/').filter(Boolean); return parts.length ? parts[parts.length - 1] : ''; } catch (e) { return ''; } } function renderProducts(htmlData) { var productsContainer = document.getElementById('popular-products'); if (productsContainer && htmlData) { // HTML'i parse et ve ürünleri dönüştür var tempDiv = document.createElement('div'); tempDiv.innerHTML = htmlData; var productItems = tempDiv.querySelectorAll('[class*="col"]'); var cards = ''; productItems.forEach(function(item) { var link = item.querySelector('a'); var img = item.querySelector('img'); var productName = item.querySelector('.product-name'); var currentPrice = item.querySelector('.current-price'); var oldPrice = item.querySelector('.old-price'); var addToCartBtn = item.querySelector('.btn-add-to-cart'); var seName = ''; var productId = ''; if (addToCartBtn) { productId = addToCartBtn.getAttribute('data-product-id') || addToCartBtn.dataset.productId || ''; seName = addToCartBtn.getAttribute('data-se-name') || addToCartBtn.dataset.seName || ''; } if ((!productId || !seName) && link) { productId = productId || link.getAttribute('data-product-id') || (link.dataset ? link.dataset.productId : '') || ''; seName = seName || link.getAttribute('data-se-name') || (link.dataset ? link.dataset.seName : '') || ''; } if (!seName && link) { seName = extractSeNameFromUrl(link.getAttribute('href') || link.href || ''); } if (!productId && addToCartBtn) { var match = addToCartBtn.getAttribute('onclick') && addToCartBtn.getAttribute('onclick').match(/addToCartFromSearch\((\d+)\)/); if (match && match[1]) { productId = match[1]; } } if (link && img && productName) { var priceHtml = ''; if (currentPrice || oldPrice) { priceHtml = ' '; if (oldPrice) { priceHtml += ` ${oldPrice.textContent.trim()} `; } if (currentPrice) { priceHtml += ` ${currentPrice.textContent.trim()} `; } priceHtml += ' '; } var cartButtonHtml = ''; if (productId) { var encodedProductId = encodeHtmlAttribute(String(productId)); var encodedSeName = encodeHtmlAttribute(seName || ''); cartButtonHtml = ` `; } cards += ` ${productName.textContent.trim()} ${priceHtml} ${cartButtonHtml} `; } }); productsContainer.innerHTML = cards || ' Ürün bulunamadı '; } } function parseAndRenderCatalogSearchBox(htmlData) { if (!htmlData) return; var tempDiv = document.createElement('div'); tempDiv.innerHTML = htmlData; // Kategorileri al - sol kısım, ilk ul var categoryList = tempDiv.querySelector('.col-lg-4 ul:nth-of-type(1)'); if (categoryList) { var categoriesContainer = document.getElementById('popular-categories'); var categories = ''; categoryList.querySelectorAll('li a').forEach(function(link) { var categoryName = link.textContent.trim(); var onmouseoverAttr = link.getAttribute('onmouseover') || ''; var categoryId = (onmouseoverAttr.match(/\((\d+)\)/) || [])[1] || '0'; categories += ` ${categoryName} `; }); if (categories) { categoriesContainer.innerHTML = categories; } } // Markaları al - sol kısım, ikinci ul var manufacturerList = tempDiv.querySelector('.col-lg-4 ul:nth-of-type(2)'); if (manufacturerList) { var brandsContainer = document.getElementById('popular-brands'); var brands = ''; manufacturerList.querySelectorAll('li a').forEach(function(link) { var brandName = link.textContent.trim(); var onmouseoverAttr = link.getAttribute('onmouseover') || ''; var brandId = (onmouseoverAttr.match(/\((\d+)\)/) || [])[1] || '0'; brands += ` ${brandName} `; }); if (brands) { brandsContainer.innerHTML = brands; } } // Ürünleri al - sağ kısım var productsSection = tempDiv.querySelector('.col-lg-8 .row'); if (productsSection) { renderProducts(productsSection.innerHTML); } // Title'ları ayarla var categoryTitle = tempDiv.querySelector('.col-lg-4 h5:nth-of-type(1)'); if (categoryTitle) { document.getElementById('categories-title').textContent = categoryTitle.textContent.trim(); } var manufacturerTitle = tempDiv.querySelector('.col-lg-4 h5:nth-of-type(2)'); if (manufacturerTitle) { document.getElementById('brands-title').textContent = manufacturerTitle.textContent.trim(); } var productTitle = tempDiv.querySelector('.col-lg-8 h5'); if (productTitle) { document.getElementById('products-title').textContent = productTitle.textContent.trim(); } } function loadInitialData() { // Initial view olarak ElasticSearchAutoComplete endpoint'ini çağır var searchLoader = document.getElementById('initial-loader'); if (searchLoader) searchLoader.style.display = 'flex'; var data = { term: '' }; addAntiForgeryToken(data); $.ajax({ cache: false, type: "POST", url: '/searchautocomplete-e', data: data, dataType: "json", success: function (data) { parseAndRenderCatalogSearchBox(data); // Hide and reset the "Tümünü Gör" link since we're showing initial data var viewAllLink = document.getElementById('view-all-products'); if (viewAllLink) { viewAllLink.style.display = 'none'; viewAllLink.href = '#'; // Reset href to prevent using old search term } // Loader'ı gizle if (searchLoader) searchLoader.style.display = 'none'; var searchResults = document.getElementById('search-results'); if (searchResults) searchResults.style.display = 'flex'; var searchProducts = document.getElementById('search-products'); if (searchProducts) searchProducts.style.display = 'flex'; }, error: function (xhr, ajaxOptions, thrownError) { if (searchLoader) searchLoader.style.display = 'none'; var searchResults = document.getElementById('search-results'); if (searchResults) searchResults.style.display = 'flex'; var searchProducts = document.getElementById('search-products'); if (searchProducts) searchProducts.style.display = 'flex'; } }); } function loadSearchData(searchTerm = '') { var searchLoader = document.getElementById('search-loader'); var initialLoader = document.getElementById('initial-loader'); if (searchLoader) searchLoader.style.display = 'flex'; if (initialLoader) initialLoader.style.display = 'none'; var data = { term: searchTerm }; addAntiForgeryToken(data); // 0) { viewAllLink.href = `/search-e?q=${encodeURIComponent(searchTerm)}`; viewAllLink.style.display = 'inline'; } else if (viewAllLink) { viewAllLink.style.display = 'none'; } // Loader'ı gizle if (searchLoader) searchLoader.style.display = 'none'; var searchResults = document.getElementById('search-results'); if (searchResults) searchResults.style.display = 'flex'; var searchProducts = document.getElementById('search-products'); if (searchProducts) searchProducts.style.display = 'flex'; }, error: function (xhr, ajaxOptions, thrownError) { if (searchLoader) searchLoader.style.display = 'none'; } }); } function addToCartFromSearch(productId, seName) { if (!productId) { return false; } var numericProductId = parseInt(productId, 10); if (!isNaN(numericProductId)) { productId = numericProductId; } if (typeof seName !== 'string') { seName = seName || ''; } if (typeof openProductAttributeModal === 'function') { openProductAttributeModal(productId, seName); return false; } // Sepete ekleme fonksiyonu var data = { productId: productId, shoppingCartTypeId: 1, quantity: 1 }; addAntiForgeryToken(data); $.ajax({ cache: false, type: "POST", url: ''.replace('__PRODUCTID__', productId), data: data, success: function(data) { if (data.success) { // Başarılı mesajı göster veya sepet ikonunu güncelle displayBarNotification(data.message, 'success', 3500); if (typeof updateFlyoutCart === 'function') { updateFlyoutCart(); } } else { displayBarNotification(data.message, 'error', 3500); } }, error: function() { displayBarNotification('Sepete eklenirken bir hata oluştu.', 'error', 3500); } }); } function openSearchOverlay() { document.getElementById('search-overlay').style.display = 'block'; // Mobile'da body scroll'u kapat if (window.innerWidth 768) { const headerInput = document.querySelector('.area2-center .search-wrapper'); const searchContent = document.querySelector('.search-overlay-content'); if (headerInput && searchContent) { const rect = headerInput.getBoundingClientRect(); searchContent.style.top = rect.top + 'px'; searchContent.style.left = rect.left + 'px'; searchContent.style.width = '800px'; searchContent.style.maxWidth = '800px'; searchContent.style.minWidth = '800px'; headerInput.style.visibility = 'hidden'; } } // Input'a arama event'i ekle searchInputElement = document.querySelector('.search-overlay-input'); let searchTimeout; if (searchInputElement) { searchInputElement.addEventListener('input', function() { clearTimeout(searchTimeout); const searchTerm = this.value.trim(); if (searchTerm.length > 0) { searchTimeout = setTimeout(() => { loadSearchData(searchTerm); }, 500); // 500ms debounce } else { // Input boşsa initial data'yı göster loadInitialData(); } }); // Enter tuşu ile arama (mobil klavye desteği) searchInputElement.addEventListener('keypress', function(e) { if (e.key === 'Enter') { e.preventDefault(); const searchTerm = this.value.trim(); if (searchTerm.length > 0) { window.location.href = '/search-e?q=' + encodeURIComponent(searchTerm); } } }); } // Initial verileri yükle loadInitialData(); // Focus input if (searchInputElement) { searchInputElement.focus(); } } function closeSearchOverlay() { document.getElementById('search-overlay').style.display = 'none'; document.body.style.overflow = 'auto'; // Header input'u geri göster (desktop'ta) if (window.innerWidth > 768) { const headerInput = document.querySelector('.area2-center .search-wrapper'); if (headerInput) { headerInput.style.visibility = 'visible'; } } } // ESC tuşu ile kapatma document.addEventListener('keydown', function(e) { if (e.key === 'Escape') { closeSearchOverlay(); } }); // Overlay background'a tıklayınca kapatma document.addEventListener('DOMContentLoaded', function() { var overlay = document.getElementById('search-overlay'); if (overlay) { overlay.addEventListener('click', function(e) { if (e.target === this) { closeSearchOverlay(); } }); } }); function performOverlaySearch() { const searchInput = document.getElementById('search-input'); if (searchInput) { const searchTerm = searchInput.value.trim(); if (searchTerm.length > 0) { window.location.href = '/search-e?q=' + encodeURIComponent(searchTerm); } } } (function () { document.addEventListener('DOMContentLoaded', function () { var tooltip = document.getElementById('cartExcelTooltip'); var closeBtn = document.getElementById('cartExcelTooltipClose'); var cookieName = 'cart_excel_tooltip_dismissed'; if (tooltip && cookieHelper.getCookie(cookieName) !== '1') { tooltip.classList.remove('hidden'); } if (closeBtn) { closeBtn.addEventListener('click', function (e) { e.preventDefault(); if (tooltip) tooltip.classList.add('hidden'); cookieHelper.setCookie(cookieName, '1', 365); }); } }); })(); window.localized_data = { AjaxCartFailure: "Ürün sepete eklenemedi. Lütfen sayfayı yenileyin ve tekrar deneyin.", ShareSuccessMessage: "URL basariyla kopyalandi!", ShoppingCartProductRemovedFromCart: "Ürün Sepetten Silindi", DiscountCouponCodeRemoved: "İndirim kodu kaldırıldı.", CartCleared: "Sepet başarıyla temizlendi.", DiscountCouponCodeApplied: "İndirim kodu uygulandı." }; AjaxCart.init(false, '.header .cart-wrapper .cart-qty', '.header-links .wishlist-qty', '.cart-wrapper', window.localized_data); function newsletter_subscribe(subscribe) { var subscribeProgress = $("#subscribe-loading-progress"); subscribeProgress.show(); var postData = { subscribe: subscribe, email: $("#newsletter-email").val() }; addAntiForgeryToken(postData); $.ajax({ cache: false, type: "POST", url: "/subscribenewsletter", data: postData, success: function (data, textStatus, jqXHR) { $("#newsletter-result-block").html(data.Result); if (data.Success) { $('#newsletter-subscribe-block').hide(); $('#newsletter-result-block').show(); } else { $('#newsletter-result-block').fadeIn("slow").delay(2000).fadeOut("slow"); } }, error: function (jqXHR, textStatus, errorThrown) { alert('Failed to subscribe.'); }, complete: function (jqXHR, textStatus) { subscribeProgress.hide(); } }); } $(document).ready(function () { $('#newsletter-subscribe-button').on('click', function () { newsletter_subscribe('true'); }); $("#newsletter-email").on("keydown", function (event) { if (event.keyCode == 13) { $("#newsletter-subscribe-button").trigger("click"); return false; } }); }); $(document).ready(function () { $('.footer-block .title').on('click', function () { var e = window, a = 'inner'; if (!('innerWidth' in window)) { a = 'client'; e = document.documentElement || document.body; } var result = { width: e[a + 'Width'], height: e[a + 'Height'] }; if (result.width ' + ' ' + ' ' + ' ' + ' Sepete ekleniyor... ' + ' ' ); addToCartFromProductDetails(productId); } else { $('#productAttributeModalContent').html( ' ' + ' ' + ' ' + ' ' ); $.ajax({ url: '/product/attributes-json', type: 'GET', data: { productId: productId }, success: function(response) { if (response.success) { buildModalContent(response); } else { showModalError('Ürün bilgileri alınamadı: ' + response.message); } }, error: function(xhr, status, error) { showModalError('Ürün bilgileri yüklenirken bir hata oluştu.'); } }); } return false; } // Sunucudan (GetProductAttributesJson) gelen attribute/paket adları vb. serbest metin // alanları $modalContent.html(...) ile DOM'a yazılmadan önce bu fonksiyondan geçiriliyor - // aksi halde bir isim " " gibi bir değer içerseydi tarayıcı bunu gerçek // HTML olarak çalıştırırdı. function escapeHtml(value) { return String(value == null ? '' : value) .replace(/&/g, '&') .replace(/ /g, '>') .replace(/"/g, '"') .replace(/'/g, '''); } function buildPackageOptionCardHtml(option) { var isPreselected = !!option.isSelected; var initialQty = isPreselected ? 1 : 0; var hasDiscount = !!option.oldPrice && !!option.discountPercent; var preselectedTagHtml = isPreselected ? ' En Avantajlı ' : ''; var discountHtml = hasDiscount ? ' %' + escapeHtml(option.discountPercent) + ' ' : ''; var oldPriceHtml = option.oldPrice ? ' ' + escapeHtml(option.oldPrice) + ' ' : ''; return '' + ' 0 ? ' new-attribute-card--selected' : '') + '"' + ' data-option-id="' + option.id + '"' + ' data-preselected="' + (isPreselected ? '1' : '0') + '"' + ' data-qty="' + initialQty + '">' + preselectedTagHtml + ' ' + escapeHtml(option.name) + ' ' + discountHtml + ' ' + ' ' + ' ' + escapeHtml(option.quantity) + ' Adet ' + oldPriceHtml + ' ' + escapeHtml(option.price) + ' ' + ' ' + escapeHtml(option.unitPrice) + ' ' + ' ' + ' ' + ' - ' + ' ' + ' + ' + ' ' + ' '; } function buildModalContent(data) { // Debug için console log ekle console.log('Modal attributes:', data.attributes); // Modal title'ını ürün adıyla güncelle if (data.productName) { $('#productAttributeModalLabel').text(data.productName); } var html = ' '; if (data.attributes && data.attributes.length > 0) { var packageAttributeId = null; // Önce package olmayan attribute'ları (renk, beden vs.) göster data.attributes.forEach(function(attribute) { if (!attribute.isPackageAttribute && attribute.options && attribute.options.length > 0) { html += ' '; html += ' ' + escapeHtml(attribute.name) + ' '; html += ' '; attribute.options.forEach(function(option) { var isSelected = option.isSelected ? 'selected' : ''; html += ' ' + escapeHtml(option.name) + ' '; }); html += ' '; html += ' '; } if (attribute.isPackageAttribute) { packageAttributeId = attribute.id; } }); // Sonra package attribute'ı (adet/paket/koli) göster var packageAttribute = data.attributes.find(attr => attr.isPackageAttribute); if (packageAttribute) { html += ' '; packageAttribute.options.forEach(function(option) { html += buildPackageOptionCardHtml(option); }); html += ' '; } } // Sepete ekle button html += ' '; html += ' SEPETE EKLE '; html += ' '; html += ' '; var $modalContent = $('#productAttributeModalContent'); $modalContent.html(html); // + ve - butonları (butona tıklandığında kart click eventinin tetiklenmemesi için direkt bağla) $modalContent.find('.new-attribute-card__stepper-btn--minus').off('click').on('click', function(event) { event.stopPropagation(); changeCardQuantity(this, -1); }); $modalContent.find('.new-attribute-card__stepper-btn--plus').off('click').on('click', function(event) { event.stopPropagation(); changeCardQuantity(this, 1); }); // Miktar kutusuna elle yazma $modalContent.find('.new-attribute-card__stepper-value').off('click').on('click', function(event) { event.stopPropagation(); }); $modalContent.find('.new-attribute-card__stepper-value').off('keydown').on('keydown', function(event) { var allowedKeys = ['Backspace', 'Delete', 'ArrowLeft', 'ArrowRight', 'Tab', 'Enter', 'Home', 'End']; if (allowedKeys.indexOf(event.key) !== -1) { return; } if (!/^[0-9]$/.test(event.key)) { event.preventDefault(); } }); $modalContent.find('.new-attribute-card__stepper-value').off('input').on('input', function() { var $card = $(this).closest('.new-attribute-card'); var parsed = parseInt($(this).val(), 10); if (isNaN(parsed) || parsed 0); if (parsed > 0) { clearOtherDefaultSelections($card); } }); $modalContent.find('.new-attribute-card__stepper-value').off('focusout').on('focusout', function() { var $card = $(this).closest('.new-attribute-card'); var newValue = parseInt($card.attr('data-qty')) || 0; $(this).val(newValue); setOptionCardState($card, newValue > 0); var anySelected = $('.new-attribute-card').filter(function() { return (parseInt($(this).attr('data-qty')) || 0) > 0; }).length > 0; if (!anySelected) { var $first = $('.new-attribute-card').first(); if ($first.length > 0) { $first.attr('data-qty', '1').find('.new-attribute-card__stepper-value').val('1'); setOptionCardState($first, true); } } }); // Option click events $('.new-attribute-card').on('click', function(event) { if ($(event.target).is('.new-attribute-card__stepper-value')) { return; } var $clickedCard = $(this); // Diğer kartları sıfırla (sadece 1 olanları, manuel arttırılmışlar korunacak) $('.new-attribute-card').not($clickedCard).each(function() { if (parseInt($(this).attr('data-qty')) === 1) { $(this).attr('data-qty', '0').find('.new-attribute-card__stepper-value').val('0'); setOptionCardState($(this), false); } }); // Select this card setOptionCardState($clickedCard, true); // Bu kartın miktarını 1 yap (eğer 0 ise) if (parseInt($clickedCard.attr('data-qty')) 0 yapılıp her ikisi // birden sepete eklenebiliyor (paket attribute'unun tek seçim kuralını bozar). function clearOtherDefaultSelections($currentCard) { $('.new-attribute-card').not($currentCard).each(function () { if (parseInt($(this).attr('data-qty')) === 1) { $(this).attr('data-qty', '0').find('.new-attribute-card__stepper-value').val('0'); setOptionCardState($(this), false); } }); } function setOptionCardState($card, isSelected) { if (!$card || $card.length === 0) { return; } if (isSelected) { $card.addClass('new-attribute-card--selected'); } else { $card.removeClass('new-attribute-card--selected'); } } function showModalError(message) { $('#productAttributeModalContent').html( ' ' + ' ' + message + ' ' + ' Kapat ' + ' ' ); } function changeCardQuantity(button, change) { var $currentCard = $(button).closest('.new-attribute-card'); var currentValue = parseInt($currentCard.attr('data-qty')) || 0; var newValue = currentValue + change; if (newValue >= 0) { $currentCard.attr('data-qty', newValue); $currentCard.find('.new-attribute-card__stepper-value').val(newValue); if (newValue > 0) { setOptionCardState($currentCard, true); clearOtherDefaultSelections($currentCard); } else { setOptionCardState($currentCard, false); // Eğer miktar 0 oldu, seçimi başka karta geçir // İlk miktarı > 0 olan kartı bul ve seç (şuanki hariç) var $nextCard = $('.new-attribute-card').not($currentCard).filter(function() { return parseInt($(this).attr('data-qty')) > 0; }).first(); if ($nextCard.length > 0) { $nextCard.click(); // Bu kartı otomatik seç } else { // Hiçbir kart yoksa, herhangi bir kartı seç ve quantity'sini 1 yap var $anyCard = $('.new-attribute-card').not($currentCard).first(); if ($anyCard.length > 0) { $anyCard.attr('data-qty', '1').find('.new-attribute-card__stepper-value').val('1'); $anyCard.click(); } } } } } // GA4 / Clarity "add_to_cart" event'i. Aktif sepete-ekleme akışı bu modal üzerinden // gittiği için event'i productId + quantity ile burada dispatch ediyoruz. Theme wrapper'ı // (anda.theme.min.js) event'i productId OLMADAN tetiklediğinden analytics dinleyicisi // (kpi_analytics2.js) onu yok sayıyor; bu yüzden tetikleme burada yapılmalı. function triggerAddToCartTracking(productId, quantity) { try { $(document).trigger({ type: "andaAjaxCartProductAddedToCartEvent", productId: productId, quantity: quantity }); } catch (e) { console.error('add_to_cart tracking trigger error:', e); } } function addToCartFromModal(productId, packageAttributeId) { // Seçilen küçük kare attribute'ları topla var selectedAttributes = {}; $('.attribute-option.selected').each(function() { var $this = $(this); var attributeId = $this.data('attribute-id'); var optionId = $this.data('option-id'); selectedAttributes['product_attribute_' + attributeId] = optionId; }); // Package attribute kartlarını kontrol et, quantity > 0 olanları topla var itemsToAdd = []; $('.new-attribute-card').each(function() { var $card = $(this); var optionId = $card.data('option-id'); var quantity = parseInt($card.attr('data-qty')) || 0; if (quantity > 0) { itemsToAdd.push({ optionId: optionId, quantity: quantity }); } }); if (itemsToAdd.length === 0) { alert('Lütfen en az bir ürün için miktar belirtin.'); return; } // Loading göster showModalLoading(); // Her bir seçenek için ayrı ayrı sepete ekle var addedCount = 0; var totalItems = itemsToAdd.length; var limitAdjustmentInfo = null; // Set if any item was auto-capped to purchase limit // Sıralı ekleme (birbirini beklesin ki karışmasın) function addNextItem(index) { if (index >= itemsToAdd.length) { return; } var item = itemsToAdd[index]; // Her seçenek için ayrı AJAX call - bu doğru çünkü farklı attribute kombinasyonları var formData = {}; formData['addtocart_' + productId + '.EnteredQuantity'] = item.quantity; formData['product_attribute_' + packageAttributeId] = item.optionId; // Küçük kare attribute'ları da ekle Object.assign(formData, selectedAttributes); // Anti-forgery token ekle if (typeof addAntiForgeryToken === 'function') { addAntiForgeryToken(formData); } $.ajax({ cache: false, url: '/addproducttocart/details/' + productId + '/1', type: 'POST', data: formData, success: function(response) { if (response && response.redirect) { window.location.href = response.redirect; return; } if (!response || response.success === false) { // --- Purchase limit auto-retry --- if (response && response.isPurchaseLimitError === true) { var remaining = response.remainingPurchaseRight; var limit = response.purchaseLimit; if (remaining ' + ' ' + ' ' + ' ' + ' Sepete ekleniyor... ' + ' ' ); } function showModalSuccessState(productId) { // Modal başlığını değiştir $('#productAttributeModalLabel').html(' Sepete Eklendi'); var html = ' '; // Modal-specific CSS for recommended products html += ' #productAttributeModal .product-grid, #productAttributeModal .product-list { margin: 0 0 1rem !important; } '; // Recommended products title html += ' Bu ürünler ilginizi çekebilir '; // Recommended products container with loader placeholder html += ' '; html += ' '; html += ' Yükleniyor... '; html += ' '; html += ' '; // Action buttons html += ' '; html += ' Alışverişe Devam Et '; html += ' Sepete Git '; html += ' '; html += ' '; $('#productAttributeModalContent').html(html); // Buton hover efektleri ekle $(document).on('mouseenter', '#productAttributeModalContent button[onclick="closeModalAndContinue()"]', function() { $(this).css({ 'background': '#f8f9fa', 'color': '#212529', 'transform': 'translateY(-1px)', 'box-shadow': '0 0 0 1px rgba(10, 13, 18, 0.22) inset, 0 -2px 0 0 rgba(10, 13, 18, 0.08) inset, 0 2px 4px 0 rgba(10, 13, 18, 0.08)', 'border-color': '#adb5bd' }); }); $(document).on('mouseleave', '#productAttributeModalContent button[onclick="closeModalAndContinue()"]', function() { $(this).css({ 'background': '#FFF', 'color': '#495057', 'transform': 'translateY(0)', 'box-shadow': '0 0 0 1px rgba(10, 13, 18, 0.18) inset, 0 -2px 0 0 rgba(10, 13, 18, 0.05) inset, 0 1px 2px 0 rgba(10, 13, 18, 0.05)', 'border-color': '#D5D7DA' }); }); $(document).on('mouseenter', '#productAttributeModalContent .modal-action-buttons button[data-variant="success-cart"]', function() { $(this).css({ 'background': '#e6791f', 'transform': 'translateY(-1px)', 'box-shadow': '0 4px 12px rgba(255, 137, 42, 0.3)' }); }); $(document).on('mouseleave', '#productAttributeModalContent .modal-action-buttons button[data-variant="success-cart"]', function() { $(this).css({ 'background': '#FF892A', 'transform': 'translateY(0)', 'box-shadow': 'none' }); }); // Load recommended products loadRecommendedProducts(productId); } function showModalErrorState(message) { $('#productAttributeModalLabel').html(' Sepete Ekleme Başarısız'); var safeMessage = $(' ').text(message || 'Seçtiğiniz ürün(ler) sepete eklenemedi.').html(); var html = ' '; html += ' ' + safeMessage + ' '; html += ' Lütfen ürün miktarını veya stok durumunu kontrol edip tekrar deneyin. '; html += ' '; html += ' Alışverişe Devam Et '; html += ' Sepeti Gör '; html += ' '; html += ' '; $('#productAttributeModalContent').html(html); $(document).on('mouseenter', '#productAttributeModalContent .modal-action-buttons button[data-variant="error-cart"]', function() { $(this).css({ 'background': '#9E201E', 'transform': 'translateY(-1px)', 'box-shadow': '0 4px 12px rgba(180, 35, 24, 0.35)' }); }); $(document).on('mouseleave', '#productAttributeModalContent .modal-action-buttons button[data-variant="error-cart"]', function() { $(this).css({ 'background': '#B42318', 'transform': 'translateY(0)', 'box-shadow': 'none' }); }); } function showModalPurchaseLimitSuccessState(purchaseLimit, addedQty, productId) { $('#productAttributeModalLabel').html(' Sepete Eklendi'); var infoMessage = 'Seçtiğiniz üründe ' + purchaseLimit + ' adet alım sınırı bulunmaktadır, ' + addedQty + ' adet daha ürün eklenerek sepetinizdeki ürün miktarı ' + purchaseLimit + ' olarak güncellenmiştir.'; var safeMessage = $(' ').text(infoMessage).html(); var html = ' '; html += ' ' + safeMessage + ' '; html += ' '; html += ' Alışverişe Devam Et '; html += ' Sepeti Gör '; html += ' '; html += ' '; $('#productAttributeModalContent').html(html); $(document).on('mouseenter', '#productAttributeModalContent .modal-action-buttons button[data-variant="limit-cart"]', function() { $(this).css({ 'background': '#9E201E', 'transform': 'translateY(-1px)', 'box-shadow': '0 4px 12px rgba(180, 35, 24, 0.35)' }); }); $(document).on('mouseleave', '#productAttributeModalContent .modal-action-buttons button[data-variant="limit-cart"]', function() { $(this).css({ 'background': '#B42318', 'transform': 'translateY(0)', 'box-shadow': 'none' }); }); } function loadRecommendedProducts(productId) { // Yeni ModalRecommendedProducts endpoint'ini kullan $.ajax({ url: '/Product/ModalRecommendedProducts', type: 'GET', data: { productId: productId }, success: function(response) { if (response && response.trim()) { $('#recommended-products-container').html(response); } else { $('#recommended-products-container').html(' Önerilen ürün bulunamadı. '); } }, error: function() { // Fallback olarak basit bir ürün listesi göster loadSimpleRelatedProducts(productId); } }); } function loadSimpleRelatedProducts(productId) { $.ajax({ url: '/Catalog/RelatedProducts', type: 'GET', data: { productId: productId }, success: function(response) { if (response && response.trim()) { // Sadece ürün grid'ini çıkar var $response = $(response); var productGrid = $response.find('.item-grid').html(); if (productGrid) { $('#recommended-products-container').html(' ' + productGrid + ' '); } else { $('#recommended-products-container').html(' Öneri ürün bulunamadı. '); } } else { $('#recommended-products-container').html(' Öneri ürün bulunamadı. '); } }, error: function() { $('#recommended-products-container').html(' Önerilen ürünler yüklenirken hata oluştu. '); } }); } function addToCartFromProductDetails(productId) { var $form = $('#product-details-form'); if ($form.length === 0) { showModalErrorState('Ürün detay formu bulunamadı.'); return; } var addToCartUrl = $form.data('add-to-cart-url') || $form.attr('data-add-to-cart-url') || $form.attr('action'); if (!addToCartUrl) { showModalErrorState('Sepete ekleme işlemi başlatılamadı.'); return; } if (typeof AjaxCart !== 'undefined' && typeof AjaxCart.addproducttocart_details === 'function') { var originalSuccessCallback = AjaxCart.success_process; var requestedQuantity = $form.find('input[name*="EnteredQuantity"]').val() || 1; AjaxCart.success_process = function(response) { // --- Purchase limit auto-retry --- if (response && response.isPurchaseLimitError === true) { var remaining = response.remainingPurchaseRight; var limit = response.purchaseLimit; AjaxCart.success_process = originalSuccessCallback; // Restore before retry if (remaining 0) { productLink[0].click(); } }); })