jQuery( function( $ ) { "use strict"; $( 'body' ) // Tabs .on( 'init', '.azeroth-tabs-wrapper, .azeroth-tabs', function() { $( '.azeroth-tab, .azeroth-tabs .panel:not(.panel .panel)' ).hide(); var hash = window.location.hash; var url = window.location.href; var $tabs = $( this ).find( '.azeroth-tabs, ul.tabs' ).first(); if ( hash.toLowerCase().indexOf( 'comment-' ) >= 0 || hash === '#reviews' || hash === '#tab-reviews' ) { $tabs.find( 'li.reviews_tab a' ).click(); } else if ( url.indexOf( 'comment-page-' ) > 0 || url.indexOf( 'cpage=' ) > 0 ) { $tabs.find( 'li.reviews_tab a' ).click(); } else if ( hash === '#tab-additional_information' ) { $tabs.find( 'li.additional_information_tab a' ).click(); } else { $tabs.find( 'li:first a' ).click(); } } ) .on( 'click', '.azeroth-tabs li a, ul.tabs li a', function( e ) { e.preventDefault(); var $tab = $( this ); var $tabs_wrapper = $tab.closest( '.azeroth-tabs-wrapper, .azeroth-tabs' ); var $tabs = $tabs_wrapper.find( '.azeroth-tabs, ul.tabs' ); $tabs.find( 'li' ).removeClass( 'active' ); $tabs_wrapper.find( '.azeroth-tab, .panel:not(.panel .panel)' ).hide(); $tab.closest( 'li' ).addClass( 'active' ); $tabs_wrapper.find( $tab.attr( 'href' ) ).show(); } ) // Review link .on( 'click', 'a.azeroth-review-link', function() { $( '.reviews_tab a' ).click(); return true; } ) // Init Tabs and Star Ratings $( '.azeroth-tabs-wrapper, .azeroth-tabs' ).trigger( 'init' ); if ($('.flex-control-nav, .azeroth-product-gallery__wrapper').length > 0) { $('.azeroth-product-gallery__wrapper').slick({ slidesToShow: 1, slidesToScroll: 1, arrows: false, draggable: false, fade: true, asNavFor: '.flex-control-nav' }); $('.flex-control-nav').slick({ vertical: true, slidesToShow: 3, slidesToScroll: 1, asNavFor: '.azeroth-product-gallery__wrapper', dots: false, arrows: true, prevArrow: '', nextArrow: '', focusOnSelect: true, slidesMargin: 14, responsive: [ { breakpoint: 991, settings: { vertical: false, slidesToShow: 3, prevArrow: '', nextArrow: '', } } ] }); } function star_rating() { $(document).on( 'click', '.comment-form-rating p.stars a', function() { var $star = $( this ), $rating = $( this ).closest( '#star-rating' ).find( '#rating' ), $container = $( this ).closest( '.stars' ); $rating.val( $star.text() ); $star.siblings( 'a' ).removeClass( 'active' ); $star.addClass( 'active' ); $container.addClass( 'selected' ); return false; } ) } $(document).ready(function () { star_rating(); $('.azeroth-product-gallery .azeroth-product-gallery__image').zoom(); }); } );