;(function($,w){'use strict';if(!w.jQuery){throw 'Ideasoft: jQuery not found';}
w.IdeaApp[IdeaApp.helpers.getRouteGroup()]={init:function(){IdeaApp.helpers.initializePage();},contactForm:{init:function(){this.afterInit();this.validateForm();this.eventListener();},afterInit:function(){IdeaApp.helpers.maskPhone([$('input[name="phone"]')]);},validateForm:function(){$('[data-selector="contact-form"]').validate({errorElement:"div",validClass:'validate',errorClass:'validate-error',rules:{fullname:{required:true,minlength:5,maxlength:60},email:{required:true,email:{depends:function(){$(this).val($.trim($(this).val()));return true;}},maxlength:60},phone:{required:true,minlength:7,maxlength:20,phoneValid:true},subject:{required:true,minlength:5,maxlength:60},message:{required:true,minlength:5,maxlength:1000},personalDataAgreement:{required:true},},messages:{fullname:{required:"Lütfen "+IdeaApp.helpers.getFormValidateMessage('[data-selector="contact-form"] input[name="fullname"]')+" giriniz.",minlength:""+IdeaApp.helpers.getFormValidateMessage('[data-selector="contact-form"] input[name="fullname"]')+" en az 5 karakter olmalıdır.",maxlength:""+IdeaApp.helpers.getFormValidateMessage('[data-selector="contact-form"] input[name="fullname"]')+" en fazla 60 karakter olmalıdır."},email:{required:"Lütfen "+IdeaApp.helpers.getFormValidateMessage('[data-selector="contact-form"] input[name="email"]')+" giriniz.",email:""+IdeaApp.helpers.getFormValidateMessage('[data-selector="contact-form"] input[name="email"]')+" uygun formatta olmalıdır.",maxlength:""+IdeaApp.helpers.getFormValidateMessage('[data-selector="contact-form"] input[name="email"]')+" en fazla 60 karakter olmalıdır."},phone:{required:"Lütfen "+IdeaApp.helpers.getFormValidateMessage('[data-selector="contact-form"] input[name="phone"]')+" giriniz.",minlength:""+IdeaApp.helpers.getFormValidateMessage('[data-selector="contact-form"] input[name="phone"]')+" en az 7 karakter olmalıdır.",maxlength:""+IdeaApp.helpers.getFormValidateMessage('[data-selector="contact-form"] input[name="phone"]')+" en fazla 20 karakter olmalıdır.",phoneValid:"Lütfen geçerli bir "+IdeaApp.helpers.getFormValidateMessage('[data-selector="contact-form"] input[name="phone"]')+" giriniz."},subject:{required:"Lütfen "+IdeaApp.helpers.getFormValidateMessage('[data-selector="contact-form"] input[name="subject"]')+" giriniz.",minlength:""+IdeaApp.helpers.getFormValidateMessage('[data-selector="contact-form"] input[name="subject"]')+" en az 5 karakter olmalıdır.",maxlength:""+IdeaApp.helpers.getFormValidateMessage('[data-selector="contact-form"] input[name="subject"]')+" en fazla 60 karakter olmalıdır."},message:{required:"Lütfen "+IdeaApp.helpers.getFormValidateMessage('[data-selector="contact-form"] textarea[name="message"]')+" giriniz.",minlength:""+IdeaApp.helpers.getFormValidateMessage('[data-selector="contact-form"] textarea[name="message"]')+" en az 5 karakter olmalıdır.",maxlength:""+IdeaApp.helpers.getFormValidateMessage('[data-selector="contact-form"] textarea[name="message"]')+" en fazla 1000 karakter olmalıdır."},personalDataAgreement:{required:"Lütfen Kişisel Verilerin Korunması alanını boş bırakmayınız."}},errorPlacement:function(error,element){if(element.attr("type")=="radio"){element.parents('.radio-custom-groups').after(error)}else if(element.attr("type")=="checkbox"){element.parents('.checkbox-custom-groups').after(error)}else if(element.attr("data-selector")=="birth-date"){element.parents('.input-group').after(error);}else{element.after(error);}},showErrors:function(errorMap,errorList){for(var i=0;i<errorList.length;i++){var error=errorList[i];error=IdeaApp.helpers.modifyValidationError(error);}
this.defaultShowErrors();}});$.validator.addMethod('email',function(email){return IdeaApp.helpers.checkEmail(email);});$.validator.addMethod('phoneValid',function(value){return IdeaApp.helpers.checkPhone(value);});},eventListener:function(){$(document).on('click','[data-selector="contact-form-submit-button"]',function(){IdeaApp.helpers.ajaxRequest({url:IdeaApp.routing.generate('/recaptcha-visibility'),success:function(response){if(response.success){if(response.data==='invisible'){$("#contact-form").submit();}else{if(grecaptcha.getResponse()){reCaptchaContactSubmit();$("#contact-form").submit();}else{IdeaApp.plugins.notification('Google Doğrulamasını işaretleyiniz.','warning');$(this).removeClass('btn-loading');}}}else{IdeaApp.plugins.notification(response.errorMessage,'warning');IdeaApp.plugins.loadingBar.hide();}}});});$(document).on('focus','[name="phone"]',function(){IdeaApp.helpers.addPrefix($(this),null);});$(document).on('input','[name="phone"]',function(){IdeaApp.helpers.addPrefix($(this),null);});}},supportForm:{init:function(){this.validateForm();this.eventListener();},validateForm:function(){$('[data-selector="support-form"]').validate({errorElement:"div",validClass:'validate',errorClass:'validate-error',rules:{email:{required:true,email:{depends:function(){$(this).val($.trim($(this).val()));return true;}},},refno:{required:true}},messages:{email:{required:"Lütfen "+IdeaApp.helpers.getFormValidateMessage('[data-selector="support-form"] input[name="email"]')+" giriniz.",email:""+IdeaApp.helpers.getFormValidateMessage('[data-selector="support-form"] input[name="email"]')+" uygun formatta olmalıdır."},refno:{required:"Lütfen "+IdeaApp.helpers.getFormValidateMessage('[data-selector="support-form"] input[name="refno"]')+" giriniz."}},showErrors:function(errorMap,errorList){for(var i=0;i<errorList.length;i++){var error=errorList[i];error=IdeaApp.helpers.modifyValidationError(error);}
this.defaultShowErrors();}});},eventListener:function(){$(document).on('click','[data-selector="support-form-button"]',function(){var supportForm=$('[data-selector="support-form"]');if(supportForm.valid()){$(this).addClass('btn-loading');}});}},fastComment:{init:function(){this.reviewStatus();this.validateForm();this.getHash();this.fastSignupFormValidate();this.eventListener();},accordion:function(element){var accordionContent='[data-selector="fast-review-accordion-content"]';element.parent().siblings().removeClass('active');$(accordionContent).slideUp(300);if(element.parent().hasClass('active')){element.parent().removeClass('active');element.next(accordionContent).slideUp(300);}else{element.parent().addClass('active');element.next(accordionContent).slideDown(300);}},reviewStatus:function(){var reviewfirstItem='.fast-review-item:not(".passive"):first';var accordionContent='[data-selector="fast-review-accordion-content"]';$(reviewfirstItem).addClass('active');$(reviewfirstItem).find(accordionContent).slideDown(300);if(!$('.fast-review-item').hasClass("active")){$('<div class="alert alert-success">Tüm değerlendirmeleriniz alınmıştır, vakit ayırdığınız için teşekkür ederiz.</div>').insertBefore('.fast-review-items');}},togglePanel:function(submitButton){var fastReviewItem=submitButton.parents('[data-selector="fast-review-item"]');var accordionContent='[data-selector="fast-review-accordion-content"]'
fastReviewItem.removeClass('active').addClass('passive');$(fastReviewItem).find(accordionContent).slideUp(300);this.reviewStatus();},getHash:function(){var path=window.location.pathname;var str=path.split("/");var hash=str[2];$('[name="hash"]').val(hash);$('[name="hashShoppingExperience"]').val(hash);},validateForm:function(){var fastReviewForm=$('[data-selector="fast-review-form"]');fastReviewForm.each(function(index){$(this).validate({errorElement:"div",validClass:'validate',errorClass:'validate-error',messages:{content:{required:"Lütfen yorumunuzu giriniz."},title:{required:"Lütfen yorum başlığı giriniz."}},showErrors:function(errorMap,errorList){for(var i=0;i<errorList.length;i++){var error=errorList[i];error=IdeaApp.helpers.modifyValidationError(error);}
this.defaultShowErrors();}});})},submitForm:function(submitButton){$('#fastSignUpDiv').removeClass('blink');var fastReviewForm=submitButton.parents('form');var self=this;if(fastReviewForm.valid()){fastReviewForm.find('[data-selector="fast-review-form-button"]').addClass('btn-loading').attr('disabled',true);IdeaApp.helpers.ajaxRequest({url:IdeaApp.routing.generate('/fastCommentSave'),data:fastReviewForm.serialize(),success:function(response){if(response.success){IdeaApp.plugins.notification(response.data.message,'confirmation');self.togglePanel(submitButton);}else{if(response.errorMessage.error==='452134'){IdeaApp.plugins.notification('Form hatası. Lütfen formdaki alanları istendiği formatta doldurunuz','warning');}
if(response.errorMessage.error==='220624'){IdeaApp.plugins.notification("Bu ürüne daha önce yorum yaptınız.",'warning');self.togglePanel(submitButton);}
if(response.errorMessage.error==='200311'){IdeaApp.plugins.notification("Bilinmeyen bir hata oluştu lütfen iletişime geçin",'warning');}else if(response.errorMessage.error==='110320'){$('#fastSignUpDiv').css("display","block").addClass('blink');$('html').animate({scrollTop:$("#fastSignUpDiv").offset().top-200},200);}}
fastReviewForm.find('[data-selector="fast-review-form-button"]').removeClass('btn-loading').attr('disabled',false);}});}},fastSignupFormValidate:function(){$('#fastSignupForm').validate({errorElement:"div",validClass:'validate',errorClass:'validate-error',focusInvalid:false,rules:{password:{required:true,minlength:6,regex:/^(?=.*[0-9])(?=.*[a-zA-Z])[a-zA-Z0-9!\.@#$%&]{6,16}$/,},memberAgreement:{required:true},personalDataAgreement:{required:true}},messages:{password:{required:"Lütfen şifre belirtiniz.",minlength:"Şifre en az 6 haneli olmalıdır.",regex:"Şifre uzunluğu en az 6 hane sadece harf ve rakamdan oluşmalıdır."},memberAgreement:{required:"Lütfen üyelik sözleşmesini kabul edin."},personalDataAgreement:{required:"Lütfen kişisel verileri koruma kanununu kabul edin."}},errorPlacement:function(error,element){if($("div.validate-error").length==0){element.parents('.cart-block').eq(0).append(error).addClass('cart-block-error');}},showErrors:function(errorMap,errorList){for(var i=0;i<errorList.length;i++){var error=errorList[i];error=IdeaApp.helpers.modifyValidationError(error);}
this.defaultShowErrors();}});$.validator.addMethod('regex',function(value,element,regexp){return IdeaApp.helpers.checkRegex(value,element,regexp)});},submitFastSignupForm:function(submitButton){var formElement=$("#fastSignupForm");if(!formElement.valid()){return;}
submitButton.attr('disabled','disabled').addClass('btn-loading');var reviewActiveItem=$('[data-selector="fast-review-item"].active');IdeaApp.helpers.ajaxRequest({url:IdeaApp.routing.generate('/hizli-uye-ol?hash='+formElement.attr('data-order-hash')),data:formElement.serialize(),success:function(response){if(response.success){IdeaApp.plugins.notification("Sisteme üyeliğiniz başarıyla tamamlanmıştır.",'confirmation');$('.order-fast-signup').slideUp(300);$('html').animate({scrollTop:reviewActiveItem.offset().top-$('#fastSignUpDiv').height+100},200);}else{IdeaApp.plugins.notification(response.errorMessage,'warning');submitButton.removeAttr('disabled').removeClass('btn-loading');}}});},changeMemberPassword:function(element){$('div.validate-error').remove();if(element.val().length>3){$('[data-selector="fast-signup-checkbox-groups"]').fadeIn().removeClass('d-none');}else{$('[data-selector="fast-signup-checkbox-groups"]').fadeOut().addClass('d-none');}},checkFastSignupForm:function(){$('div.validate-error').remove();if(!$('#fastSignupForm').valid()){return;}
$('.order-fast-signup').removeClass('cart-block-error');},showPassword:function(element){if(element.hasClass('fa-eye-slash')){element.removeClass('fa-eye-slash').addClass('fa-eye');$('input[name="password"]').attr('type','text');}else{element.removeClass('fa-eye').addClass('fa-eye-slash');$('input[name="password"]').attr('type','password');}},eventListener:function(){var self=this;$(document).on('click','[data-selector="fast-review-form-button"]',function(e){e.preventDefault();self.submitForm($(this));});$(document).on('click','[data-selector="fast-review-accordion-header"]',function(){self.accordion($(this));});$(document).on('click','[data-selector="submit-signup-form"]',function(e){e.preventDefault();self.submitFastSignupForm($(this));});$('input[name="password"]').keyup(function(){self.changeMemberPassword($(this));});$(document).on('change','[name="memberAgreement"], [name="personalDataAgreement"]',function(e){e.preventDefault();self.checkFastSignupForm();});$(document).on('click','.password-icon',function(){self.showPassword($(this));});}},orderTrackingForm:{init:function(){this.validateForm();this.eventListener();},getOrderId:function(element){return element.attr('data-id');},remakeOrder:function(element){if(element.attr('disabled')){return;}
element.addClass('btn-loading').attr('disabled',true);var options={url:IdeaApp.routing.generate('/hesabim/siparisi-tekrarla'),data:"orderId="+this.getOrderId(element),success:function(response){if(response.success){window.location=response.data.url;}else{IdeaApp.plugins.notification(response.errorMessage,'warning');}
element.removeClass('btn-loading').removeAttr('disabled');}};IdeaApp.helpers.ajaxRequest(options);},validateForm:function(){$('[data-selector="order-tracking-form"]').validate({errorElement:"div",validClass:'validate',errorClass:'validate-error',rules:{refno:{required:true},email:{required:true,email:{depends:function(){$(this).val($.trim($(this).val()));return true;}},maxlength:60}},messages:{refno:{required:"Lütfen "+IdeaApp.helpers.getFormValidateMessage('[data-selector="order-tracking-form"] input[name="refno"]')+" giriniz."},email:{required:"Lütfen "+IdeaApp.helpers.getFormValidateMessage('[data-selector="order-tracking-form"] input[name="email"]')+" giriniz.",email:""+IdeaApp.helpers.getFormValidateMessage('[data-selector="order-tracking-form"] input[name="email"]')+" uygun formatta olmalıdır.",maxlength:""+IdeaApp.helpers.getFormValidateMessage('[data-selector="order-tracking-form"] input[name="email"]')+" en fazla 60 karakter olmalıdır."}},});$.validator.addMethod('email',function(email){return IdeaApp.helpers.checkEmail(email);});},submitForm:function(el){el.addClass('btn-loading').attr('disabled',true);var orderTrackingForm=$('[data-selector="order-tracking-form"]');if(orderTrackingForm.valid()){IdeaApp.helpers.ajaxRequest({url:IdeaApp.routing.generate('/siparis-sorgu-gonder'),data:orderTrackingForm.serialize(),success:function(response){if(response.success){if(response.data.redirect){let pathname=response.data.redirect
window.location.href=window.location.pathname;}
el.removeClass('btn-loading').removeAttr('disabled');$('[data-selector="order-details"]').html(response.data.order_content);orderTrackingForm[0].reset();}else{orderTrackingForm[0].reset();IdeaApp.plugins.notification(response.errorMessage,'warning');}}});}},eventListener:function(){var self=this;$(document).on('click','[data-selector="order-tracking-form-submit-button"]',function(){IdeaApp.helpers.ajaxRequest({url:IdeaApp.routing.generate('/recaptcha-visibility'),success:function(response){if(response.success){if(response.data==='invisible'){self.submitForm($(this));}else{if(grecaptcha.getResponse()){reCaptchaOrderTrackingSubmit();self.submitForm($(this));grecaptcha.reset();}else{IdeaApp.plugins.notification('Google Doğrulamasını işaretleyiniz.','warning');$(this).removeClass('btn-loading');grecaptcha.reset();}}}else{IdeaApp.plugins.notification(response.errorMessage,'warning');IdeaApp.plugins.loadingBar.hide();}}});});$(document).on('click','[data-selector="print-shipping"], [data-selector="print-order"]',function(){self.print($(this));});$(document).on('click','[data-selector="refund-and-cancel"]',function(){var url=IdeaApp.routing.generate("/hesabim/iade-ve-iptal?orderId="+$(this).attr("data-order"));if($(this).attr("data-member")&&!isMember&&$(this).attr("data-member-status")!=='suspended'){$('#memberInformation').modal('show');$('.corfim-modal').on('click',function(){window.location.href=url;})}else{window.location.href=url;}});$(document).on('click','[data-selector="remake-order"]',function(){self.remakeOrder($(this));});}}}}(jQuery,window));function reCaptchaContactSubmit(token){$("#contact-form").append("<input name='recaptcha' type='hidden' value='"+token+"'>");}
function reCaptchaOrderTrackingSubmit(token){$("#order-tracking-form").append("<input name='recaptcha' type='hidden' value='"+token+"'>");}