$(".addToCart-button").click(function(event){ event.preventDefault(); var $form = $(this).parents("form"); $.post( $form.attr("action"), //serialize Yii2 form $form.serialize() ) .done(function(result) { if (typeof(result.succes) != "undefined") { if(result.succes == true) { $('#addcatmodal').modal('show'); $("#addcatmodal-content").html(result.notify); $("#carticon").html(result.cart); } else { $('#addcatmodal').modal('hide'); } } }).fail(function() { console.log("server error"); }); return false; }); $(".addToFavorite-button").click(function(event){ event.preventDefault(); var button=$(this); var $form = $(this).parents("form"); $.post( '/products/productsfavoritelist/addproducttofavorite', //serialize Yii2 form $form.serialize() ) .done(function(result) { if (typeof(result.succes) != "undefined") { if(result.succes == true) { button.addClass('hide'); button.parent().find('.removeFromFavorite-button').removeClass('hide'); $('#addcatmodal').modal('show'); $("#addcatmodal-content").html(result.notify); $("#favicon").html(result.favicon); } else { $('#addcatmodal').modal('hide'); } } }).fail(function() { console.log("server error"); }); return false; }); $(".removeFromFavorite-button").click(function(event){ event.preventDefault(); var button=$(this); var $form = $(this).parents("form"); $.post( '/products/productsfavoritelist/removeproductfromfavorite', //serialize Yii2 form $form.serialize() ) .done(function(result) { if (typeof(result.succes) != "undefined") { if(result.succes == true) { button.addClass('hide'); button.parent().find('.addToFavorite-button').removeClass('hide'); $('#addcatmodal').modal('show'); $("#addcatmodal-content").html(result.notify); $("#favicon").html(result.favicon); } else { $('#addcatmodal').modal('hide'); } } }).fail(function() { console.log("server error"); }); return false; }); function inCartamount(varid,amount){ $.ajax({ url: '/shop/shopcart/updateamount', type: 'POST', data: {varid: varid, amount: amount}, dataType: "json", success: function(data) { $("#prodprice-"+varid).html(data.prodprice); $("#cartSummary").html(data.summary); $("#cart-shipping").html(data.shipping); $("#cart-payment").html(data.payment); $("#cart-ordersummary").html(data.ordersummary); $("#prodcount").html(data.prodcount); } }); } function sendCoupon(){ $("#coupon-error").hide(); $.ajax({ url : $("#sendcoupon").attr("href")+"?ajax=1", cache : false, data : { code : $("#couponcode").val() }, type : "POST", dataType : "JSON", success : function(data){ if(data.success == "false") { $("#coupon-error").html(data.msg); $("#coupon-error").fadeIn(); } else { $("#addcoupon").hide(); $("#carticon").html(data.sidecart); $("#coupon-container").html(data.coupon); $("#cart-shipping").html(data.shipping); $("#cart-payment").html(data.payment); $("#cart-ordersummary").html(data.summary); } } }); } /*$("#sendcoupon").click(function(e){ sendCoupon(); e.stopPropagation(); e.preventDefault(); return false; });*/ // Select all links with hashes $('a[href*="#"]') // Remove links that don't actually link to anything .not('[href="#"]') .not('[href="#0"]') .not('[href="#collapsesocial-box"]') .not('.carousel-control') .click(function(event) { // On-page links if ( location.pathname.replace(/^\//, '') == this.pathname.replace(/^\//, '') && location.hostname == this.hostname ) { // Figure out element to scroll to var target = $(this.hash); target = target.length ? target : $('[name=' + this.hash.slice(1) + ']'); // Does a scroll target exist? if (target.length) { // Only prevent default if animation is actually gonna happen event.preventDefault(); $('html, body').animate({ scrollTop: target.offset().top }, 1000, function() { // Callback after animation // Must change focus! var $target = $(target); $target.focus(); if ($target.is(":focus")) { // Checking if the target was focused return false; } else { $target.attr('tabindex','-1'); // Adding tabindex for elements not focusable $target.focus(); // Set focus again }; }); } } }); function addCommas(nStr) { nStr += ''; x = nStr.split('.'); x1 = x[0]; x2 = x.length > 1 ? '.' + x[1] : ''; var rgx = /(\d+)(\d{3})/; while (rgx.test(x1)) { x1 = x1.replace(rgx, '$1' + ',' + '$2'); } return x1 + x2; } // Normalize Carousel Heights - pass in Bootstrap Carousel items. /* jQuery(function($){ $(window).on('load', function(){ $('#myCarousel .item').carouselHeights(); }); }); */ $.fn.carouselHeights = function() { var items = $(this), //grab all slides heights = [], //create empty array to store height values tallest; //create variable to make note of the tallest slide var normalizeHeights = function() { items.each(function() { //add heights to array heights.push($(this).height()); }); tallest = Math.max.apply(null, heights); //cache largest value items.each(function() { $(this).css('min-height',tallest + 'px'); }); }; normalizeHeights(); $(window).on('resize orientationchange', function () { //reset vars tallest = 0; heights.length = 0; items.each(function() { $(this).css('min-height','0'); //reset min-height }); normalizeHeights(); //run it again }); }; (function () { $("#cookie-consent .form-button").css({ "background-color" : window.cookie_consent_color, "border-color" : window.cookie_consent_color }); $("#cookie-consent .icon").css("color", window.cookie_consent_color); setTimeout(function () { $("#cookie-consent").addClass("shown"); }, 1000); $("#cookie-consent .buttons .button button.form-button").click(function () { consentGranted(); $("#cookie-consent").removeClass("shown"); $.post("/site/agree-cookie-consent", {}, function (response) { }).fail(function () { }); }); }()); $(document).on("input", ".cartzipcode-field input", function () { if($(this).val().length==4) { var zipcodefield = $(this); $.ajax({ type: "POST", url: '/shop/shoporder/citynamebyzipcode', data:"zipcode="+$(this).val(), success: function(data){ if(data.success==1) { zipcodefield.closest('.shipping-content').find('.cartcity-field input').val(data.value); } } }); } }); $(document).ready(function () { let partners = $(".partners-slider"); if(partners.length) { partners.slick({ dots: false, buttons: false, infinite: false, speed: 500, slidesToShow: 10, slidesToScroll: 1, responsive: [ { breakpoint: 1600, settings: { slidesToShow: 6, slidesToScroll: 1 } }, { breakpoint: 1200, settings: { slidesToShow: 4, slidesToScroll: 1 } }, { breakpoint: 992, settings: { slidesToShow: 3, slidesToScroll: 1 } }, { breakpoint: 768, settings: { slidesToShow: 3, slidesToScroll: 1 } } ] }); } }) /* function startPlayer() { let width = $(document).width(); let height = $(document).height(); let fbWindow = window.open('','targetWindow', "toolbar=no, location=no,status=no,menubar=no,scrollbars=yes,resizable=yews,width="+width+",height="+height); fbWindow.opener = null; fbWindow.location = $("#elo-adas").attr("data-href"); // Lejátszó elérési útja } */