jQuery( document ).ready( function( $ ) { "use strict"; /* Scroll to top */ $('.brnhmbx-up-button').click( function() { $('html, body').animate( { scrollTop: 0 }, 500 ); return false; } ); /* */ /* Attach Owl to Product Images */ var sync1 = $("#p-preview"); var sync2 = $("#p-thumb"); sync1.owlCarousel({ singleItem: true, slideSpeed: 300, rewindSpeed: 400, navigation: true, navigationText: [ "
", "
" ], pagination: false, afterAction: syncPosition, responsiveRefreshRate: 100, }); sync2.owlCarousel({ items: 5, itemsDesktop: [1199, 5], itemsDesktopSmall: [979, 4], itemsTablet: [768, 3], itemsMobile: [479, 2], pagination: false, navigation: false, responsiveRefreshRate: 100, afterInit: function (el) { el.find(".owl-item").eq(0).addClass("synced"); } }); function syncPosition(el) { var current = this.currentItem; $("#p-thumb").find(".owl-item").removeClass("synced").eq(current).addClass("synced"); if ($("#p-thumb").data("owlCarousel") !== undefined) { center(current); } } $("#p-thumb").on("click", ".owl-item", function (e) { e.preventDefault(); var number = $(this).data("owlItem"); sync1.trigger("owl.goTo", number); }); $(".variations_form").on("change", ".variations select", function (e) { e.preventDefault(); var number = $(this).data("owlItem"); sync1.trigger("owl.goTo", 0); }); function center(number) { var sync2visible = sync2.data("owlCarousel").owl.visibleItems; var num = number; var found = false; for (var i in sync2visible) { if (num === sync2visible[i]) { var found = true; } } if (found === false) { if (num > sync2visible[sync2visible.length - 1]) { sync2.trigger("owl.goTo", num - sync2visible.length + 2); } else { if (num - 1 === -1) { num = 0; } sync2.trigger("owl.goTo", num); } } else if (num === sync2visible[sync2visible.length - 1]) { sync2.trigger("owl.goTo", sync2visible[1]); } else if (num === sync2visible[0]) { sync2.trigger("owl.goTo", num - 1); } } /* */ /* Input Spinner */ $( 'body' ) .on( 'click', '.brnhmbx-spinner-buttons a.up', function() { var contentObj = $(this).parent().parent().next('.quantity').find('.brnhmbx-spinner'); var value = parseInt( contentObj.val() ); value ++; contentObj.val(value); } ) .on( 'click', '.brnhmbx-spinner-buttons a.down', function() { var contentObj = $(this).parent().parent().next('.quantity').find('.brnhmbx-spinner'); var value = parseInt( contentObj.val() ); if ( value >= 1 ) { value --; } contentObj.val(value); } ); /* */ // Fitvids $('.bxslider-vid').fitVids(); // Added to avoid iframe confuse on Chrome, Safari and Opera $('iframe').each( function() { this.src = this.src; } ); /* Owl Carousel */ // Attach Wrapper var brnhmbx_wrapItOwl = '
'; $( '.related.products' ).find( 'ul.products' ).wrapInner( brnhmbx_wrapItOwl ); $( '.cross-sells' ).find( 'ul.products' ).wrapInner( brnhmbx_wrapItOwl ); $( '.upsells.products' ).find( 'ul.products' ).wrapInner( brnhmbx_wrapItOwl ); $( '.brnhmbx-shortcode-owl.products' ).wrapInner( brnhmbx_wrapItOwl ); // With Sidebar or Inside a Page/Post $( '.cross-sells .brnhmbx-owl-holder, .brnhmbx-woo-sidebar .brnhmbx-owl-holder, .page-with-menu-right .brnhmbx-owl-holder, .brnhmbx-single-sidebar .brnhmbx-owl-holder' ).owlCarousel( { items: 3, itemsDesktop: [1199, 3], itemsDesktopSmall: [979, 2], itemsTablet: [730, 1], pagination: true, navigation: false } ); $( '.brnhmbx-owl-holder' ).owlCarousel( { items: 4, pagination: true, navigation: false } ); /* */ /* Product Hover */ if ( !Modernizr.touch ) { jQuery( 'ul.products li.pif-has-gallery' ).hover( function() { jQuery( this ).find( '.wp-post-image' ).removeClass( 'fadeInDown' ).addClass( 'animated fadeOutUp' ); jQuery( this ).find( '.secondary-image' ).removeClass( 'fadeOutUp' ).addClass( 'animated fadeInDown' ); jQuery( this ).find( '.brnhmbx-hover-group' ).removeClass( 'fadeOutUp' ).addClass( 'animated fadeInDown' ); }, function() { jQuery( this ).find( '.wp-post-image' ).removeClass( 'fadeOutUp' ).addClass( 'fadeInDown' ); jQuery( this ).find( '.secondary-image' ).removeClass( 'fadeInDown' ).addClass( 'fadeOutUp' ); jQuery( this ).find( '.brnhmbx-hover-group' ).removeClass( 'fadeInDown' ).addClass( 'fadeOutUp' ); }); jQuery( 'ul.products li.pif-no-gallery' ).hover( function() { jQuery( this ).find( '.brnhmbx-hover-group' ).removeClass( 'fadeOutUp' ).addClass( 'animated fadeInDown' ); }, function() { jQuery( this ).find( '.brnhmbx-hover-group' ).removeClass( 'fadeInDown' ).addClass( 'fadeOutUp' ); }); } /* */ /* Grid/List Toggle */ $( 'ul.products, nav.woocommerce-pagination' ).show(); if ( Modernizr.touch ) { $( 'ul.products li' ).find( '.brnhmbx-hover-group' ).hide(); } var intGrid; jQuery('#grid').click(function() { clearInterval( intGrid ); intGrid = setInterval( showHoverGroup, 300 ); } ); jQuery('#list').click(function() { clearInterval( intGrid ); $( 'ul.products li' ).find( '.brnhmbx-hover-group' ).hide(); intGrid = setInterval( function() { $( '.brnhmbx-summary-outer' ).show(); }, 300 ); } ); if ( $( '#cookieBo' ).text() == 'cookie-true' ) { if ( jQuery.cookie( 'gridcookie' ) == 'list' ) { clearInterval( intGrid ); $( 'ul.products.grid li, ul.products.list li' ).find( '.brnhmbx-hover-group' ).hide(); if ( !Modernizr.touch ) { $( '.brnhmbx-owl-holder li' ).find( '.brnhmbx-hover-group' ).show(); } if ( $( '#shopBo' ).text() == 'shop' ) { $( '.brnhmbx-summary-outer' ).show(); } } } function showHoverGroup() { clearInterval( intGrid ); if ( !Modernizr.touch ) { $( 'ul.products li' ).find( '.brnhmbx-hover-group' ).show(); $( 'ul.products li' ).find( '.brnhmbx-hover-group' ).css( 'opacity', 0 ); $( 'ul.products li' ).find( '.brnhmbx-hover-group' ).removeClass( 'fadeInDown fadeOutUp' ); } $( '.brnhmbx-summary-outer' ).hide(); } /* */ /* Add send icon to submit button */ $( '#respond input#submit' ).parent().append( '' ); /* */ /* Contact Form 7 Place Send Icon */ $( '.wpcf7-submit' ).parent().append( '' ); /* */ /* Star ratings for comments */ $( '#rating' ).hide().before( '
' ); /* Wrap Buttons */ $( '.bfm-form button.brnhmbx-button span' ).wrap( '
' ); $( '.bfm-form button.brnhmbx-button' ).append( '
' ); $( '.brnhmbx-hover-group button.single_add_to_cart_button.brnhmbx-button span' ).wrap( '
' ); $( '.brnhmbx-hover-group button.single_add_to_cart_button.brnhmbx-button' ).append( '' ); $( '.brnhmbx-hover-group-list button.single_add_to_cart_button.brnhmbx-button span' ).wrap( '
' ); $( '.brnhmbx-hover-group-list button.single_add_to_cart_button.brnhmbx-button' ).append( '' ); $( 'form.cart button.single_add_to_cart_button.brnhmbx-button span' ).wrap( '
' ); $( 'form.cart button.single_add_to_cart_button.brnhmbx-button' ).append( '' ); $( 'div.cart .brnhmbx-button.single_add_to_cart_button.b170.button.alt span' ).wrap( '
' ); $( 'div.cart .brnhmbx-button.single_add_to_cart_button.b170.button.alt' ).append( '' ); /* */ $( 'table.woocommerce-MyAccount-orders td.order-actions a' ).addClass( 'brnhmbx-button-style-2' ); $( 'body' ).on( 'click', '#respond .brnhmbx-ratings input', function() { var $star = $( this ), $rating = $( this ).closest( '#respond' ).find( '#rating' ); $rating.val( $star.val() ); } ); /* */ /* Top Cart & Search */ var cartOpenBO = true; var brnhmbx_cart_widget_container = $( '.site-top-container .widget-item.widget_shopping_cart' ); var searchOpenBO = true; var brnhmbx_top_search_container = $( '.top-search' ); // Cart Button if ( Modernizr.touch ) { $( 'a.brnhmbx-cart-button.brnhmbx-kuf' ).click( function( e ) { e.preventDefault(); $( '#site-menu, #mega-menu-primary' ).slicknav( 'close' ); if ( cartOpenBO ) { cartOpenBO = false; brnhmbx_cart_widget_container.css( 'display', 'none' ); } else { cartOpenBO = true; brnhmbx_cart_widget_container.css( 'display', 'block' ); } // searchOpenBO = false; brnhmbx_top_search_container.css( 'display', 'none' ); } ); } else { jQuery( 'a.brnhmbx-cart-button.brnhmbx-kuf' ).hover( function() { if ( $( window ).width() > 960 ) { cartOpenBO = true; brnhmbx_cart_widget_container.css( 'display', 'block' ); brnhmbx_top_search_container.css( 'display', 'none' ); searchOpenBO = false; } } ); } // Top Search Button if ( Modernizr.touch ) { $( '.brnhmbx-top-search-button' ).click( function() { $( '#site-menu, #mega-menu-primary' ).slicknav( 'close' ); if ( searchOpenBO ) { searchOpenBO = false; brnhmbx_top_search_container.css( 'display', 'none' ); } else { searchOpenBO = true; brnhmbx_top_search_container.css( 'display', 'block' ); } // brnhmbx_cart_widget_container.css( 'display', 'none' ); cartOpenBO = false; } ); } else { jQuery( '.brnhmbx-top-search-button' ).hover( function() { searchOpenBO = true; brnhmbx_top_search_container.css( 'display', 'block' ); brnhmbx_cart_widget_container.css( 'display', 'none' ); cartOpenBO = false; } ); } /* */ /* Menu Button */ $( '.brnhmbx-menu-button' ).click( function() { $( '#site-menu, #mega-menu-primary' ).slicknav( 'toggle' ); searchOpenBO = false; brnhmbx_top_search_container.css( 'display', 'none' ); searchOpenBO = false; brnhmbx_top_search_container.css( 'display', 'none' ); } ); /* */ /* Zoom */ var intZF; var zBO = false; if ( $( '#zBo' ).text() == 'zoom-true' ) { zBO = true; } $( '.brnhmbx-owl-nav-button, #p-thumb .owl-item' ).click( function() { clearInterval( intZF ); intZF = setInterval( zoomTrueAgain, 500 ); zBO = false; } ); function zoomTrueAgain() { clearInterval( intZF ); zBO = true; } var inGallery = false; $( "body" ).mousemove( function( event ) { /* */ if ( cartOpenBO ) { if ( event.pageX >= brnhmbx_cart_widget_container.position().left - 30 || event.pageX < brnhmbx_cart_widget_container.position().left - 70 - 268 || event.pageY >= brnhmbx_cart_widget_container.position().top + brnhmbx_cart_widget_container.height() + 70 || event.pageY < brnhmbx_cart_widget_container.position().top - 40 ) { brnhmbx_cart_widget_container.css( 'display', 'none' ); cartOpenBO = false; } } else { brnhmbx_cart_widget_container.css( 'display', 'none' ); cartOpenBO = false; } /* */ /* */ if ( searchOpenBO ) { if ( event.pageX >= brnhmbx_top_search_container.position().left + 150 || event.pageX < brnhmbx_top_search_container.position().left - 150 || event.pageY >= brnhmbx_top_search_container.position().top + brnhmbx_top_search_container.height() + 50 || event.pageY < brnhmbx_top_search_container.position().top - 40 ) { brnhmbx_top_search_container.css( 'display', 'none' ); searchOpenBO = false; } } else { brnhmbx_top_search_container.css( 'display', 'none' ); searchOpenBO = false; } /* */ /* */ if ( zBO ) { $( '.zoomContainer' ).show(); var gallery = $( '#p-preview' ); var newInGallery = mouseWithin( gallery, event.pageX, event.pageY ); if ( newInGallery && !inGallery ) { $( '.brnhmbx-zoomer' ).each( function( index ) { var elevateZoom = $( this ).data( 'elevateZoom' ); if ( typeof elevateZoom !== 'undefined' ) { elevateZoom.changeState( 'enable' ); } } ); } if ( inGallery && !newInGallery ) { $( '.brnhmbx-zoomer' ).each( function( index ) { var elevateZoom = $( this ).data( 'elevateZoom' ); if ( typeof elevateZoom !== 'undefined' ) { elevateZoom.changeState( 'disable' ); $( this ).removeData( 'elevateZoom' );//remove zoom instance from image $( '.zoomContainer' ).remove();// remove zoom container from DOM } }); } inGallery = newInGallery; } else { $( '.zoomContainer' ).hide(); } /* */ } ); function mouseWithin( bounds, x, y ) { var offset = bounds.offset(); var l = offset.left; var t = offset.top; var h = bounds.height(); var w = bounds.width(); var maxx = l + w; var maxy = t + h; return (y <= maxy && y >= t) && (x <= maxx && x >= l); }; if ( !Modernizr.touch ) { if ( $( '#enable_Magnifier' ).text() == '1' ) { $( '.brnhmbx-zoomer' ).hover( function() { var elevateZoom = $( this ).data( 'elevateZoom' ); if ( typeof elevateZoom === 'undefined' ) { $( this ).elevateZoom( { zoomType: "inner", cursor: "pointer", responsive: true, easing: true } ); } else { elevateZoom.changeState( 'enable' ); } } ); } } /* */ /* Magnific */ $( '.brnhmbx-do-zoom' ).magnificPopup( { type: 'image', overflowY: 'scroll', tClose: '', // Alt text on close gallery: { arrowMarkup: '', enabled: true, tPrev: '', // Alt text on left arrow tNext: '', // Alt text on right arrow tCounter: '%curr% / %total%' // Markup for "1 of 7" counter }, mainClass: 'mfp-with-zoom', // this class is for CSS animation below zoom: { duration: 300, // duration of the effect, in milliseconds easing: 'ease-in-out', // CSS transition easing function }, image: { verticalFit: false } } ); /* */ /* Hover group add to cart button */ var intATC; var intAdded; $( '.brnhmbx-hover-group .add_to_cart_button, .brnhmbx-hover-group-list .add_to_cart_button' ).click( function() { $( this ).css( 'cursor', 'none' ); $( this ).find( 'i.fa-plus' ).hide(); $( this ).find( 'i.fa-check' ).hide(); $( this ).find( 'i.fa-ban' ).show(); var cart_qty = $( 'a.brnhmbx-cart-button.brnhmbx-kuf .qty-wrapper' ).text(); $( 'a.brnhmbx-cart-button .qty-wrapper' ).html( Number( cart_qty ) + 1 ); clearInterval( intATC ); clearInterval( intAdded ); intATC = setInterval( checkHoverATC, 1 ); intAdded = setInterval( clearHoverATC, 4000 ); } ); function clearHoverATC() { clearInterval( intATC ); clearInterval( intAdded ); } function checkHoverATC() { $( '.brnhmbx-hover-group button.add_to_cart_button, .brnhmbx-hover-group-list button.add_to_cart_button' ).each( function( i, obj ) { if ( $( this ).hasClass( 'added' ) ) { $( this ).css( 'cursor', 'pointer' ); $( this ).find( 'i.fa-check' ).show(); $( this ).find( 'i.fa-ban' ).hide(); } } ); } /* */ /* Times icon for chosen widget a tags */ $( '.woocommerce .widget_layered_nav ul li.chosen a, .woocommerce .widget_layered_nav_filters ul li.chosen a' ).prepend( '' ); /* */ /* Price filter button text */ $( '.widget-item-inner .price_slider_amount button' ).empty().prepend( '
' + $( '.widget-item-inner .price_slider_amount .price_label' ).html() + '
' ); /* */ /* Add search icon */ $( '.widget_product_search .widget-item-inner' ).append( '
' ); $( '.widget_product_search .search-widget-s-icon' ).click( function() { window.location = $( '#siteUrl' ).html() + '/?s=' + $( this ).parent().find( '.search-field' ).val() + '&post_type=product'; } ); /* */ /* Custom Search box focus */ var brnhmbx_searchDefaultVal_custom = $( '#s_custom' ).val(); $( '.search-widget-input' ).focus( function() { if ( $(this).val() == brnhmbx_searchDefaultVal_custom ) { $(this).val(''); } } ); $( '.search-widget-input' ).focusout( function() { if ( $(this).val() == '' ) { $(this).val(brnhmbx_searchDefaultVal_custom); } } ); $( '.search-widget .search-widget-s-icon' ).click( function() { window.location = $( '#siteUrl' ).html() + '/?s=' + $(this).parent().find( '.search-widget-input' ).val(); } ); /* */ /* Top Search box focus */ var brnhmbx_topSearchDefaultVal_custom = $( '#s_top' ).val(); $( '.top-search-input' ).focus( function() { if ( $( this ).val() == brnhmbx_topSearchDefaultVal_custom ) { $( this ).val( '' ); } } ); $( '.top-search-input' ).focusout( function() { if ( $( this ).val() == '' ) { $( this ).val( brnhmbx_topSearchDefaultVal_custom ); } } ); $( '.top-search-input' ).keyup( function( event ) { if ( event.which == 13 ) { //ENTER window.location = $( '#siteUrl' ).html() + '/?s=' + $( this ).val() + '&post_type=product'; } } ); /* */ /* Apply Slicknav */ $( '#site-menu' ).slicknav( { label: '', prependTo: '#touch-menu', allowParentLinks: true, closedSymbol: '', openedSymbol: '' } ); $( '#mega-menu-primary' ).slicknav( { label: '', prependTo: '#touch-menu', allowParentLinks: true, closedSymbol: '', openedSymbol: '' } ); /* */ /* Add select icon to the items those include a select field */ $( '.widget-item-inner select' ).before( '
' ); $( '.mega-menu-item select' ).before( '
' ); /* */ /* Add
  • tag before & after blog & comments pagination items */ $( '.brnhmbx-comments-paginate-outer' ).wrapInner( '