var cart_path = "/services/cart" var cart = { 'add': function (productId, quantity) { $.ajax({ url: cart_path + "add", type: 'post', data: 'productId=' + productId + '&quantity=' + (typeof (quantity) != 'undefined' ? quantity : 1), dataType: 'json', success: function (json) { if (json['success']) { $.notify({ message: json['success'], target: '_blank' }, { element: 'body', position: null, type: "info", allow_dismiss: true, newest_on_top: false, placement: { from: "top", align: "right" }, offset: 20, spacing: 10, z_index: 2031, delay: 5000, timer: 1000, url_target: '_blank', mouse_over: null, animate: { enter: 'animated fadeInDown', exit: 'animated fadeOutUp' }, onShow: null, onShown: null, onClose: null, onClosed: null, icon_type: 'class', template: '
' }); // Need to set timeout otherwise it wont update the total setTimeout(function () { $('#cart-total').html(json['total']); $('#cart-preview').load('/sepetonizleme'); }, 100); $('#cart > ul').load('/particals/cartitems'); var loc = String(document.location); if (loc.indexOf("sepetim") >= 0) { window.location = "/sepetim"; } } else { $.notify({ message: json['error'], target: '_blank' }, { element: 'body', position: null, type: "error", allow_dismiss: true, newest_on_top: false, placement: { from: "top", align: "right" }, offset: 20, spacing: 10, z_index: 2031, delay: 5000, timer: 1000, url_target: '_blank', mouse_over: null, animate: { enter: 'animated fadeInDown', exit: 'animated fadeOutUp' }, onShow: null, onShown: null, onClose: null, onClosed: null, icon_type: 'class', template: '' }); } } }); }, 'update': function (key, quantity) { $.ajax({ url: cart_path + "add", type: 'post', data: 'productId=' + key + '&quantity=' + (typeof (quantity) != 'undefined' ? quantity : 1), dataType: 'json', success: function (json) { setTimeout(function () { $('#cart-total').html(json['total']); $('#cart-preview').load('/sepetonizleme'); }, 100); $('#cart > ul').load('/particals/cartitems'); var loc = String(document.location); if (loc.indexOf("sepetim") >= 0) { window.location = "/sepetim"; } } }); }, 'remove': function (key) { $.ajax({ url: cart_path + "remove", type: 'post', data: 'productId=' + key, dataType: 'json', success: function (json) { // Need to set timeout otherwise it wont update the total setTimeout(function () { $('#cart-total').html(json['total']); $('#cart-preview').load('/sepetonizleme'); }, 100); $('#cart > ul').load('/particals/cartitems'); var loc = String(document.location); if (loc.indexOf("sepetim") >= 0) { window.location = "/sepetim"; } } }); } } $(document).on("click", ".add-to-cart", function () { obj = $(this); var productId = parseInt(obj.data("productid")); var quantity = $(".product-quantity-" + productId).val() == undefined ? 1 : $(".product-quantity-" + productId).val(); cart.add(productId, quantity); }) $(document).on("click", ".update-cart", function () { obj = $(this); var productId = parseInt(obj.data("productid")); var quantity = $(".product-quantity-" + productId).val() == undefined ? 1 : $(".product-quantity-" + productId).val(); cart.update(productId, quantity); }) $(document).on("click", ".add-to-stock-alert", function () { obj = $(this); var productId = parseInt(obj.data("productid")); $.ajax({ url: cart_path + "stockAlert", type: 'post', data: 'productId=' + productId, dataType: 'json', success: function (json) { if (json['success']) { $.notify({ message: json['success'], target: '_blank' }, { element: 'body', position: null, type: "info", allow_dismiss: true, newest_on_top: false, placement: { from: "top", align: "right" }, offset: 20, spacing: 10, z_index: 2031, delay: 5000, timer: 1000, url_target: '_blank', mouse_over: null, animate: { enter: 'animated fadeInDown', exit: 'animated fadeOutUp' }, onShow: null, onShown: null, onClose: null, onClosed: null, icon_type: 'class', template: '' }); } else { $.notify({ message: json['error'], target: '_blank' }, { element: 'body', position: null, type: "error", allow_dismiss: true, newest_on_top: false, placement: { from: "top", align: "right" }, offset: 20, spacing: 10, z_index: 2031, delay: 5000, timer: 1000, url_target: '_blank', mouse_over: null, animate: { enter: 'animated fadeInDown', exit: 'animated fadeOutUp' }, onShow: null, onShown: null, onClose: null, onClosed: null, icon_type: 'class', template: '' }); } } }); }); $(document).ready(function () { $('.cardNumberInput').change(function () { var bin1 = $('.cardNumberInput1').val(); var bin2 = $('.cardNumberInput2').val(); var bin = (bin1 + bin2).replace(' ', '').substr(0, 6); if (bin.length > 5) { binChange(bin); } }); function binChange(bin) { $.ajax({ url: 'payment/cardbin?b=' + bin + '&s=' + $(".creditCardInstallmentCount:checked").val() + '&i=' + $("#orderInfoSession").val(), type: 'GET', success: function (response) { $("#taksitSecenek").empty(); $("#taksitSecenek").append(response); }, error: function (xhr, ajaxOptions, thrownError) { binControl(null); } }); } }).on("click", ".remember-pass-btn", function(){ var e = $("#forgotPass").val(); if(!validateEmail(e)){ $("#forgotPass").notify("Lütfen Geçerli Bir E-Mail Girin", "error"); return; } $.ajax({ url: '/services/rememberpassword', type: 'post', data: 'email=' + encodeURIComponent(e), dataType: 'json', beforeSend: function () { $('#forgotPass').button('loading'); }, complete: function () { $('#forgotPass').button('reset'); }, success: function (json) { $('.alert').remove(); if (json['error']) { $("#forgotPass").notify(json['error'], "error"); }else{ $("#forgotPass").val(""); $("#forgotPass").notify(json['success'], "success"); } } }); }); function validateEmail(email) { var re = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/; return re.test(String(email).toLowerCase()); } $(document).delegate('.agree', 'click', function(e) { e.preventDefault(); $('#modal-agree').remove(); var element = this; $.ajax({ url: $(element).attr('href'), type: 'get', dataType: 'html', success: function(data) { html = '