$(function(){
$('body').on('click','.moreRatingsBtn',function(){
var moreRatings = $(this).parent().parent().find('.moreRatingsWrap');
var moreRatingsToggle = $(this);
if(moreRatings.is(':visible')){
moreRatingsToggle.html(` More Ratings `);
moreRatings.slideUp('fast',resize);
}
else
{
moreRatings.slideDown('fast',resize);
moreRatingsToggle.html(` Less Ratings `);
}
});
$('body').on('click','.moreAnswersBtn',function(){
var moreAnswers = $(this).parent().parent().find('.moreAnswersWrap');
var moreAnswersToggle = $(this);
if(moreAnswers.is(':visible')){
moreAnswersToggle.html(` More Answers `);
moreAnswers.slideUp('fast',resize);
}
else
{
moreAnswers.slideDown('fast',resize);
moreAnswersToggle.html(` Less Answers `);
}
});
$('body').on('click','.showDetailsBtn',function(){
var moreSubRatings = $(this).parent().parent().find('.reviewSubratings');
var moreSubRatingsToggle = $(this);
if(moreSubRatings.is(':visible')){
moreSubRatingsToggle.html(`Show More`);
moreSubRatings.slideUp('fast',resize);
}
else
{
moreSubRatings.slideDown('fast',resize);
moreSubRatingsToggle.html(`Show Less`);
}
});
$('body').on('click','.prodQaTab',function(){
$('.prodReviewsTab').removeClass('active');
$('.prodQaTab').addClass('active');
$('.prodReviewsSection').removeClass('active');
$('.prodQaSection').addClass('active');
resize();
});
$('body').on('click','.prodReviewsTab',function(){
$('.prodReviewsTab').addClass('active');
$('.prodReviewsSection').addClass('active');
$('.prodQaTab').removeClass('active');
$('.prodQaSection').removeClass('active');
resize();
});
});
function resize(){
var height = $(".prodRevWidget").outerHeight();
var modalHeight = $(".modalWrap").outerHeight();
if(modalHeight > height){
height = modalHeight;
}
window.parent.postMessage(JSON.stringify({
action: 'product-resize',
elementId: elementId, // prevent conflicting widgets
height: height
}),'*');
}
function scrollTop(){
window.parent.postMessage(JSON.stringify({
action: 'product-scroll',
elementId: elementId // prevent conflicting widgets
}),'*');
}
window.onresize = function(event){
resize();
}