"use strict"; jQuery(document).ready(function ($) { // Modal Images $('.fancy-img').fancybox({ padding: 0, helpers: { overlay: { locked: false }, thumbs: { width: 60, height: 60 } } }); // Product Related if ($('#prod-related-car-top').length > 0) { $('#prod-related-car-top').flexslider({ animation: "slide", controlNav: true, slideshow: false, selector: '.slides > li', }); } if ($('#prod-related-car').length > 0) { $('#prod-related-car').flexslider({ animation: "slide", controlNav: true, slideshow: false, selector: '.slides > li', }); } if ($('#prod-related-car2').length > 0) { $('#prod-related-car2').flexslider({ animation: "slide", controlNav: true, slideshow: false, selector: '.slides > li', }); } // Catalog Images Carousel if (jQuery('.prod-i-img.prod-i-carousel:not(.brazzers-daddy)').length > 0) { jQuery(".prod-i-img.prod-i-carousel:not(.brazzers-daddy)").brazzersCarousel(); } // Sticky sidebar Catalog if ($('#section-sticky-sb').length > 0 && $('#section-sticky-cont').length > 0) { $('#section-sticky-sb, #section-sticky-cont').theiaStickySidebar({ additionalMarginTop: 30 }); } // Sticky sidebar Blog if ($('#blog-sticky-sb').length > 0 && $('#blog-sticky-cont').length > 0) { $('#blog-sticky-sb, #blog-sticky-cont').theiaStickySidebar({ additionalMarginTop: 30 }); } // Product quantity for List view mode $('body').on('click', '.prod-qnt a', function () { var qnt_btn = $(this); var qnt_wrap = qnt_btn.parents('.prod-qnt'); var qnt_input = qnt_wrap.find('input'); var qnt = qnt_input.val(); if (qnt_btn.data('qnt') == 'minus' && qnt > 1) { qnt--; } else if (qnt_btn.data('qnt') == 'plus') { qnt++; } qnt_input.val(qnt); qnt_input.trigger('change'); return false; }); // Single Product Tabs $('body').on('click', '.prod-tabs li a', function () { if ($(this).hasClass('active') || $(this).attr('data-prodtab') == '') return false; $(this).parents('.prod-tabs').find('li a').removeClass('active'); $(this).addClass('active'); // mobile $('.prod-tab-mob[data-prodtab-num=' + $(this).data('prodtab-num') + ']').parents('.prod-tab-cont').find('.prod-tab-mob').removeClass('active'); $('.prod-tab-mob[data-prodtab-num=' + $(this).data('prodtab-num') + ']').addClass('active'); $($(this).attr('data-prodtab')).parents('.prod-tab-cont').find('.prod-tab').css('height', '0px'); $($(this).attr('data-prodtab')).css('height', 'auto'); return false; }); // Single Product Tabs (mobile) $('body').on('click', '.prod-tab-cont .prod-tab-mob', function () { if ($(this).hasClass('active') || $(this).attr('data-prodtab') == '') return false; $(this).parents('.prod-tab-cont').find('.prod-tab-mob').removeClass('active'); $(this).addClass('active'); // main $('.prod-tabs li a[data-prodtab-num=' + $(this).data('prodtab-num') + ']').parents('.prod-tabs').find('li a').removeClass('active'); $('.prod-tabs li a[data-prodtab-num=' + $(this).data('prodtab-num') + ']').addClass('active'); $($(this).attr('data-prodtab')).parents('.prod-tab-cont').find('.prod-tab').css('height', '0px'); $($(this).attr('data-prodtab')).css('height', 'auto').hide().fadeIn(); return false; }); // "All Features" button $('.prod-showprops').on('click', function () { if ($('.prod-tabs li a.active').attr('data-prodtab') == '#prod-tab-additional_information') { $('html, body').animate({scrollTop: ($('.prod-tabs-wrap').offset().top - 10)}, 700); } else { $('.prod-tabs li a').removeClass('active'); $('.additional_information_tab a').addClass('active'); $('.prod-tab-cont .prod-tab').css('height', '0px'); $('#prod-tab-additional_information').css('height', 'auto'); $('html, body').animate({scrollTop: ($('.prod-tabs-wrap').offset().top - 10)}, 700); } return false; }); // Sidebar Categories $('#section-sb-toggle').on('click', function () { $('#section-sb-list').slideToggle(); if ($(this).hasClass('opened')) $(this).removeClass("opened"); else $(this).addClass('opened'); return false; }); $("#section-sb-list li.has_child").on("click", ".section-sb-toggle", function () { $(this).parent().next("ul").slideToggle(); if ($(this).hasClass('opened')) $(this).removeClass("opened"); else $(this).addClass('opened'); return false; }); // Product Offers (select type) $('body').on('click', '.offer-props-select p', function () { if ($(this).parent().hasClass('opened')) $(this).parent().removeClass('opened'); else $(this).parent().addClass('opened'); return false; }); $('body').on('click', '.offer-props-select li', function () { if ($(this).parent().parent().hasClass('opened')) $(this).parent().parent().removeClass('opened'); else $(this).parent().parent().addClass('opened'); }); $('body').on('click', '.offer-props-select li', function () { $(this).parent().parent().find('p').html($(this).text()); }); // Topmenu $('.topmenu').on('click', '.mainmenu-btn', function () { if ($('body').hasClass('mainmenu-show')) { $('body').removeClass('mainmenu-show'); } else { $('body').addClass('mainmenu-show'); } return false; }); $('html').on('click', 'body.mainmenu-show', function () { $('body').removeClass('mainmenu-show'); }); $('body').on('click', '.mainmenu', function(event){ event.stopPropagation(); }); // Topmenu (mobile) if ($(window).width() < 751) { $('.topmenu .mainmenu li a .fa').on('click', function () { if ($(this).parent().next('.sub-menu').hasClass('opened')) { $(this).parent().next('.sub-menu').removeClass('opened'); $(this).parent().next('.sub-menu').slideUp(); } else { $(this).parent().next('.sub-menu').addClass('opened'); $(this).parent().next('.sub-menu').slideDown(); } return false; }); $('.topcatalog').on('click', '.topcatalog-btn', function () { if ($('body').hasClass('topcatalog-show')) { $('body').removeClass('topcatalog-show'); } else { $('body').addClass('topcatalog-show'); } return false; }); $('html').on('click', 'body.topcatalog-show', function () { $('body').removeClass('topcatalog-show'); }); $('body').on('click', '.topcatalog-list', function(event){ event.stopPropagation(); }); $('.topcatalog li .fa').on('click', function () { if ($(this).next('ul').hasClass('opened')) { $(this).next('ul').removeClass('opened'); $(this).next('ul').slideUp(); } else { $(this).next('ul').addClass('opened'); $(this).next('ul').slideDown(); } return false; }); } // Search Button $('.topsearch').on('click', '#topsearch-btn', function () { if ($('body').hasClass('search-show')) { $('body').removeClass('search-show'); } else { $('body').addClass('search-show'); } return false; }); // Search Close $('body.search-show').on('click', '#topsearch-btn', function () { if ($('body').hasClass('search-show')) { $('body').removeClass('search-show'); } return false; }); $('html').on('click', 'body.search-show', function () { $('body').removeClass('search-show'); }); $('body').on('click', '.topsearch', function(event){ event.stopPropagation(); }); // Reviews "Show Answer" button if ($('.reviews-i-showanswer').length > 0) { $('.reviews-i-showanswer').on('click', function () { if ($(this).hasClass('opened')) { $(this).removeClass('opened').find('span').text($(this).find('span').data('open')); $(this).parents('.reviews-i').find('.reviews-i-answer').slideUp(); } else { $(this).addClass('opened').find('span').text($(this).find('span').data('close')); $(this).parents('.reviews-i').find('.reviews-i-answer').slideDown(); } return false; }); } // Catalog Gallery - Show Properties on hover if ($('.prod-i-action .prod-i-properties-label').length > 0) { $('.prod-i-action .prod-i-properties-label').on({ mouseenter: function () { $(this).parents('.prod-i').find('.prod-i-properties').addClass('show'); return false; }, mouseleave: function () { $(this).parents('.prod-i').find('.prod-i-properties').removeClass('show'); return false; } }); } }); // WooCommerce Ajax Cart jQuery(document).ready(function($){ var wacChange = function(element) { var form = element.closest('form'); // emulates button Update cart click $("").appendTo(form); // plugin flag $("").appendTo(form); var el_qty = element; var matches = element.attr('name').match(/cart\[(\w+)\]/); var cart_item_key = matches[1]; form.append( $("").val(cart_item_key) ); // ask user if they really want to remove this product if ( !wacZeroQuantityCheck(el_qty) ) { return false; } // when qty is set to zero, then fires default woocommerce remove link if ( el_qty.val() == 0 ) { var removeLink = element.closest('.cart_item').find('.product-remove a'); removeLink.click(); return false; } // get the form data before disable button... var formData = form.serialize(); $("input[name='update_cart']").val('Updating…').prop('disabled', true); $("a.checkout-button.wc-forward").addClass('disabled').html('Updating…'); $.post( form.attr('action'), formData, function(resp) { // ajax response $('.cart-collaterals').html(resp.html); el_qty.closest('.cart_item').find('.product-subtotal').html(resp.price); $('#update_cart').remove(); $('#is_wac_ajax').remove(); $('#cart_item_key').remove(); $("input[name='update_cart']").val(resp.update_label).prop('disabled', false); $("a.checkout-button.wc-forward").removeClass('disabled').html(resp.checkout_label); // when changes to 0, remove the product from cart if ( el_qty.val() == 0 ) { el_qty.closest('tr.cart_item').remove(); } // fix to update "Your order" totals when cart is inside Checkout page (thanks @vritzka) if ( $( '.woocommerce-checkout' ).length ) { $( document.body ).trigger( 'update_checkout' ); } $( document.body ).trigger( 'updated_cart_totals' ); }, 'json'); return true; }; // overrided by wac-js-calls.php var wacZeroQuantityCheck = function(el_qty) { if ( el_qty.val() == 0 ) { return false; } return true; }; var wacListenChange = function() { $(document).on('change','.cart-quantity .qty', {} ,function(e){ return wacChange( $(this) ); }); }; var wacQtyButtons = function() { $(document).on('click','.wac-btn-inc', {} ,function(e){ var inputQty = $(this).parent().parent().parent().find('.qty'); inputQty.val( function(i, oldval) { return ++oldval; }); inputQty.change(); return false; }); $(document).on('click','.wac-btn-sub', {} ,function(e){ var inputQty = $(this).parent().parent().parent().find('.qty'); inputQty.val( function(i, oldval) { return oldval > 0 ? --oldval : 0; }); inputQty.change(); return false; }); }; // start calls wacListenChange(); wacQtyButtons(); }); (function($) { jQuery(window).load(function(){ // Select Styles if ($('.section-sb:not(.WOOF_Widget) select').length > 0) { $('.section-sb:not(.WOOF_Widget) select').chosen({ disable_search_threshold: 10 }); } if ($('.prod-cont select').length > 0) { $('.prod-cont select').chosen({ disable_search_threshold: 10 }); } if ($('.section-sortby select.orderby').length > 0) { $('.section-sortby select.orderby').chosen({ disable_search_threshold: 10 }); } // Product Images Slider if ($('.prod-slider-car').length > 0) { $('.prod-slider-car').each(function () { $(this).bxSlider({ pagerCustom: $(this).parents('.prod-slider-wrap').find('.prod-thumbs-car'), adaptiveHeight: true, infiniteLoop: false, }); $(this).parents('.prod-slider-wrap').find('.prod-thumbs-car').bxSlider({ slideWidth: 5000, slideMargin: 8, moveSlides: 1, infiniteLoop: false, minSlides: 5, maxSlides: 5, pager: false, }); }); } }); })(jQuery); /* Woocommerce Add to cart Ajax for variable products http://www.rcreators.com/woocommerce-ajax-add-to-cart-variable-products Ajax based add to cart for varialbe products in woocommerce. Rishi Mehta - Rcreators Websolutions http://rcreators.com */ jQuery( function( $ ) { // wc_add_to_cart_params is required to continue, ensure the object exists if ( typeof wc_add_to_cart_params === 'undefined' ) return false; // Ajax add to cart $( document ).on( 'click', '.variations_form .single_add_to_cart_button', function(e) { e.preventDefault(); var $variation_form = $( this ).closest( '.variations_form' ); var var_id = $variation_form.find( 'input[name=variation_id]' ).val(); var product_id = $variation_form.find( 'input[name=product_id]' ).val(); var quantity = $variation_form.find( 'input[name=quantity]' ).val(); //attributes = []; $( '.ajaxerrors' ).remove(); var item = {}, check = true; var variations = $variation_form.find( 'select[name^=attribute]' ); /* Updated code to work with radio button - mantish - WC Variations Radio Buttons - 8manos */ if ( !variations.length) { variations = $variation_form.find( '[name^=attribute]:checked' ); } /* Backup Code for getting input variable */ if ( !variations.length) { variations = $variation_form.find( 'input[name^=attribute]' ); } variations.each( function() { var $this = $( this ), attributeName = $this.attr( 'name' ), attributevalue = $this.val(), index, attributeTaxName; $this.removeClass( 'error' ); if ( attributevalue.length === 0 ) { index = attributeName.lastIndexOf( '_' ); attributeTaxName = attributeName.substring( index + 1 ); $this .addClass( 'required error' ) .before( '
Please select ' + attributeTaxName + '