external product review link not opening on load fixes #5008
This commit is contained in:
parent
6fcdccd73b
commit
76021004c1
|
@ -1,74 +1,73 @@
|
||||||
jQuery(function($) {
|
jQuery( function( $ ) {
|
||||||
|
|
||||||
// wc_single_product_params is required to continue, ensure the object exists
|
// wc_single_product_params is required to continue, ensure the object exists
|
||||||
if (typeof wc_single_product_params === "undefined")
|
if ( typeof wc_single_product_params === "undefined" )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Tabs
|
// Tabs
|
||||||
$('.woocommerce-tabs .panel').hide();
|
$( '.woocommerce-tabs .panel' ).hide();
|
||||||
|
|
||||||
$('.woocommerce-tabs ul.tabs li a').click(function(){
|
$( '.woocommerce-tabs ul.tabs li a' ).click( function() {
|
||||||
|
|
||||||
var $tab = $(this);
|
var $tab = $( this ),
|
||||||
var $tabs_wrapper = $tab.closest('.woocommerce-tabs');
|
$tabs_wrapper = $tab.closest( '.woocommerce-tabs' );
|
||||||
|
|
||||||
$('ul.tabs li', $tabs_wrapper).removeClass('active');
|
$( 'ul.tabs li', $tabs_wrapper ).removeClass( 'active' );
|
||||||
$('div.panel', $tabs_wrapper).hide();
|
$( 'div.panel', $tabs_wrapper ).hide();
|
||||||
$('div' + $tab.attr('href'), $tabs_wrapper).show();
|
$( 'div' + $tab.attr( 'href' ), $tabs_wrapper).show();
|
||||||
$tab.parent().addClass('active');
|
$tab.parent().addClass( 'active' );
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
$('.woocommerce-tabs').each(function() {
|
$( '.woocommerce-tabs' ).each( function() {
|
||||||
var hash = window.location.hash;
|
var hash = window.location.hash,
|
||||||
var url = window.location.href;
|
url = window.location.href,
|
||||||
|
tabs = $( this );
|
||||||
|
|
||||||
if (hash.toLowerCase().indexOf("comment-") >= 0) {
|
if ( hash.toLowerCase().indexOf( "comment-" ) >= 0 ) {
|
||||||
$('ul.tabs li.reviews_tab a', $(this)).click();
|
$('ul.tabs li.reviews_tab a', tabs ).click();
|
||||||
} else {
|
|
||||||
$('ul.tabs li:first a', $(this)).click();
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( url.indexOf("comment-page-") > 0 || url.indexOf("cpage=") > 0 ) {
|
} else if ( url.indexOf( "comment-page-" ) > 0 || url.indexOf( "cpage=" ) > 0 ) {
|
||||||
$( 'ul.tabs li.reviews_tab a', $( this ) ).click();
|
$( 'ul.tabs li.reviews_tab a', $( this ) ).click();
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
$( 'ul.tabs li:first a', $( this ) ).click();
|
$( 'ul.tabs li:first a', tabs ).click();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$('a.woocommerce-review-link').click(function() {
|
$( 'a.woocommerce-review-link' ).click( function() {
|
||||||
$('.reviews_tab a').click();
|
$( '.reviews_tab a' ).click();
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
|
|
||||||
// Star ratings for comments
|
// Star ratings for comments
|
||||||
$('#rating').hide().before('<p class="stars"><span><a class="star-1" href="#">1</a><a class="star-2" href="#">2</a><a class="star-3" href="#">3</a><a class="star-4" href="#">4</a><a class="star-5" href="#">5</a></span></p>');
|
$( '#rating' ).hide().before( '<p class="stars"><span><a class="star-1" href="#">1</a><a class="star-2" href="#">2</a><a class="star-3" href="#">3</a><a class="star-4" href="#">4</a><a class="star-5" href="#">5</a></span></p>' );
|
||||||
|
|
||||||
$('body')
|
$( 'body' )
|
||||||
.on( 'click', '#respond p.stars a', function(){
|
.on( 'click', '#respond p.stars a', function() {
|
||||||
var $star = $(this);
|
var $star = $( this ),
|
||||||
var $rating = $(this).closest('#respond').find('#rating');
|
$rating = $( this ).closest( '#respond' ).find( '#rating' );
|
||||||
|
|
||||||
$rating.val( $star.text() );
|
$rating.val( $star.text() );
|
||||||
$star.siblings('a').removeClass('active');
|
$star.siblings( 'a' ).removeClass( 'active' );
|
||||||
$star.addClass('active');
|
$star.addClass( 'active' );
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
})
|
})
|
||||||
.on( 'click', '#respond #submit', function(){
|
.on( 'click', '#respond #submit', function() {
|
||||||
var $rating = $(this).closest('#respond').find('#rating');
|
var $rating = $( this ).closest( '#respond' ).find( '#rating' ),
|
||||||
var rating = $rating.val();
|
rating = $rating.val();
|
||||||
|
|
||||||
|
if ( $rating.size() > 0 && ! rating && wc_single_product_params.review_rating_required === 'yes' ) {
|
||||||
|
alert( wc_single_product_params.i18n_required_rating_text );
|
||||||
|
|
||||||
if ( $rating.size() > 0 && ! rating && wc_single_product_params.review_rating_required == 'yes' ) {
|
|
||||||
alert(wc_single_product_params.i18n_required_rating_text);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// prevent double form submission
|
// prevent double form submission
|
||||||
$('form.cart').submit(function(){
|
$( 'form.cart' ).submit( function() {
|
||||||
$(this).find(':submit').attr( 'disabled','disabled' );
|
$( this ).find( ':submit' ).attr( 'disabled','disabled' );
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue