$(document).ready(function () { $(function() { $('body').removeClass('fade-out'); }); $('aISOFFORNOW').on('click',function(e){ var href = this.href; if (!href || href == "#") {return false;} if ( href.match(/www.minsgourmet.com/) ){ return true; } e.preventDefault(); newWindow(href); return false; }); $(function(){ $('.menui').slicknav({ prependTo:'.menu', closeOnClick:false, allowParentLinks: true, label: 'MENU', open: function(trigger){ var that = trigger.parent().children('ul'); $('.slicknav_menu ul li.slicknav_open ul').each(function(){ if($(this).get( 0 ) != that.get( 0 )){ $(this).slideUp().addClass('slicknav_hidden'); $(this).parent().removeClass('slicknav_open').addClass('slicknav_collapsed'); } }) } }); }); }); var stx = stx || {}; stx.productspinner = (function () { var _foo = ''; function _incrementProduct(product) { var currValue = product.find( '.prod-quant' ).val(); var newValue = parseInt( currValue, 10) + 1; if ( isNaN(newValue) ) { newValue = 1; } var newValueOverlay = newValue; product.find( '.prod-quant' ).val(newValue); } function _decrementProduct(product) { var currValue = product.find( '.prod-quant' ).val(); var newValue = parseInt( currValue, 10) - 1; if ( isNaN(newValue) ) { newValue = 0; } var newValueOverlay = newValue; if ( newValue <0 ) { newValue = 0; } product.find( '.prod-quant' ).val(newValue); } function init() { // set up click handlers $( '.product-increment' ).on('click',function(){ var product = $(this).closest( '.prod-quantity' ); _incrementProduct(product); }); $( '.product-decrement' ).on('click',function(){ var product = $(this).closest( '.prod-quantity' ); _decrementProduct(product); }); } return { init: init }; })(); $(document).ready(function(){ stx.productspinner.init(); $('body').on('click',function(){ $('.prod-quant-wrapper').removeClass('prod-quant-missing'); }); $('.product-form').submit(function(e){ var currValue = $(this).find( '.prod-quant' ).val(); if (currValue <1) { e.preventDefault(); $(this).find( '.prod-quant' ).parent().addClass('prod-quant-missing'); return false; } }); }); jQuery(document).ready(function(){ //*on refresh, many browsers keep us at our current location*// var initscroll = jQuery(window).scrollTop(); if (initscroll> 5) { jQuery("body").addClass("fixed-header"); } jQuery(window).scroll(function() { var scroll = jQuery(window).scrollTop(); if (scroll>= 5) { jQuery("body").addClass("fixed-header"); } else{ jQuery("body").removeClass("fixed-header"); } }); }); $(document).ready(function() { get_cart('mightycart','cart'); $('.productform').submit(function(event){ var id = $(this).attr('id'); event.preventDefault(); $('#'+id+'products-wrapper').removeClass('hide-transition'); $('#'+id+'-feedback').addClass('spinner'); get_cart(id,'cart','update'); }); $('.minicart .cart-icon').on('click',function(event){ if($('.minicart').hasClass('show') ) { $('.minicart').removeClass('show'); } else { $('.minicart').addClass('show'); } event.stopPropagation(); }); }); function bind_toggle_minicart() { $('.minicart .close-minicart').on('click',function(event){ if($('.minicart').hasClass('show') ) { $('.minicart').removeClass('show'); } else { $('.minicart').addClass('show'); } event.stopPropagation(); }); } function get_cart( e, replace, typeofrequest ){ var myData = $('#'+e).serialize(); $('#'+e+' .button').addClass('processing'); if(myData) { myData += "&add=1&p=quickcart&d.t=spices"; }else { myData = "add=1&p=quickcart&t=spices&d.t=spices"; } $.ajax({ url: '/mycart/', dataType: 'text', type: 'post', contentType: 'application/x-www-form-urlencoded; charset=UTF-8', data: myData, success: function( data, textStatus, jQxhr ){ var data= $.parseJSON(data); $('.product-added-checkmark').remove(); var itemcount = 0; var carttotal = "$0"; if (typeof data.shipto_product_loop === 'undefined') { data.shipto_product_loop = 0; } else { itemcount = data.shipto_items_for_shipping; carttotal = "$" + (parseFloat(data.Total_With_Discount)).toFixed(2); $('#cart-count').html(carttotal); } $('#'+replace).html('
'+ data.html + '
'); if(itemcount> 0) { $('.menui ul li.last ul').addClass('show'); } //scrollto('#cart-count'); var successhtml = '
Product Added
'; var checkmarkhtml = ''; //scrollto('#cart-count'); if (typeofrequest == "update") { // $('#'+e+'-feedback').before(checkmarkhtml ); $('#'+e+'products-wrapper').addClass('hide-transition'); $('#'+e).closest('.modal').removeClass('show').addClass('hide-transition'); $('#'+e+' .button').removeClass('processing'); $('.minicart').addClass('show'); } if (data.shipto_product_loop.length> 0) { //we're landing on the page. We should have data. var checkmarkhtml = ''; data.shipto_product_loop.forEach(function(item) { // do something with `item` let itemcode = item.item_code; let justadded = "p"+itemcode; if(justadded == e) { $(".minicart ."+justadded).addClass("just-added"); } var i; for (i = 0; i '+ data.html + ''); if (data.shipto_product_loop.length> 0) { //we're landing on the page. We should have data. var checkmarkhtml = ''; data.shipto_product_loop.forEach(function(item) { // do something with `item` let itemcode = item.item_code; let justadded = "p"+itemcode; //console.log("yes, found a match:" + itemcode + " VS. " + e); if(justadded == e) { $(".minicart ."+justadded).addClass("just-added"); } var i; for (i = 0; i