2014-03-01 20:10:25 +00:00
|
|
|
jQuery( function( $ ) {
|
2012-12-10 13:11:05 +00:00
|
|
|
|
2013-12-04 19:15:24 +00:00
|
|
|
// wc_single_product_params is required to continue, ensure the object exists
|
2014-03-19 22:56:07 +00:00
|
|
|
if ( typeof wc_single_product_params === 'undefined' ) {
|
2013-12-04 19:15:24 +00:00
|
|
|
return false;
|
2014-03-19 22:56:07 +00:00
|
|
|
}
|
2013-12-04 19:15:24 +00:00
|
|
|
|
2012-07-17 14:09:18 +00:00
|
|
|
// Tabs
|
2014-03-01 20:10:25 +00:00
|
|
|
$( '.woocommerce-tabs .panel' ).hide();
|
2012-12-10 13:11:05 +00:00
|
|
|
|
2014-03-01 20:10:25 +00:00
|
|
|
$( '.woocommerce-tabs ul.tabs li a' ).click( function() {
|
2012-12-10 13:11:05 +00:00
|
|
|
|
2014-03-01 20:10:25 +00:00
|
|
|
var $tab = $( this ),
|
|
|
|
$tabs_wrapper = $tab.closest( '.woocommerce-tabs' );
|
2012-12-10 13:11:05 +00:00
|
|
|
|
2014-03-01 20:10:25 +00:00
|
|
|
$( 'ul.tabs li', $tabs_wrapper ).removeClass( 'active' );
|
|
|
|
$( 'div.panel', $tabs_wrapper ).hide();
|
|
|
|
$( 'div' + $tab.attr( 'href' ), $tabs_wrapper).show();
|
|
|
|
$tab.parent().addClass( 'active' );
|
2012-12-10 13:11:05 +00:00
|
|
|
|
|
|
|
return false;
|
2012-07-17 14:09:18 +00:00
|
|
|
});
|
2012-12-10 13:11:05 +00:00
|
|
|
|
2014-03-01 20:10:25 +00:00
|
|
|
$( '.woocommerce-tabs' ).each( function() {
|
|
|
|
var hash = window.location.hash,
|
|
|
|
url = window.location.href,
|
|
|
|
tabs = $( this );
|
2014-02-05 12:40:15 +00:00
|
|
|
|
2014-10-24 14:50:15 +00:00
|
|
|
if ( hash.toLowerCase().indexOf( "comment-" ) >= 0 || hash == '#reviews' ) {
|
2014-03-01 20:10:25 +00:00
|
|
|
$('ul.tabs li.reviews_tab a', tabs ).click();
|
2014-02-05 12:40:15 +00:00
|
|
|
|
2014-03-01 20:10:25 +00:00
|
|
|
} else if ( url.indexOf( "comment-page-" ) > 0 || url.indexOf( "cpage=" ) > 0 ) {
|
2014-02-05 12:40:15 +00:00
|
|
|
$( 'ul.tabs li.reviews_tab a', $( this ) ).click();
|
2014-03-01 20:10:25 +00:00
|
|
|
|
2014-02-05 12:40:15 +00:00
|
|
|
} else {
|
2014-03-01 20:10:25 +00:00
|
|
|
$( 'ul.tabs li:first a', tabs ).click();
|
2014-02-05 12:40:15 +00:00
|
|
|
}
|
2012-07-17 14:09:18 +00:00
|
|
|
});
|
2012-12-10 13:11:05 +00:00
|
|
|
|
2014-03-01 20:10:25 +00:00
|
|
|
$( 'a.woocommerce-review-link' ).click( function() {
|
|
|
|
$( '.reviews_tab a' ).click();
|
2013-10-31 16:26:20 +00:00
|
|
|
return true;
|
|
|
|
});
|
|
|
|
|
2012-07-17 14:09:18 +00:00
|
|
|
// Star ratings for comments
|
2014-03-01 20:10:25 +00:00
|
|
|
$( '#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>' );
|
2012-12-10 13:11:05 +00:00
|
|
|
|
2014-03-01 20:10:25 +00:00
|
|
|
$( 'body' )
|
|
|
|
.on( 'click', '#respond p.stars a', function() {
|
|
|
|
var $star = $( this ),
|
|
|
|
$rating = $( this ).closest( '#respond' ).find( '#rating' );
|
2012-12-10 13:11:05 +00:00
|
|
|
|
2013-02-11 15:37:26 +00:00
|
|
|
$rating.val( $star.text() );
|
2014-03-01 20:10:25 +00:00
|
|
|
$star.siblings( 'a' ).removeClass( 'active' );
|
|
|
|
$star.addClass( 'active' );
|
2012-12-10 13:11:05 +00:00
|
|
|
|
2012-07-17 14:09:18 +00:00
|
|
|
return false;
|
2013-02-11 15:37:26 +00:00
|
|
|
})
|
2014-03-01 20:10:25 +00:00
|
|
|
.on( 'click', '#respond #submit', function() {
|
|
|
|
var $rating = $( this ).closest( '#respond' ).find( '#rating' ),
|
|
|
|
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 );
|
2013-02-11 15:37:26 +00:00
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
});
|
2012-12-10 13:11:05 +00:00
|
|
|
|
2012-10-17 11:21:50 +00:00
|
|
|
// prevent double form submission
|
2014-03-01 20:10:25 +00:00
|
|
|
$( 'form.cart' ).submit( function() {
|
|
|
|
$( this ).find( ':submit' ).attr( 'disabled','disabled' );
|
2012-10-17 11:21:50 +00:00
|
|
|
});
|
2013-10-03 18:23:50 +00:00
|
|
|
});
|