window.okeReviewsWidgetOnInit = function() {
var reviewsWidgetElement = document.querySelector('.js-okeReviews-reviewsWidget');
var reviewSummaryElement = document.querySelector('.js-okeReviews-reviewsSummary');
if (reviewsWidgetElement && reviewSummaryElement) {
reviewSummaryElement.addEventListener('click', function() {
// Find tab element with text 'Reviews'
var tabElements = document.querySelectorAll('.tablink');
var reviewTabElement = '';
tabElements.forEach(function(tab) {
console.log(tab.textContent);
if (tab.textContent == 'Product Reviews') {
reviewTabElement = tab;
}
});
reviewTabElement.click();
});
}
}
window.okeReviewsWidgetOnInit = function() {
var reviewsWidgetElement = document.querySelector('.js-okeReviews-reviewsWidget');
var reviewSummaryElement = document.querySelector('.js-okeReviews-reviewsSummary');
if (reviewsWidgetElement && reviewSummaryElement) {
reviewSummaryElement.addEventListener('click', function() {
// Find tab element with text 'Reviews'
var reviewTabToggleElement = $('.nav-tabs a:contains(\'Customer Reviews\')');
// If widget element is not visible
if (!reviewsWidgetElement.getBoundingClientRect().width) {
reviewTabToggleElement.click();
}
});
}
}
window.okeReviewsWidgetOnInit = function() {
var reviewSummaryElements = document.querySelectorAll('.js-okeReviews-reviewsSummary');
var reviewTabElement = document.querySelector('div[data-tab-header="reviews"]');
if (reviewTabElement && reviewSummaryElements.length) {
reviewSummaryElements.forEach(function(reviewSummaryElement) {
reviewSummaryElement.addEventListener('click', function() {
reviewTabElement.click();
});
});
}
}