var site_domain = $('base').attr('href'); $(document).ready(function() { // Default Construct gdprSubscribeModal('form#subscribe_form', 'privacy-policy.html', '#1648a1', '#FFFFFF'); $('.nivo-slider').nivoSlider({ effect: 'fade', }); $('.infieldlabels').inFieldLabels(); $('.jqzoom').jqzoom({ zoomType: 'standard', lens:true, preloadImages: false, alwaysOn: false, position: 'left' }); /*************************** * * HOME PAGE * ***************************/ $('.home_product_container .price_reorder_btn').live("click",function(e) { e.preventDefault(); var order = 'ASC'; var type_id = $('ul.home_switcher_tabs li.on a').attr('id'); var type = type_id.substr(10); //order desc if($(this).hasClass('icon_up')) { order = 'DESC'; } //order asc else if($(this).hasClass('icon_up')) { order = 'ASC'; } $.ajax({ url: 'process_reorder.php', type: "POST", data: 'home_product_switcher=1&order='+order+'&type='+type, success: function(data) { //Update the list $('.home_switcher_list_container').html(data); //Make sure only the correct tab is showing $('.home_product_container').hide(); $('#list_products_'+type).show(); $('ul.home_switcher_tabs li').removeClass('on'); $('ul.home_switcher_tabs li a#show_prod_'+type).parent('li').addClass('on'); } }); }); /*************************** * * FORMS * ***************************/ $('#subscribe_form').ajaxForm({ url: "cont_enewsletter.php?ajax=1", // Change the url to the ajax version success: function(data) { $("#subscribe_form_container").html(data); } }); /*************************** * * PAYMENT * ***************************/ $('ul.payment_options li .po_icon').live("click",function(e) { e.preventDefault(); //e.stopPropagation(); //$('li.selected').removeClass('selected'); //$(this).addClass('selected'); $(this).closest('li').children("input[type=radio]").click(); }); /*************************** * * CART * ***************************/ $('select#shipping_select').live('change', function(){ var id = $(this).val(); $.ajax({ url: 'process_cart.php', type: "POST", data: 'ajax=1&m=cart_shipping&id='+id, success: function(data) { totals_array = data.split('|'); $('ul.subtotals .st_cart').html(totals_array[0]); $('ul.subtotals .st_discount').html(totals_array[2]); $('ul.subtotals .st_vat').html(totals_array[3]); $('.cart_total .st_total').html(totals_array[4]); } }); }); /*************************** * * MINI CART * ***************************/ //show cart slide on hover function openCart() { $(".cart_mini_container").fadeIn('fast', function() {}); } function openCartTimeOut() { timeoutval = 3000; $(".cart_mini_container").fadeIn('fast', function() { // Increase compatibility with unnamed functions }); window.setTimeout( function() { closeCart(); }, timeoutval ); // will work with every browser } //hide cart slide on exit function closeCart() { $(".cart_mini_container").fadeOut('fast', function() {}); //$(".cart_container").fadeOut("slow"); } var config_mini_cart = { over: openCart, // function = onMouseOver callback (REQUIRED) sensitivity: 5, timeout: 50, //milliseconds delay before onMouseOut out: closeCart // function = onMouseOut callback (REQUIRED) }; // Call hoverIntent with your selector $(".outter_cart_mini_container").hoverIntent( config_mini_cart ); $('.mycart_close').live("click",function(e) { e.preventDefault(); //$('.cart_mini_container').slideToggle('fast', 'linear', function() { $('.cart_mini_container').fadeOut('fast', function() { // Animation complete. }); }); // Add to cart $('.add_to_cart_button').live("click",function(e) { e.preventDefault(); var serialized = $(this).parents('form').serialize(); $.ajax({ url: 'process_cart.php', type: "POST", data: serialized + '&ajax=1', success: function(data) { $.ajax({ url: 'cont_cart_mini.php', type: "POST", data: 'ajax=1', success: function(response) { $('.outter_cart_mini_container').html(response); $('html, body').animate({ scrollTop: 0 }, 'slow', function() { openCartTimeOut(); }); } }); } }); }); // Remove from cart $('.cart_remove').live('click', function(e) { e.preventDefault(); var remove = $(this); var raw_id = $(this).parents('li').attr('id'); id = raw_id.substr(3); raw_id = raw_id.replace(/[;&,.+*~:!^$[\]()=>|\/]/g, "\\$&"); console.log(raw_id); $.ajax({ url: 'process_cart.php', type: "POST", data: 'id=' + id + '&cart_remove=1&ajax=1', success: function(data) { totals_array = data.split('|'); $('ul.subtotals .st_cart').html(totals_array[0]); $('ul.subtotals .st_discount').html(totals_array[2]); $('ul.subtotals .st_vat').html(totals_array[3]); $('.cart_total .st_total').html(totals_array[4]); $.ajax({ url: 'cont_cart_mini.php', type: "POST", data: 'ajax=1', success: function(response) { $('.outter_cart_mini_container').html(response); $('li#'+raw_id).remove(); } }); } }); }); // Update cart $('.cart_update').live('click', function(e) { e.preventDefault(); var click = $(this); var raw_id = $(this).parents('li').attr('id'); id = raw_id.substr(3); raw_id = raw_id.replace(/[;&,.+*~:!^$[\]()=>|\/]/g, "\\$&"); console.log(raw_id); var cart_name = $('li#'+raw_id+' input').attr('name'); var cart_val = $('li#'+raw_id+' input').val(); $('li#'+raw_id+' div.price_item').html(''); $('li#'+raw_id+' div.price_st').html(' '); $.ajax({ url: 'process_cart.php', type: "POST", data: cart_name + '=' + cart_val + '&cart_update=1&ajax=1', success: function(data) { totals_array = data.split('|'); var status = totals_array[0]; $('ul.subtotals .st_cart').html(totals_array[1]); $('ul.subtotals .st_discount').html(totals_array[3]); $('ul.subtotals .st_vat').html(totals_array[4]); $('.cart_total .st_total').html(totals_array[5]); var remove_array = totals_array[6].split('#'); var update_array = totals_array[7].split('#'); if (status == 'ok') { $.ajax({ url: 'cont_cart_mini.php', type: "POST", data: 'ajax=1', success: function(response) { $('.outter_cart_mini_container').html(response); $('li#'+raw_id+' div.price_item').html(update_array[0]); $('li#'+raw_id+' div.price_st').html(update_array[1]); if(totals_array[6] != '') { $('li#'+raw_id).remove(); } } }); } } }); }); /*************************** * * PRODUCT CONFIGURATIONS * ***************************/ $('.product_configurations select').change(function() { var price_mod = 0; var price_base = $('.prod_price').html(); // get all price mods selected $('.product_configurations select option:selected').each(function() { price_mod = parseFloat(price_mod) + parseFloat($(this).attr('rel')); }); price_return = parseFloat(price_mod) + parseFloat(price_base); $('.prod_price').hide(); $('.prod_price_conf').html(parseFloat(price_return).toFixed(2)); }); /*************************** * * HOME SWITCHER * ***************************/ $('#list_products_featured, #list_products_best').hide(); $('ul.home_switcher_tabs li a').live('click', function(e) { e.preventDefault(); var home_switcher = $(this).parents('ul.home_switcher_tabs'); var home_switcher_type = $(this).attr('id'); home_switcher_type = home_switcher_type.substr(10); //alert('#'+home_switcher_type+'#'); $('.home_product_container').hide(); $('#list_products_'+home_switcher_type).show(); $('ul.home_switcher_tabs li').removeClass('on'); $('ul.home_switcher_tabs li a#show_prod_'+home_switcher_type).parent('li').addClass('on'); }); /*************************** * * CAROUSEL * ***************************/ $('#feat_caro').carouFredSel({ prev: '#prev_caro', next: '#next_caro', pagination: false, auto: false }); $('#prod_thumbs_caro').carouFredSel({ prev: '#prev_caro', next: '#next_caro', pagination: false, auto: false }); /*************************** * * SUPER MENU * ***************************/ var $oe_menu = $('#oe_menu'); var $oe_menu_items = $oe_menu.children('li'); var $oe_overlay = $('#oe_overlay'); $oe_menu_items.hoverIntent( mouseenter_menu_items, mouseleave_menu_items ) $oe_menu.hoverIntent( mouseenter_menu, mouseleave_menu ) function mouseenter_menu_items () { var $this = $(this); $this.addClass('slided selected'); //$this.children('div').css('z-index','9999').stop(true,true).slideDown(200,function(){ $this.children('div').css('z-index','9999').stop(true,true).fadeIn(1,function(){ $oe_menu_items.not('.slided').children('div').hide(); $this.removeClass('slided'); }); }; function mouseleave_menu_items () { var $this = $(this); $this.removeClass('selected').children('div').css('z-index','9999'); }; function mouseenter_menu () { var $this = $(this); //$oe_overlay.stop(true,true).fadeTo(200, 0.6); $this.addClass('hovered'); }; function mouseleave_menu () { var $this = $(this); $this.removeClass('hovered'); //$oe_overlay.stop(true,true).fadeTo(200, 0); $oe_menu_items.children('div').hide(); }; }); var CaptchaCallback = function(){ var SITE_KEY = '6LeOrV8UAAAAAJI3Fxyu5Qd80CRiwB34MtuFN9o8'; // Get all form elements on page. var pageForms = $('form'); // Ensure the page has a form on it, at least. if(pageForms.length <= 0) { return; } pageForms.each(function(formIncId, form){ // Grab all of the 'submit' buttons which are attached to the form. var submissionButtons = $(form).find('input[type="submit"]:not(.captcha-ignore)'); if(submissionButtons.length <= 0){ return; // Return here is similar to 'continue' within a loop. } submissionButtons.each(function(btnIncId, button){ $(button).attr('data-sitekey', SITE_KEY); grecaptcha.render(button, { sitekey: SITE_KEY, callback: function(){ $(button).closest('form').submit(); } }); }); }); };