
var BLOCK_FN = {};
var PAGE_LINK = {"CART":"sepet","LOGIN":"uye-girisi-sayfasi","REGISTER":"uye-kayit","CONTACT":"iletisim","CUSTOMER_ORDER_LIST":"uye-siparisleri","ORDER":"order"};
BLOCK_FN["1226"] = function(BLOCK, SETTING) {
/* Header */
window.headerMemberLoginFn = (result, options) => {
    popoverAlert.show(
        document.getElementById(`${options.prefix}${options.type || 'email'}`), 
        result.message, 
        2400, 
        `btn ${(result.status === true) ? 'btn-success' : 'btn-danger'} text-left`,
        false
    );
    if(result.status === true) {
        setTimeout(() => {
            window.location.reload();
        }, 1500);
    }
}

window[`headercart-cb-${BLOCK.ID}`] = () => {
    loadSubFolder({
        pageId: 1,
        blockParentId: 1001,
        subFolder: 'cart',
        success:  function(loadRes){
            let popupContent = T(`#header-cart-panel-${BLOCK.ID} .drawer-body`);
            popupContent.html(loadRes);
            evalScripts(popupContent[0].innerHTML);
        }
    });
}

if(CART_DROPDOWN_LIST === true) {
    const cartDropdownBtn = T('.header-cart-dropdown'),
          dropdownContent = T(`.header-cart-dropdown-list`),
          cartBtnParent = cartDropdownBtn.length ? T(cartDropdownBtn[0].parentNode) : null;
    let status = 1;
    callbacks.cart.add.push(() => { status = 1; });
    if(cartDropdownBtn.length && dropdownContent.length) {
        cartDropdownBtn.on('mouseenter', () => {
            if(matchMedia("screen and (max-width:768px)").matches === true) return;
            if (status == 1) {
                dropdownContent.html('');
                dropdownContent.addClass('is-loading');
            }
            loadSubFolder({
                pageId: 1,
                blockParentId: 1001,
                subFolder: 'cart',
                success: function(loadRes){
                    dropdownContent.html(loadRes);
                    evalScripts(dropdownContent[0].innerHTML);
                    dropdownContent.removeClass('is-loading');
                    status = '';
                }
            });
            cartDropdownBtn.addClass('cart-viewed');
            dropdownContent.removeClass('d-none');
        });
        cartBtnParent.on('mouseleave', () => {
            if(matchMedia("screen and (max-width:768px)").matches === true) return;
            setTimeout(() => {
                cartDropdownBtn.removeClass('cart-viewed');
                dropdownContent.addClass('d-none');
            }, 150);
        });
    }
}

window.onscroll = () => {
    if (document.body.scrollTop > T('header').height() || document.documentElement.scrollTop > T('header').height()) {
    T(`#scroll-to-up-${BLOCK.ID}`).show();
    } else { T(`#scroll-to-up-${BLOCK.ID}`).hide(); }
};
T(`#scroll-to-up-${BLOCK.ID}`).on('click', () => {
    scroll({ top: 0, behavior: "smooth" });
});

const liveSearch = T('[data-search="live-search"]');
if (liveSearch.length > 0) {
    const liveSearchApp = {
        data() {
            return {
                data : '',
                searchVal : '',
                valueLimit: 3,
                licence: liveSearch[0].dataset.licence || 0,
                timer: null,
            }
        },
        methods: {
            search() {
                const self = this;
                self.timer = setTimeout(() => {
                    const formData = new FormData();
                    formData.append('searchWord', self.searchVal);
                    
                    axios.post(getEndpoint('SEARCH'), formData).then(response => {
                        self.data = response.data;
                    });
                }, 250);
            },
            searchAll() {
                const self = this;
                self.timer = setTimeout(() => {
                    axios.get(getEndpoint('SEARCH_ALL', self.searchVal)).then(response => {
                        self.data = response.data;
                    });
                }, 250);
            }
        },
        watch: {
            'searchVal'(value) {
                const self = this;
                clearTimeout(self.timer);
                if (value.length >= self.valueLimit) {
                    self.licence == 1 ? self.searchAll() : self.search();
                } else {
                    self.data = '';
                }
            }
        },
        mounted() {
            const self = this;
            document.addEventListener('click', e => {
                var Dom = e.target.nodeName == 'I' ? e.target.parentElement : e.target;
                const parentDom = Dom.closest('#search');
                if (parentDom == null) {
                    self.searchVal = '';
                    self.data = '';
                }
            });
        },
    }
    Vue.createApp(liveSearchApp).mount(`#search`);
}

T(`#toggleVisiblePassword${BLOCK.ID}`).on('click', e => {
    const icon = e.target;
    if (icon == null && T(icon).length < 1) return;
    const type = T(icon).hasClass('ti-eye-off') ? 'text' : 'password';
    T(icon.closest('.input-group').querySelector('input')).attr('type', type);
    T(icon).toggleClass('ti-eye-off text-gray ti-eye text-primary');
});

let nav = T(`.menu-${BLOCK.ID}`);
let navTime;
T(nav).on('mouseenter', () => {
    navTime = setTimeout(() => {
        if (!T(nav).hasClass('active')) T(nav).addClass("active");
    }, 250);
});
T(nav).on('mouseleave', () => {
    T(nav).removeClass('active');
    clearTimeout(navTime);
});

const app = T(`#mobile-app-${BLOCK.ID}`);
if (app.length > 0 && T.isMobile()) {
    const MobileAppRedirect = T(`#mobile-app-redirect-${BLOCK.ID}`)[0].value,
          AppMarketLink = T(`#app-market-link-${BLOCK.ID}`)[0].value,
          OpenAppLink = T(`#open-app-link-${BLOCK.ID}`)[0].value;
    if (T.getCookie('mobileApp') == 1) {
        app[0].remove();
    } else {
        app.show();
        app.removeClass('d-none');
    }
    let storeUrl, timeout;
    if (MobileAppRedirect == 'ios') {
        storeUrl = `https://itunes.apple.com/app/id${AppMarketLink}`;
    } else if (MobileAppRedirect == 'android') {
        storeUrl = `market://details?id=${AppMarketLink}`;
    }
    const meta = document.createElement('meta');
          meta.name = 'apple-itunes-app';
          meta.content = `app-id=${AppMarketLink}, affiliate-data=myAffiliateData, app-argument=${OpenAppLink}://`;
    T('head')[0].append(meta);
    T(`#mobile-app-close-${BLOCK.ID}`).on('click', () => {
        app[0].remove();
        T.setCookie('mobileApp', 1);
    });
    T(`#mobile-app-download-${BLOCK.ID}`).on('click', () => {
        timeout = setTimeout(() => {
            document.location.href = storeUrl;
        }, 2000);
        document.location.href = `${OpenAppLink}://`;
    });
}

}
 try{ BLOCK_FN["1226"]({"ID":1226,"PARENT_ID":1001,"PAGE_ID":37,"NAME":"\u00dcst K\u0131s\u0131m","ASSETS":"\/theme\/v5-foryou\/assets\/"}, {"IS_STICKY":"1","DISPLAY_TITLE":"1","MENU_SELECTED":"","GOOGLE_RECAPTCHA":{"CLIENT_KEY":"","ACTIVE":false}});   }catch(ex){ console.error('HATA VAR : Üst Kısım/37'); console.error(ex); }


BLOCK_FN["1227"] = function(BLOCK, SETTING) {
/* Breadcrumb */


}
 try{ BLOCK_FN["1227"]({"ID":1227,"PARENT_ID":1005,"PAGE_ID":37,"NAME":"Navigasyon","ASSETS":"\/theme\/v5-foryou\/assets\/"}, {"DISPLAY_TITLE":1,"GOOGLE_RECAPTCHA":{"CLIENT_KEY":"","ACTIVE":false}});   }catch(ex){ console.error('HATA VAR : Navigasyon/37'); console.error(ex); }


BLOCK_FN["1228"] = function(BLOCK, SETTING) {
/* OrderByPhone */
T(`#reload-captcha-${BLOCK.ID}`).on('click', e => {
    document.getElementById(`captcha-${BLOCK.ID}`).setAttribute('src', `/SecCode.php?${new Date().getTime()}`);
    document.getElementById(`seccode-${BLOCK.ID}`).value = '';
});

let today = new Date();
const date = document.querySelector(`#date-${BLOCK.ID}`),
      hour = document.querySelector(`#hour-${BLOCK.ID}`),
      dd = String(today.getDate()).padStart(2, '0'),
      mm = String(today.getMonth() + 1).padStart(2, '0'),
      yyyy = today.getFullYear();
today = dd + '-' + mm + '-' + yyyy;

flatpickr(date, {
    dateFormat: 'd-m-Y',
    minDate: 'today',
    "disable": [
        function(date) {
            return (date.getDay() === 0);
        }
    ],
    "locale": {
        "firstDayOfWeek": 1
    },
    onClose : () => {
        hour.disabled = false;
        Array.from(hour.options).forEach( el => {
            if (today == date.value) {
                const toHour = new Date().getHours() + ':00';
                if (el.value != '') {
                    const arrHour = el.value.split(' - ');
                    if (arrHour[0] < toHour) {
                        el.disabled = true;
                    }
                }
            } else {
                el.disabled = false;
            }
        });
    }
});

T(`#${BLOCK.ID}`).on('submit', e => {
    e.stopPropagation();
    e.preventDefault();

    const formEl = e.target;
    popoverAlert.hideAll();

    if(!T.checkValidity(formEl))
        return;

    const data = new FormData(formEl);

    T.buttonLock.dom = T(`#send-${BLOCK.ID}`)[0];
    T.buttonLock.lock();

    axios.post(formEl.action, data).then(response => {
        const result = response.data;
        const element = T(`#${result.key}-${BLOCK.ID}`)[0];

        if (result.status > 0) {
            T.notify({
                 text: result.statusText,
                className: 'success',
                duration: 3200,
                iconClass : 'ti-thumbs-up',
            });
        } else {
            popoverAlert.show(
                element.type == 'checkbox' ? element.nextElementSibling : element,
                result.statusText,
                3000,
                `btn btn-danger no-radius text-left`,
                false,
                `${(result.key == 'seccode' || element.type == 'checkbox') ? '' : 'inline'}`
            );
        }
        T.buttonLock.unlock();
    }).catch(error => {
        console.warn(`Contact form send error => ${error}`);
    });
});


}
 try{ BLOCK_FN["1228"]({"ID":1228,"PARENT_ID":1060,"PAGE_ID":37,"NAME":"Telefonla Sipari\u015f","ASSETS":"\/theme\/v5-foryou\/assets\/"}, {"INFO":"<div class=\"w-100 h-100 p-2 border border-gray border-round\">\n<div class=\"w-100 mb-1 block-title text-primary border-bottom border-gray\">TELEFONLA S\u0130PAR\u0130\u015e A&Ccedil;IKLAMASI<\/div>\n<div class=\"col-12\">\n<div class=\"row\">\n<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.<\/p>\n<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.<\/p>\n<\/div>\n<\/div>\n<\/div>","DISPLAY_TITLE":1,"GOOGLE_RECAPTCHA":{"CLIENT_KEY":"","ACTIVE":false}});   }catch(ex){ console.error('HATA VAR : Telefonla Sipariş/37'); console.error(ex); }


BLOCK_FN["1229"] = function(BLOCK, SETTING) {
/* Footer */
T(`#newsletter-form-${BLOCK.ID}`).on('submit', e => {
    e.stopPropagation();
    e.preventDefault();
    const formEl = e.target;
    popoverAlert.hideAll();
    if(!T.checkValidity(formEl))
        return;
    var data = new FormData(formEl);
    axios.post('/srv/service/guest/subscribeNewsletter', data).then(response => {
        const result = response.data;
        const element = T(`#news_${result.key}-${BLOCK.ID}`)[0] || formEl.querySelector('[name="email"]');
        if(result.status == 1) {
            T.notify({
                text: result.message,
                className: 'success',
                stopOnFocus : true,
                duration: 3200,
            });
            formEl.reset();
            return;
        }
        if (element) {
            popoverAlert.show(
                element.type == 'checkbox' ? element.nextElementSibling : element, 
                result.message || result.statusText,
                3000, 
                `btn btn-danger no-radius text-left`,
                false,
                `${element.type == 'checkbox' ? '' : 'inline'}`
            );
        }
    });
});


}
 try{ BLOCK_FN["1229"]({"ID":1229,"PARENT_ID":1002,"PAGE_ID":37,"NAME":"Alt K\u0131s\u0131m","ASSETS":"\/theme\/v5-foryou\/assets\/"}, {"DISPLAY_TITLE":"1","GOOGLE_RECAPTCHA":{"CLIENT_KEY":"","ACTIVE":false}});   }catch(ex){ console.error('HATA VAR : Alt Kısım/37'); console.error(ex); }

