(function(){
jQuery(document).ready(function($){
crResizeAllGridItems();
crResizeTrustBadges();
jQuery("form#commentform").attr("enctype", "multipart/form-data").attr("encoding", "multipart/form-data");
jQuery("#commentform").on("submit", function(event){
if(cr_ajax_object.ivole_recaptcha==='1'){
var recaptcha=jQuery("#g-recaptcha-response").val();
if(recaptcha===""){
event.preventDefault();
alert("Please confirm that you are not a robot");
}}
});
jQuery("ol.commentlist").on("click", ".cr-comment-a", function(t){
if(cr_ajax_object.disable_lightbox==='0'){
t.preventDefault();
const oo=jQuery(".pswp");
if(0 < oo.length){
const o=oo[0];
var pics=jQuery(this).parent().parent().find(".cr-comment-a img");
var this_pic=jQuery(this).find("img");
var inx=0;
if(pics.length > 0&&this_pic.length > 0){
var a=[];
for (i=0; i < pics.length; i++){
a.push({
src: pics[i].src,
w: pics[i].naturalWidth,
h: pics[i].naturalHeight,
title: pics[i].alt
});
if(this_pic[0].src==pics[i].src){
inx=i;
}}
var r={
index: inx
};
new PhotoSwipe(o, PhotoSwipeUI_Default, a, r).init();
}}
}});
jQuery(".cr-reviews-grid").on("click", ".image-row-vid, .cr-comment-videoicon", function(t){
if(! jQuery(this).closest(".image-row").hasClass("cr-vid-playing") ){
jQuery(this).closest(".image-row").addClass("cr-vid-playing");
jQuery(this).closest(".image-row").find(".image-row-vid").prop("controls", true);
jQuery(this).closest(".image-row").find(".image-row-vid").get(0).play();
}else{
jQuery(this).closest(".image-row").find(".image-row-vid").get(0).pause();
jQuery(this).closest(".image-row").find(".image-row-vid").prop("controls", false);
jQuery(this).closest(".image-row").removeClass("cr-vid-playing");
}
return false;
});
jQuery(".cr-ajax-reviews-cus-images-modal").on("click", ".cr-ajax-reviews-video, .cr-ajax-reviews-video .cr-comment-videoicon", function(t){
if(! jQuery(this).closest(".cr-ajax-reviews-video").hasClass("cr-vid-playing") ){
jQuery(this).closest(".cr-ajax-reviews-video").addClass("cr-vid-playing");
jQuery(this).closest(".cr-ajax-reviews-video").find("video").prop("controls", true);
jQuery(this).closest(".cr-ajax-reviews-video").find("video").get(0).play();
}else{
jQuery(this).closest(".cr-ajax-reviews-video").find("video").get(0).pause();
jQuery(this).closest(".cr-ajax-reviews-video").find("video").prop("controls", false);
jQuery(this).closest(".cr-ajax-reviews-video").removeClass("cr-vid-playing");
}
return false;
});
jQuery(".cr-reviews-grid").on("click", ".media-row-count", function(t){
if(cr_ajax_object.disable_lightbox==='0'){
t.preventDefault();
const oo=jQuery(".pswp");
let media=jQuery(this).parent().find(".image-row-vid,.image-row-img"),
this_media=jQuery(this),
inx=0;
if(media.length > 0&&this_media.length > 0){
const o=oo[0];
var a=[];
for (i=0; i < media.length; i++){
if("vid"===media[i].dataset.crmedia){
a.push({
html: '<div class="cr-video-wrapper"><video class="cr-media-video" src="' + media[i].src + '" controls></video></div>',
title: media[i].dataset.crtitle
});
}else{
a.push({
src: media[i].src,
w: media[i].naturalWidth,
h: media[i].naturalHeight,
title: media[i].alt
});
}
if(this_media[0].src==media[i].src){
inx=i;
}}
var r={
index: inx
};
new PhotoSwipe(o, PhotoSwipeUI_Default, a, r).init();
}}
});
jQuery(document).on("click", ".cr-video-wrapper .cr-media-video", function(t){
const vid=jQuery(this).get(0);
if(vid){
const isVideoPlaying = !!(vid.currentTime > 0&&!vid.paused&&!vid.ended&&vid.readyState > 2);
if(isVideoPlaying){
vid.pause();
}else{
vid.play();
}}
return false;
});
jQuery(".cr-reviews-grid").on("click", ".image-row-img, .image-row-count", function(t){
if(cr_ajax_object.disable_lightbox==='0'){
t.preventDefault();
const oo=jQuery(".pswp");
if(0 < oo.length){
const o=oo[0];
var pics=jQuery(this).parent().find("img.image-row-img");
var this_pic=jQuery(this);
var inx=0;
if(pics.length > 0&&this_pic.length > 0){
var a=[];
for (i=0; i < pics.length; i++){
a.push({
src: pics[i].src,
w: pics[i].naturalWidth,
h: pics[i].naturalHeight,
title: pics[i].alt
});
if(this_pic[0].src==pics[i].src){
inx=i;
}}
var r={
index: inx
};
new PhotoSwipe(o, PhotoSwipeUI_Default, a, r).init();
}}
}});
initVoteClick("ol.commentlist", ".cr-voting-a", "cr_vote_review");
initVoteClick(".cr-ajax-reviews-cus-images-modal", ".cr-voting-a", "cr_vote_review");
initVoteClick(".cr-qna-block .cr-qna-list-block", ".cr-voting-a", "cr_vote_question");
jQuery("ol.commentlist").on("click", ".cr-video-a, .cr-comment-videoicon", function(t){
if(! jQuery(this).closest(".cr-comment-videos").hasClass("cr-comment-videos-modal") ){
let tt=jQuery(this).closest("[class*='cr-comment-video-']");
jQuery(this).closest(".cr-comment-videos").addClass("cr-comment-videos-modal");
tt.addClass("cr-comment-video-modal");
tt.find("video").prop("controls", true);
tt.find(".cr-comment-videoicon").hide();
tt.find("video").get(0).play();
return false;
}
return false;
});
jQuery("ol.commentlist").on("click", ".cr-comment-videos", function(t){
if(jQuery(this).hasClass("cr-comment-videos-modal") ){
jQuery(this).removeClass("cr-comment-videos-modal");
jQuery(this).find("[class*='cr-comment-video-']").each(function(index, element){
if(jQuery(element).hasClass("cr-comment-video-modal") ){
jQuery(element).removeClass("cr-comment-video-modal");
jQuery(element).find("video").get(0).pause();
jQuery(element).find("video").prop("controls", false);
jQuery(element).find(".cr-comment-videoicon").show();
jQuery(element).removeAttr("style");
}});
return false;
}});
jQuery(".cr-show-more-reviews-prd").on("click", function(t){
t.preventDefault();
crShowMoreReviewsPrd(jQuery(this));
});
jQuery(".cr-ajax-reviews-sort").on("change", function(t){
t.preventDefault();
if(jQuery(this).parents(".cr-all-reviews-shortcode").length){
cr_filter_all_reviews(jQuery(this));
}else{
var cr_product_id=jQuery(this).parents(".cr-reviews-ajax-comments").find(".commentlist.cr-ajax-reviews-list").attr("data-product");
var cr_sort=jQuery(this).children("option:selected").val();
var cr_rating=jQuery(this).parents(".cr-reviews-ajax-comments").find(".cr-summaryBox-ajax tr.ivole-histogramRow.ivole-histogramRow-s .ivole-histogram-a").attr("data-rating");
if(!cr_rating){
cr_rating=0;
}
var cr_data={
"action": "cr_sort_reviews",
"productID": cr_product_id,
"sort": cr_sort,
"rating": cr_rating
};
jQuery(this).parents(".cr-reviews-ajax-comments").find(".cr-search-no-reviews").hide();
jQuery(this).parents(".cr-reviews-ajax-comments").find('.cr-ajax-search input').val("").trigger("change");
jQuery(this).parents(".cr-reviews-ajax-comments").find(".cr-show-more-reviews-prd").hide();
jQuery(this).parents(".cr-reviews-ajax-comments").find(".commentlist.cr-ajax-reviews-list").hide();
jQuery(this).parents(".cr-reviews-ajax-comments").find(".cr-show-more-review-spinner").show();
jQuery(this).parents(".cr-reviews-ajax-comments").find(".cr-summaryBox-ajax").addClass("cr-summaryBar-updating");
jQuery(this).addClass("cr-sort-updating");
jQuery.post({
url: cr_ajax_object.ajax_url,
data: cr_data,
context: this,
success: function(response){
jQuery(this).parents(".cr-reviews-ajax-comments").find(".cr-show-more-review-spinner").hide();
jQuery(this).parents(".cr-reviews-ajax-comments").find(".cr-summaryBox-ajax").removeClass("cr-summaryBar-updating");
jQuery(this).removeClass("cr-sort-updating");
if(response.page > 0){
jQuery(this).parents(".cr-reviews-ajax-comments").find(".commentlist.cr-ajax-reviews-list").empty();
jQuery(this).parents(".cr-reviews-ajax-comments").find(".commentlist.cr-ajax-reviews-list").append(response.html);
jQuery(this).parents(".cr-reviews-ajax-comments").find(".commentlist.cr-ajax-reviews-list").show();
jQuery(this).parents(".cr-reviews-ajax-comments").attr("data-page",response.page);
if(response.show_more_label){
jQuery(this).parents(".cr-reviews-ajax-comments").find(".cr-show-more-reviews-prd").text(response.show_more_label);
}
if(response.count_row){
jQuery(this).parents(".cr-reviews-ajax-comments").find(".cr-count-row .cr-count-row-count").html(response.count_row);
}
if(!response.last_page){
jQuery(this).parents(".cr-reviews-ajax-comments").find(".cr-show-more-reviews-prd").show();
}}
},
dataType: "json"
});
}});
jQuery(".cr-noAjax").on("click", ".ivole-histogram-a", function (t){
t.preventDefault();
const parser=new URL(window.location);
parser.searchParams.set(cr_ajax_object.rating_filter, jQuery(this).data("rating"));
parser.hash=cr_ajax_object.reviews_tab;
window.location=parser.href;
});
jQuery(".cr-reviews-ajax-comments").on("click", ".ivole-histogram-a, .cr-seeAllReviews", function(t){
t.preventDefault();
let tmpParent=jQuery(this).parents(".cr-reviews-ajax-comments");
let cr_product_id=tmpParent.find(".commentlist.cr-ajax-reviews-list").attr("data-product");
let cr_nonce=tmpParent.find(".cr-summaryBox-ajax").attr("data-nonce");
let cr_rating=jQuery(this).attr("data-rating");
let cr_sort=tmpParent.find(".cr-ajax-reviews-sort").children("option:selected").val();
let cr_data={
"action": "cr_filter_reviews",
"productID": cr_product_id,
"rating": cr_rating,
"sort": cr_sort,
"security": cr_nonce
};
tmpParent.find(".cr-summaryBox-ajax tr.ivole-histogramRow.ivole-histogramRow-s").removeClass("ivole-histogramRow-s");
if(cr_rating > 0){
jQuery(this).closest("tr.ivole-histogramRow").addClass("ivole-histogramRow-s");
}
tmpParent.find(".cr-search-no-reviews").hide();
tmpParent.find('.cr-ajax-search input').val("").trigger("change");
tmpParent.find(".cr-show-more-reviews-prd").hide();
tmpParent.find(".commentlist.cr-ajax-reviews-list").hide();
tmpParent.find(".cr-show-more-review-spinner").show();
tmpParent.find(".cr-summaryBox-ajax").addClass("cr-summaryBar-updating");
tmpParent.find(".cr-ajax-reviews-sort").addClass("cr-sort-updating");
jQuery.post({
url: cr_ajax_object.ajax_url,
data: cr_data,
context: tmpParent,
success: function(response){
this.find(".cr-show-more-review-spinner").hide();
this.find(".cr-summaryBox-ajax").removeClass("cr-summaryBar-updating");
this.find(".cr-ajax-reviews-sort").removeClass("cr-sort-updating");
if(response.page > 0){
this.find(".commentlist.cr-ajax-reviews-list").empty();
this.find(".commentlist.cr-ajax-reviews-list").append(response.html);
this.find(".commentlist.cr-ajax-reviews-list").show();
this.attr("data-page",response.page);
if(response.show_more_label){
this.find(".cr-show-more-reviews-prd").text(response.show_more_label);
}
if(response.count_row){
this.find(".cr-count-row .cr-count-row-count").html(response.count_row);
}
if(!response.last_page){
this.find(".cr-show-more-reviews-prd").show();
}}
},
dataType: "json"
});
});
jQuery('.cr-ajax-search input').on("keyup", function(e){
if(e.keyCode==13){
jQuery(this).parents(".cr-ajax-search").find("button").trigger("click");
}
if(jQuery(this).val()!==""){
jQuery(this).parents(".cr-ajax-search").find(".cr-clear-input").css("display", "inline-block");
}else{
jQuery(this).parents(".cr-ajax-search").find(".cr-clear-input").css("display", "none");
}}).on("change", function(){
if(jQuery(this).val()==="") jQuery(this).parents(".cr-ajax-search").find(".cr-clear-input").hide();
});
jQuery('.cr-reviews-ajax-reviews .cr-ajax-search input').on('keyup', crDebounce(
(ref)=> {
jQuery(ref.target).parents(".cr-reviews-ajax-comments").attr("data-page", 0);
jQuery(ref.target).parents(".cr-reviews-ajax-reviews").find(".cr-ajax-reviews-list").empty();
crShowMoreReviewsPrd(jQuery(ref.target));
},
1000
));
jQuery(".cr-ajax-search .cr-clear-input").on("click", function (){
jQuery(this).prev("input").val("");
jQuery(this).parents(".cr-ajax-search").find(".cr-clear-input").hide();
jQuery(this).parents(".cr-ajax-search").find("button").trigger("click");
if(jQuery(this).parents(".cr-reviews-ajax-reviews").length){
jQuery(this).parents(".cr-reviews-ajax-comments").attr("data-page", 0);
jQuery(this).parents(".cr-reviews-ajax-reviews").find(".cr-ajax-reviews-list").empty();
crShowMoreReviewsPrd(jQuery(this));
}});
jQuery(".cr-ajax-search button").on("click", function (e){
e.preventDefault();
if(jQuery(this).parents(".cr-all-reviews-shortcode").length){
cr_filter_all_reviews(jQuery(this));
}else{
jQuery(this).parents(".cr-reviews-ajax-comments").attr("data-page", 0);
jQuery(this).parents(".cr-reviews-ajax-comments").find(".cr-ajax-reviews-list").empty();
crShowMoreReviewsPrd(jQuery(this));
}});
jQuery(".cr-ajax-reviews-add-review, .cr-nosummary-add").on("click", function(t){
t.preventDefault();
jQuery(this).closest(".cr-reviews-ajax-reviews").find(".cr-reviews-ajax-comments").hide();
jQuery(this).closest(".cr-reviews-ajax-reviews").find(".cr-ajax-reviews-review-form").show();
});
jQuery(".cr-review-tags-filter span.cr-tags-filter").on("click", function (e){
e.preventDefault();
if(jQuery(this).hasClass("cr-tag-selected")){
jQuery(this).removeClass("cr-tag-selected");
}else{
jQuery(this).addClass("cr-tag-selected");
}
if(jQuery(this).parents(".cr-all-reviews-shortcode").length){
cr_filter_all_reviews(jQuery(this));
}else{
jQuery(this).parents(".cr-reviews-ajax-comments").attr("data-page", 0);
jQuery(this).parents(".cr-reviews-ajax-comments").find(".cr-ajax-reviews-list").empty();
crShowMoreReviewsPrd(jQuery(this));
}});
jQuery(".cr-comment-image-top .cr-comment-image-top-item").on("click", function(t){
t.preventDefault();
jQuery("body").addClass("cr-noscroll");
let slide_no=jQuery(this).data("slide");
let imgParent=jQuery(this).closest(".cr-ajax-reviews-cus-images-div").parent();
imgParent.find(".cr-ajax-reviews-cus-images-modal-cont").addClass("cr-mask-active");
imgParent.find(".cr-ajax-reviews-cus-images-modal .cr-ajax-reviews-cus-images-slider-main").slickk('setPosition');
imgParent.find(".cr-ajax-reviews-cus-images-modal .cr-ajax-reviews-cus-images-slider-nav").slickk('setPosition');
if(typeof slide_no!=='undefined'){
imgParent.find(".cr-ajax-reviews-cus-images-modal .cr-ajax-reviews-cus-images-slider-main").slickk('slickGoTo', slide_no, true);
imgParent.find(".cr-ajax-reviews-cus-images-modal .cr-ajax-reviews-cus-images-slider-nav").slickk('slickGoTo', slide_no, true);
}});
jQuery(".cr-comment-image-top .cr-comment-videoicon").on("click", function(t){
jQuery(this).closest(".cr-comment-image-top").find(".cr-comment-image-top-item").trigger("click");
});
jQuery(".cr-ajax-reviews-cus-images-modal-cont, .cr-ajax-reviews-cus-images-modal .cr-ajax-reviews-cus-images-close").on("click", function(t){
t.preventDefault();
let closeParent=jQuery(this).closest(".cr-ajax-reviews-cus-images-modal-cont.cr-mask-active");
closeParent.find(".cr-ajax-reviews-cus-images-modal .cr-ajax-reviews-cus-images-slider-main").slickk('slickGoTo',0,true);
closeParent.find(".cr-ajax-reviews-cus-images-modal .cr-ajax-reviews-cus-images-slider-nav").slickk('slickGoTo',0,true);
closeParent.removeClass("cr-mask-active");
jQuery("body").removeClass("cr-noscroll");
});
jQuery(".cr-ajax-reviews-cus-images-modal-cont .cr-ajax-reviews-cus-images-modal").on("click", function(t){
t.stopPropagation();
});
jQuery(".single_variation_wrap").on("show_variation", function(event, variation){
if(jQuery(".cr_gtin").length){
jQuery(".cr_gtin_val").text(variation._cr_gtin);
}
if(jQuery(".cr_mpn").length){
jQuery(".cr_mpn_val").text(variation._cr_mpn);
}
if(jQuery(".cr_brand").length){
jQuery(".cr_brand_val").text(variation._cr_brand);
}});
jQuery(document).on('reset_data', function (){
var cr_gtin=jQuery(".cr_gtin"),
cr_mpn=jQuery(".cr_mpn"),
cr_brand=jQuery(".cr_brand");
if(cr_gtin.length){
jQuery(".cr_gtin_val").text(cr_gtin.data("o_content"));
}
if(cr_mpn.length){
jQuery(".cr_mpn_val").text(cr_mpn.data("o_content"));
}
if(cr_brand.length){
jQuery(".cr_brand_val").text(cr_brand.data("o_content"));
}});
jQuery('.cr-all-reviews-shortcode .cr-show-more-button').on("click", function (e){
e.preventDefault();
cr_filter_all_reviews(jQuery(this), true);
});
jQuery('.cr-all-reviews-shortcode').on("click", ".cr-page-numbers-a", function (e){
e.preventDefault();
cr_filter_all_reviews(jQuery(this), true);
});
jQuery(".cr-all-reviews-shortcode").on("click", ".cr-histogram-a, .cr-seeAllReviews", function(t){
t.preventDefault();
let cr_rating=jQuery(this).data("rating");
jQuery("div.ivole-summaryBox tr.ivole-histogramRow.ivole-histogramRow-s").removeClass("ivole-histogramRow-s");
if(cr_rating > 0){
jQuery(this).closest("tr.ivole-histogramRow").addClass("ivole-histogramRow-s");
}
jQuery(this).parents(".cr-all-reviews-shortcode").find(".cr-review-tags-filter .cr-tag-selected").removeClass("cr-tag-selected");
cr_filter_all_reviews(jQuery(this));
});
jQuery(".cr-reviews-grid .cr-show-more-button").on("click", function (e){
e.preventDefault();
let $this=jQuery(this),
$spinner=$this.next(".cr-show-more-spinner"),
cr_rating=$this.parents(".cr-reviews-grid").find(".ivole-summaryBox.cr-grid-reviews-ajax tr.ivole-histogramRow.ivole-histogramRow-s .cr-histogram-a").attr("data-rating"),
attributes=$this.parents(".cr-reviews-grid").data("attributes");
attributes.comment__not_in=$this.parents(".cr-reviews-grid").find(".cr-review-card.cr-card-product").map(function(){
return jQuery(this).data("reviewid");
}).get();
attributes.comment__not_in=attributes.comment__not_in.concat($this.parents(".cr-reviews-grid").find(".cr-review-card.cr-card-shop").map(function(){
return jQuery(this).data("reviewid");
}).get());
var grid_data={
'action': "ivole_show_more_grid_reviews",
'rating': cr_rating,
'attributes': attributes
};
$this.hide();
$spinner.show();
jQuery.post(cr_ajax_object.ajax_url, grid_data, function(response){
$spinner.hide();
$reviews=jQuery(response.html).find(".cr-review-card");
let showMoreBtn=jQuery(response.html).find(".cr-show-more-button");
if($reviews.length){
$this.parents(".cr-reviews-grid").find(".cr-reviews-grid-inner").colcade("append", $reviews);
if(showMoreBtn.length){
$this.text(showMoreBtn.text());
$this.show();
}else{
$this.hide();
}}else{
$this.hide();
}}).fail(function(response){
$spinner.hide();
$this.show();
$this.parent().append('<div style="color:#cd2653;text-align:center;display:block;">'+response.responseText+'</div>');
});
});
jQuery(".cr-reviews-grid .cr-summaryBox-wrap").on("click", ".cr-histogram-a, .cr-seeAllReviews", function(e){
e.preventDefault();
let $this=jQuery(this),
$grid=$this.parents(".cr-reviews-grid"),
$spinner=$grid.find(".cr-show-more-spinner"),
cr_rating=$this.attr("data-rating"),
attributes=$grid.data("attributes");
attributes.show_more=attributes.count + attributes.count_shop_reviews;
attributes.comment__not_in=[];
if(!cr_rating) cr_rating=0;
var grid_data={
'action': "ivole_show_more_grid_reviews",
'rating': cr_rating,
'attributes': attributes
};
$grid.find("div.ivole-summaryBox tr.ivole-histogramRow.ivole-histogramRow-s").removeClass("ivole-histogramRow-s");
if(cr_rating > 0){
$this.closest("tr.ivole-histogramRow").addClass("ivole-histogramRow-s");
}
$grid.find(".cr-reviews-grid-inner").hide();
$grid.find(".cr-show-more-button").hide();
$spinner.show();
$grid.find("div.ivole-summaryBox").addClass("cr-summaryBar-updating");
jQuery.post(cr_ajax_object.ajax_url, grid_data, function(response){
$spinner.hide();
$grid.find(".cr-show-more-button").show();
$grid.find(".cr-summaryBox-wrap .cr-count-filtered-reviews").empty();
$reviews=jQuery(response.html).find(".cr-review-card");
if($reviews.length){
$grid.find(".cr-reviews-grid-inner").colcade("empty");
$grid.find(".cr-reviews-grid-inner").show();
$grid.find(".cr-reviews-grid-inner").colcade("append", $reviews);
$grid.find("div.ivole-summaryBox").removeClass("cr-summaryBar-updating");
$grid.find(".cr-summaryBox-wrap .cr-count-filtered-reviews").append(jQuery(response.html).find(".cr-count-filtered-reviews").html());
}}).fail(function(response){
$spinner.hide();
$this.parent().append('<div style="color: #cd2653;text-align: center;display: block;">'+response.responseText+'</div>');
});
});
jQuery('#cr_floatingtrustbadge').on("click", function(){
if(!jQuery(this).hasClass('cr-floatingbadge-big') ){
jQuery(this).find('div.cr-badge.badge_size_compact').hide();
jQuery(this).find('div.cr-badge.badge--wide-mobile').css('display', 'block');
jQuery(this).find('div.cr-floatingbadge-close').css('display', 'block');
jQuery(this).addClass('cr-floatingbadge-big');
var crcolors=jQuery(this).data('crcolors');
if(typeof crcolors!=='undefined'){
jQuery(this).css('border-color', crcolors['big']['border']);
jQuery(this).find('div.cr-floatingbadge-background-top').css('background-color', crcolors['big']['top']);
jQuery(this).find('div.cr-floatingbadge-background-middle').css('background-color', crcolors['big']['middle']);
jQuery(this).find('div.cr-floatingbadge-background-bottom').css('background-color', crcolors['big']['bottom']);
jQuery(this).find('div.cr-floatingbadge-background-bottom').css('border-color', crcolors['big']['border']);
}}
});
jQuery('#cr_floatingtrustbadge .cr-floatingbadge-close').on("click", function(event){
if(jQuery('#cr_floatingtrustbadge').hasClass('cr-floatingbadge-big') ){
jQuery(this).closest('#cr_floatingtrustbadge').find('div.cr-badge.badge--wide-mobile').hide();
jQuery(this).closest('#cr_floatingtrustbadge').find('div.cr-badge.badge_size_compact').css('display', 'block');
jQuery(this).closest('#cr_floatingtrustbadge').removeClass('cr-floatingbadge-big');
var crcolors=jQuery(this).closest('#cr_floatingtrustbadge').data('crcolors');
if(typeof crcolors!=='undefined'){
jQuery(this).closest('#cr_floatingtrustbadge').css('border-color', crcolors['small']['border']);
jQuery(this).closest('#cr_floatingtrustbadge').find('div.cr-floatingbadge-background-top').css('background-color', crcolors['small']['top']);
jQuery(this).closest('#cr_floatingtrustbadge').find('div.cr-floatingbadge-background-middle').css('background-color', crcolors['small']['middle']);
jQuery(this).closest('#cr_floatingtrustbadge').find('div.cr-floatingbadge-background-bottom').css('background-color', crcolors['small']['bottom']);
jQuery(this).closest('#cr_floatingtrustbadge').find('div.cr-floatingbadge-background-bottom').css('border-color', crcolors['small']['border']);
}}else{
jQuery('#cr_floatingtrustbadge').hide();
document.cookie='cr_hide_trustbadge=true; path=/; max-age='+60*60*24+';';
}
event.stopPropagation();
});
jQuery('.cr-reviews-slider').on('click', '.cr-slider-read-more a', function (e){
e.preventDefault();
let parent=jQuery(this).parents(".review-text");
parent.find(".cr-slider-read-more").hide();
parent.find(".cr-slider-details").css("display", "inline");
jQuery(this).parents(".cr-reviews-slider").slickk('setPosition');
});
jQuery('.cr-reviews-slider').on('click', '.cr-slider-read-less a', function (e){
e.preventDefault();
let parent=jQuery(this).parents(".review-text");
parent.find(".cr-slider-details").hide();
parent.find(".cr-slider-read-more").css("display", "inline");
jQuery(this).parents(".cr-reviews-slider").slickk('setPosition');
});
jQuery('.cr-reviews-grid').on('click', '.cr-grid-read-more a', function (e){
e.preventDefault();
let parent=jQuery(this).parents(".review-content");
if(0===parent.length){
parent=jQuery(this).parents(".cr-grid-reply-content");
}
parent.find(".cr-grid-read-more").hide();
parent.find(".cr-grid-details").css("display", "inline");
});
jQuery('.cr-reviews-grid').on('click', '.cr-grid-read-less a', function (e){
e.preventDefault();
let parent=jQuery(this).parents(".review-content");
if(0===parent.length){
parent=jQuery(this).parents(".cr-grid-reply-content");
}
parent.find(".cr-grid-details").hide();
parent.find(".cr-grid-read-more").css("display", "inline");
});
jQuery('.cr-qna-block .cr-qna-search-block .cr-qna-ask-button').on('click', function (e){
e.preventDefault();
jQuery(this).closest('.cr-qna-block').addClass('cr-qna-new-q-form-open');
});
jQuery(".cr-qna-block .cr-qna-list-block").on("click", ".cr-qna-ans-button", function (e){
e.preventDefault();
let nameField=jQuery(this).closest('.cr-qna-block').find(".cr-qna-new-q-form .cr-review-form-name");
let nameValue=nameField.find(".cr-review-form-txt").data("defval");
jQuery(this).closest('.cr-qna-list-q-b').find(".cr-qna-list-inl-answ .cr-review-form-name .cr-review-form-txt").val(nameValue);
let emailField=jQuery(this).closest('.cr-qna-block').find(".cr-qna-new-q-form .cr-review-form-email");
let emailValue=emailField.find(".cr-review-form-txt").data("defval");
jQuery(this).closest('.cr-qna-list-q-b').find(".cr-qna-list-inl-answ .cr-review-form-email .cr-review-form-txt").val(emailValue);
jQuery(this).closest('.cr-qna-list-q-b').addClass('cr-qna-ans-form-open');
});
jQuery(".cr-qna-block").on("click", ".cr-show-more-que", function(t){
t.preventDefault();
let qna_block=jQuery(this).parents(".cr-qna-block").eq(0);
let cr_product_id=jQuery(this).attr("data-product");
let cr_page=jQuery(this).attr("data-page");
let cr_attributes=qna_block.data("attributes");
let cr_search=qna_block.find(".cr-ajax-qna-search input").val();
let cr_permalink=jQuery(this).attr("data-permalink");
let cr_data={
"action": "cr_show_more_qna",
"productID": cr_product_id,
"page": cr_page,
"permalink": cr_permalink,
"search": cr_search,
"cr_attributes": cr_attributes
};
qna_block.find(".cr-search-no-qna").hide();
jQuery(this).hide();
qna_block.find("#cr-show-more-q-spinner").show();
jQuery.post(cr_ajax_object.ajax_url, cr_data, function(response){
jQuery(".cr-qna-block #cr-show-more-q-spinner").hide();
if(response.page >=0){
jQuery(".cr-qna-block .cr-qna-list-block .cr-qna-list-block-inner").append(response.html);
jQuery(".cr-qna-block #cr-show-more-q-id").attr("data-page",response.page);
if(!response.last_page){
jQuery(".cr-qna-block #cr-show-more-q-id").show();
}}
if(response.html===""&&response.page===0){
jQuery(".cr-qna-block .cr-search-no-qna").show();
}}, "json");
});
jQuery(".cr-qna-block .cr-ajax-qna-search input").on("keyup", cr_keyup_delay(function(e){
var code=(e.keyCode||e.which);
if(code==37||code==38||code==39||code==40){
return;
}
jQuery(".cr-qna-block #cr-show-more-q-id").attr("data-page", -1);
jQuery(".cr-qna-block .cr-qna-list-block .cr-qna-list-block-inner").empty();
jQuery(".cr-qna-block #cr-show-more-q-id").trigger("click");
}, 500));
jQuery(".cr-qna-block .cr-ajax-qna-search input").on("keyup", function(e){
if(jQuery(this).val()!==""){
jQuery(".cr-qna-block .cr-ajax-qna-search .cr-clear-input").css("display", "inline-block");
}else{
if(jQuery(this).val()==="") jQuery(".cr-qna-block .cr-ajax-qna-search .cr-clear-input").hide();
}}).on("change", function(){
if(jQuery(this).val()==="") jQuery(".cr-qna-block .cr-ajax-qna-search .cr-clear-input").hide();
});
jQuery(".cr-qna-block .cr-ajax-qna-search .cr-clear-input").on("click", function (){
jQuery(this).prev("input").val("");
jQuery(".cr-qna-block .cr-ajax-qna-search .cr-clear-input").hide();
jQuery(".cr-qna-block #cr-show-more-q-id").attr("data-page", -1);
jQuery(".cr-qna-block .cr-qna-list-block .cr-qna-list-block-inner").empty();
jQuery(".cr-qna-block #cr-show-more-q-id").trigger("click");
});
jQuery("body").on("click", "a.cr-qna-link", function (){
const cr_qna_tab=jQuery('.cr_qna_tab a');
if(cr_qna_tab.length){
cr_qna_tab.trigger("click");
}else{
jQuery('.cr-qna-block').parents(':hidden').show();
}
return true;
});
jQuery("body").on("click", ".cr-review-link", function (){
const wc_reviews_tab=jQuery('.reviews_tab a');
if(wc_reviews_tab.length){
wc_reviews_tab.trigger("click");
return true;
}});
jQuery("#cr_review_image").on("change", function (){
jQuery(".cr-upload-images-status").removeClass("cr-upload-images-status-error");
jQuery(".cr-upload-images-status").text(cr_ajax_object.cr_upload_initial);
let allowedTypes=['image/jpeg', 'image/png', 'image/jpg', 'image/gif', 'video/mp4', 'video/mpeg', 'video/ogg', 'video/webm', 'video/quicktime', 'video/x-msvideo'];
let uploadFiles=jQuery("#cr_review_image");
let countFiles=uploadFiles[0].files.length;
let countUploaded=jQuery(".cr-upload-images-preview .cr-upload-images-containers").length;
let lastIndex=1;
let cr_captcha="";
if(jQuery(this).attr("data-lastindex")){
lastIndex=parseInt(jQuery(this).attr("data-lastindex"));
}
if(countFiles + countUploaded > cr_ajax_object.cr_images_upload_limit){
jQuery(".cr-upload-images-status").addClass("cr-upload-images-status-error");
jQuery(".cr-upload-images-status").text(cr_ajax_object.cr_upload_error_too_many);
jQuery(".cr-upload-images-preview .cr-upload-images-containers").not(".cr-upload-ok").remove();
uploadFiles.val("");
return;
}
for(let i=0; i < countFiles; i++){
if(!allowedTypes.includes(uploadFiles[0].files[i].type)){
jQuery(".cr-upload-images-status").addClass("cr-upload-images-status-error");
jQuery(".cr-upload-images-status").text(cr_ajax_object.cr_upload_error_file_type);
jQuery(".cr-upload-images-preview .cr-upload-images-containers").not(".cr-upload-ok").remove();
uploadFiles.val("");
return;
}else if(uploadFiles[0].files[i].size&&uploadFiles[0].files[i].size > cr_ajax_object.cr_images_upload_max_size){
jQuery(".cr-upload-images-status").addClass("cr-upload-images-status-error");
jQuery(".cr-upload-images-status").text(cr_ajax_object.cr_upload_error_file_size);
jQuery(".cr-upload-images-preview .cr-upload-images-containers").not(".cr-upload-ok").remove();
uploadFiles.val("");
return;
}else{
let container=jQuery("<div/>", {class:"cr-upload-images-containers cr-upload-images-container-" + (lastIndex + i)});
let progressBar=jQuery("<div/>", {class:"cr-upload-images-pbar"});
progressBar.append(jQuery("<div/>", {class:"cr-upload-images-pbarin"})
);
if(-1===uploadFiles[0].files[i].type.indexOf('image') ){
container.append(jQuery("<svg class='cr-upload-video-thumbnail' viewBox='0 0 576 512'><path d='M336.2 64H47.8C21.4 64 0 85.4 0 111.8v288.4C0 426.6 21.4 448 47.8 448h288.4c26.4 0 47.8-21.4 47.8-47.8V111.8c0-26.4-21.4-47.8-47.8-47.8zm189.4 37.7L416 177.3v157.4l109.6 75.5c21.2 14.6 50.4-.3 50.4-25.8V127.5c0-25.4-29.1-40.4-50.4-25.8z'></path></svg>")
);
}else{
container.append(jQuery("<img>", {class:"cr-upload-images-thumbnail",src:URL.createObjectURL(uploadFiles[0].files[i])})
);
}
container.append(progressBar
);
let removeButton=jQuery("<button/>", {class:"cr-upload-images-delete"});
removeButton.append('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><rect x="0" fill="none" width="20" height="20"/><g><path class="cr-no-icon" d="M12.12 10l3.53 3.53-2.12 2.12L10 12.12l-3.54 3.54-2.12-2.12L7.88 10 4.34 6.46l2.12-2.12L10 7.88l3.54-3.53 2.12 2.12z"/></g></svg>'
);
container.append(removeButton
);
container.append(jQuery("<input>", {name:"cr-upload-images-ids[]",type:"hidden",value:""})
);
container.append(jQuery("<span/>", {class:"cr-upload-images-delete-spinner"})
);
jQuery(".cr-upload-images-preview").append(container);
}}
for(let i=0; i < countFiles; i++){
let formData=new FormData();
formData.append("action", "cr_upload_local_images_frontend");
formData.append("cr_nonce", jQuery(this).attr("data-nonce"));
formData.append("cr_postid", jQuery(this).attr("data-postid"));
formData.append("cr_file", uploadFiles[0].files[i]);
if(typeof grecaptcha!=="undefined"&&cr_ajax_object.ivole_recaptcha==='1'){
cr_captcha=grecaptcha.getResponse();
grecaptcha.reset();
}
formData.append("cr_captcha", cr_captcha);
jQuery.ajax({
url: cr_ajax_object.ajax_url,
data: formData,
processData: false,
contentType: false,
dataType: "json",
type: "POST",
beforeSend: function(){
},
xhr: function(){
var myXhr=jQuery.ajaxSettings.xhr();
if(myXhr.upload){
myXhr.upload.addEventListener('progress', function(e){
if(e.lengthComputable){
let perc=(e.loaded / e.total) * 100;
perc=perc.toFixed(0);
jQuery(".cr-upload-images-preview .cr-upload-images-containers.cr-upload-images-container-" + (lastIndex + i) + " .cr-upload-images-pbar .cr-upload-images-pbarin").width(perc + "%");
}}, false);
}
return myXhr;
},
success: function(response){
if(200===response["code"]){
let idkey=JSON.stringify({ id: response["attachment"]["id"], key: response["attachment"]["key"] });
jQuery(".cr-upload-images-preview .cr-upload-images-containers.cr-upload-images-container-" + (lastIndex + i) + " input").val(idkey);
jQuery(".cr-upload-images-preview .cr-upload-images-containers.cr-upload-images-container-" + (lastIndex + i)).addClass("cr-upload-ok");
jQuery(".cr-upload-images-preview .cr-upload-images-containers.cr-upload-images-container-" + (lastIndex + i) + " button").attr("data-delnonce",response["attachment"]["nonce"]);
}else if(500 <=response["code"]){
jQuery(".cr-upload-images-preview .cr-upload-images-containers.cr-upload-images-container-" + (lastIndex + i)).remove();
jQuery(".cr-upload-images-status").addClass("cr-upload-images-status-error");
jQuery(".cr-upload-images-status").text(response["message"]);
}}
});
}
jQuery(this).attr("data-lastindex", lastIndex + countFiles);
uploadFiles.val("");
});
jQuery(".cr-upload-images-preview").on("click", ".cr-upload-images-delete", function (e){
e.preventDefault();
jQuery(".cr-upload-images-status").removeClass("cr-upload-images-status-error");
jQuery(".cr-upload-images-status").text(cr_ajax_object.cr_upload_initial);
let classList=jQuery(this).parent().eq(0).attr("class").split(/\s+/);
let classes="";
jQuery.each(classList, function(index, item){
classes +="." + item;
});
let ajaxData={
"action": "cr_delete_local_images_frontend",
"cr_nonce": jQuery(this).attr("data-delnonce"),
"image": jQuery(this).parent().children("input").eq(0).val(),
"class": classes
}
jQuery(this).parent().addClass("cr-upload-delete-pending");
jQuery.post(cr_ajax_object.ajax_url, ajaxData, function(response){
if(200===response["code"]&&response["class"]){
jQuery(".cr-upload-images-preview " + response["class"]).remove();
}
jQuery(".cr-upload-images-preview " + response["class"]).removeClass("cr-upload-delete-pending");
}, "json");
});
jQuery(".cr-review-form-rating .cr-review-form-rating-inner").on("mouseenter",
function(){
let rating=parseInt(jQuery(this).data("rating") );
let ratingActv=parseInt(jQuery(this).closest(".cr-review-form-rating-cont").find(".cr-review-form-rating-actv").data("rating") );
if(isNaN(ratingActv) ){
ratingActv=0;
}
for(r=1; r < 6; r++){
if(r > rating&&r > ratingActv){
jQuery(this).closest(".cr-review-form-rating-cont").find(".cr-review-form-rating-inner[data-rating=" + r + "] .cr-rating-act").hide();
jQuery(this).closest(".cr-review-form-rating-cont").find(".cr-review-form-rating-inner[data-rating=" + r + "] .cr-rating-deact").show();
}else{
jQuery(this).closest(".cr-review-form-rating-cont").find(".cr-review-form-rating-inner[data-rating=" + r + "] .cr-rating-deact").hide();
jQuery(this).closest(".cr-review-form-rating-cont").find(".cr-review-form-rating-inner[data-rating=" + r + "] .cr-rating-act").show();
}}
jQuery(this).closest(".cr-review-form-rating-cont").find(".cr-review-form-rating-nbr").text(rating + "/5");
}
).on("mouseleave",
function(){
let ratingActv=parseInt(jQuery(this).closest(".cr-review-form-rating-cont").find(".cr-review-form-rating-actv").data("rating") );
if(isNaN(ratingActv) ){
ratingActv=0;
}
for(r=1; r < 6; r++){
if(r > ratingActv){
jQuery(this).closest(".cr-review-form-rating-cont").find(".cr-review-form-rating-inner[data-rating=" + r + "] .cr-rating-act").hide();
jQuery(this).closest(".cr-review-form-rating-cont").find(".cr-review-form-rating-inner[data-rating=" + r + "] .cr-rating-deact").show();
}else{
jQuery(this).closest(".cr-review-form-rating-cont").find(".cr-review-form-rating-inner[data-rating=" + r + "] .cr-rating-deact").hide();
jQuery(this).closest(".cr-review-form-rating-cont").find(".cr-review-form-rating-inner[data-rating=" + r + "] .cr-rating-act").show();
}}
jQuery(this).closest(".cr-review-form-rating-cont").find(".cr-review-form-rating-nbr").text(ratingActv + "/5");
}
);
jQuery(".cr-review-form-rating .cr-review-form-rating-inner").on("click", function(e){
e.preventDefault();
let rating=parseInt(jQuery(this).data("rating") );
jQuery(this).closest(".cr-review-form-rating-cont").find(".cr-review-form-rating-inner").removeClass("cr-review-form-rating-actv");
jQuery(this).addClass("cr-review-form-rating-actv");
for(r=1; r < 6; r++){
if(r > rating){
jQuery(this).closest(".cr-review-form-rating-cont").find(".cr-review-form-rating-inner[data-rating=" + r + "] .cr-rating-act").hide();
jQuery(this).closest(".cr-review-form-rating-cont").find(".cr-review-form-rating-inner[data-rating=" + r + "] .cr-rating-deact").show();
}else{
jQuery(this).closest(".cr-review-form-rating-cont").find(".cr-review-form-rating-inner[data-rating=" + r + "] .cr-rating-deact").hide();
jQuery(this).closest(".cr-review-form-rating-cont").find(".cr-review-form-rating-inner[data-rating=" + r + "] .cr-rating-act").show();
}}
jQuery(this).closest(".cr-review-form-rating-cont").find(".cr-review-form-rating-nbr").text(rating + "/5");
jQuery(this).closest(".cr-review-form-rating").find(".cr-review-form-rating-inp").val(rating);
jQuery(this).closest(".cr-review-form-rating").removeClass("cr-review-form-error");
});
jQuery(".cr-all-reviews-shortcode .cr-nav-left svg, .cr-all-reviews-shortcode .cr-nav-right svg, .cr-all-reviews-shortcode .cr-review-form-cancel").on("click", function(e){
jQuery(this).closest(".cr-all-reviews-shortcode").removeClass("cr-all-reviews-new-review");
jQuery(this).closest(".cr-review-form-wrap").removeClass("cr-review-form-res");
cr_reset_review_form(jQuery(this) );
});
jQuery(".cr-all-reviews-shortcode .cr-review-form-wrap").on("click", ".cr-review-form-success", function(e){
jQuery(this).closest(".cr-all-reviews-shortcode").removeClass("cr-all-reviews-new-review");
jQuery(this).closest(".cr-review-form-wrap").removeClass("cr-review-form-res");
cr_reset_review_form(jQuery(this) );
window.location.reload();
});
jQuery(".cr-review-form-wrap").on("click", ".cr-review-form-error", function(e){
jQuery(this).closest(".cr-review-form-wrap").removeClass("cr-review-form-res");
});
jQuery(".cr-ajax-reviews-review-form .cr-nav-left svg, .cr-ajax-reviews-review-form .cr-nav-right svg, .cr-ajax-reviews-review-form .cr-review-form-cancel").on("click", function(e){
jQuery(this).closest(".cr-reviews-ajax-reviews").find(".cr-reviews-ajax-comments").show();
jQuery(this).closest(".cr-reviews-ajax-reviews").find(".cr-ajax-reviews-review-form").hide();
jQuery(this).closest(".cr-review-form-wrap").removeClass("cr-review-form-res");
cr_reset_review_form(jQuery(this) );
});
jQuery(".cr-ajax-reviews-review-form .cr-review-form-wrap").on("click", ".cr-review-form-success", function(e){
jQuery(this).closest(".cr-reviews-ajax-reviews").find(".cr-reviews-ajax-comments").show();
jQuery(this).closest(".cr-reviews-ajax-reviews").find(".cr-ajax-reviews-review-form").hide();
jQuery(this).closest(".cr-review-form-wrap").removeClass("cr-review-form-res");
cr_reset_review_form(jQuery(this) );
if(window.location.hash!=='#reviews'){
window.location.href=window.location.pathname + '#reviews';
}
window.location.reload();
});
jQuery(".cr-reviews-grid .cr-nav-left svg, .cr-reviews-grid .cr-nav-right svg, .cr-reviews-grid .cr-review-form-cancel").on("click", function(e){
jQuery(this).closest(".cr-reviews-grid").removeClass("cr-reviews-grid-new-review");
jQuery(this).closest(".cr-review-form-wrap").removeClass("cr-review-form-res");
cr_reset_review_form(jQuery(this) );
});
jQuery(".cr-reviews-grid .cr-review-form-wrap").on("click", ".cr-review-form-success", function(e){
jQuery(this).closest(".cr-reviews-grid").removeClass("cr-reviews-grid-new-review");
jQuery(this).closest(".cr-review-form-wrap").removeClass("cr-review-form-res");
cr_reset_review_form(jQuery(this) );
window.location.reload();
});
jQuery(".cr-qna-block").on("click", ".cr-qna-new-q-form .cr-nav-left svg, .cr-qna-new-q-form .cr-nav-right svg, .cr-qna-new-q-form .cr-review-form-cancel", function(e){
jQuery(this).closest(".cr-qna-block").removeClass("cr-qna-new-q-form-open");
jQuery(this).closest(".cr-qna-new-q-form").removeClass("cr-review-form-res");
cr_reset_qna_form(jQuery(this) );
});
jQuery(".cr-qna-block").on("click", ".cr-qna-new-q-form .cr-review-form-success", function(e){
jQuery(this).closest(".cr-qna-block").removeClass("cr-qna-new-q-form-open");
jQuery(this).closest(".cr-qna-new-q-form").removeClass("cr-review-form-res");
cr_reset_qna_form(jQuery(this) );
});
jQuery(".cr-qna-block").on("click", ".cr-qna-new-q-form .cr-review-form-error", function(e){
jQuery(this).closest(".cr-qna-new-q-form").removeClass("cr-review-form-res");
});
jQuery(".cr-qna-block").on("click", ".cr-qna-list-inl-answ .cr-nav-left svg, .cr-qna-list-inl-answ .cr-nav-right svg, .cr-qna-list-inl-answ .cr-review-form-cancel", function(e){
jQuery(this).closest(".cr-qna-list-q-b").removeClass("cr-qna-ans-form-open");
jQuery(this).closest(".cr-qna-list-inl-answ").removeClass("cr-review-form-res");
cr_reset_ans_form(jQuery(this) );
});
jQuery(".cr-qna-block").on("click", ".cr-qna-list-inl-answ .cr-review-form-success", function(e){
jQuery(this).closest(".cr-qna-list-q-b").removeClass("cr-qna-ans-form-open");
jQuery(this).closest(".cr-qna-list-inl-answ").removeClass("cr-review-form-res");
cr_reset_ans_form(jQuery(this) );
});
jQuery(".cr-qna-block").on("click", ".cr-qna-list-inl-answ .cr-review-form-error", function(e){
jQuery(this).closest(".cr-qna-list-inl-answ").removeClass("cr-review-form-res");
});
jQuery(".cr-review-form-wrap .cr-review-form-submit").on("click", function(e){
if(0 < jQuery(this).closest(".cr-review-form-wrap").find(".cr-form-item-media-preview .cr-upload-images-containers:not(.cr-upload-ok)").length){
return false;
}
jQuery(this).closest(".cr-review-form-wrap").find(".cr-review-form-rating").removeClass("cr-review-form-error");
jQuery(this).closest(".cr-review-form-wrap").find(".cr-review-form-comment").removeClass("cr-review-form-error");
jQuery(this).closest(".cr-review-form-wrap").find(".cr-review-form-name").removeClass("cr-review-form-error");
jQuery(this).closest(".cr-review-form-wrap").find(".cr-review-form-email").removeClass("cr-review-form-error");
jQuery(this).closest(".cr-review-form-wrap").find(".cr-onsite-question").removeClass("cr-review-form-error");
jQuery(this).closest(".cr-review-form-wrap").find(".cr-form-item-media").removeClass("cr-review-form-error");
jQuery(this).closest(".cr-review-form-wrap").find(".cr-review-form-captcha").removeClass("cr-review-form-error");
jQuery(this).closest(".cr-review-form-wrap").find(".cr-review-form-terms").removeClass("cr-review-form-error");
if(cr_validate_review_form(jQuery(this) )){
let onsiteQuestions={};
jQuery(this).closest(".cr-review-form-wrap").find(".cr-review-form-rating input[type='hidden']").each(function(){
onsiteQuestions[jQuery(this).attr('name')]=jQuery(this).val();
}
)
jQuery(this).closest(".cr-review-form-wrap").find(".cr-onsite-question input").each(function(){
onsiteQuestions[jQuery(this).attr('name')]=jQuery(this).val();
}
)
let captchaResponse='';
if(0 < jQuery(this).closest(".cr-review-form-wrap").find('.cr-review-form-captcha .cr-recaptcha').length){
if(grecaptcha){
captchaResponse=grecaptcha.getResponse();
}}
let cr_data={
"action": "cr_submit_review",
"rating": jQuery(this).closest(".cr-review-form-wrap").find(".cr-review-form-rating-overall .cr-review-form-rating-inp").val(),
"review": jQuery(this).closest(".cr-review-form-wrap").find(".cr-review-form-comment-txt").val().trim(),
"name": jQuery(this).closest(".cr-review-form-wrap").find(".cr-review-form-name .cr-review-form-txt").val().trim(),
"id": jQuery(this).closest(".cr-review-form-wrap").find(".cr-review-form-item-id").val(),
"email": jQuery(this).closest(".cr-review-form-wrap").find(".cr-review-form-email .cr-review-form-txt").val().trim(),
"onsiteQuestions": onsiteQuestions,
"cr-upload-images-ids": jQuery(this).closest(".cr-review-form-wrap").find(".cr-form-item-media .cr-upload-images-containers input").map(function(){
return jQuery(this).val();
}).get(),
'g-recaptcha-response': captchaResponse
};
jQuery(this).closest(".cr-review-form-wrap").addClass("cr-review-form-submitting");
jQuery(this).closest(".cr-review-form-wrap").find(".cr-review-form-continue").removeClass("cr-review-form-success");
jQuery(this).closest(".cr-review-form-wrap").find(".cr-review-form-continue").removeClass("cr-review-form-error");
jQuery.post({
url: cr_ajax_object.ajax_url,
data: cr_data,
context: jQuery(this),
success: function(response){
if(! Object.hasOwn(response, 'button') ){
response.button='OK';
}
if(! Object.hasOwn(response, 'description') ){
response.description='An unexpected error that could be caused by a third-party plugin';
}
this.closest(".cr-review-form-wrap").removeClass("cr-review-form-submitting");
this.closest(".cr-review-form-wrap").addClass("cr-review-form-res");
this.closest(".cr-review-form-wrap").find(".cr-review-form-result span").html(response.description);
this.closest(".cr-review-form-wrap").find(".cr-review-form-continue").html(response.button);
if(0===response.code){
this.closest(".cr-review-form-wrap").find(".cr-review-form-continue").addClass("cr-review-form-success");
}else{
this.closest(".cr-review-form-wrap").find(".cr-review-form-continue").addClass("cr-review-form-error");
}},
dataType: "json"
}
);
};});
jQuery(".cr-qna-block .cr-qna-new-q-form").on("click", ".cr-review-form-submit", function(e){
jQuery(this).closest(".cr-qna-new-q-form").find(".cr-review-form-comment").removeClass("cr-review-form-error");
jQuery(this).closest(".cr-qna-new-q-form").find(".cr-review-form-name").removeClass("cr-review-form-error");
jQuery(this).closest(".cr-qna-new-q-form").find(".cr-review-form-email").removeClass("cr-review-form-error");
jQuery(this).closest(".cr-qna-new-q-form").find(".cr-review-form-terms").removeClass("cr-review-form-error");
if(cr_validate_qna(jQuery(this) )){
let cr_data={
"action": "cr_new_qna",
"crNonce": jQuery(this).closest(".cr-qna-block").data("nonce"),
"currentPostID": jQuery(this).closest(".cr-qna-new-q-form").find(".cr-review-form-item-id").val(),
"text": jQuery(this).closest(".cr-qna-new-q-form").find(".cr-review-form-comment-txt").val().trim(),
"name": jQuery(this).closest(".cr-qna-new-q-form").find(".cr-review-form-name .cr-review-form-txt").val().trim(),
"email": jQuery(this).closest(".cr-qna-new-q-form").find(".cr-review-form-email .cr-review-form-txt").val().trim()
};
jQuery(this).closest(".cr-qna-new-q-form").addClass("cr-review-form-submitting");
jQuery(this).closest(".cr-qna-new-q-form").find(".cr-review-form-continue").removeClass("cr-review-form-success");
jQuery(this).closest(".cr-qna-new-q-form").find(".cr-review-form-continue").removeClass("cr-review-form-error");
const postQuestion=(token, data, ref)=> {
data.cptcha=token;
jQuery.post({
url: cr_ajax_object.ajax_url,
data: data,
context: jQuery(ref),
success: function(response){
this.closest(".cr-qna-new-q-form").removeClass("cr-review-form-submitting");
this.closest(".cr-qna-new-q-form").addClass("cr-review-form-res");
this.closest(".cr-qna-new-q-form").find(".cr-review-form-result span").html(response.description);
this.closest(".cr-qna-new-q-form").find(".cr-review-form-continue").html(response.button);
if(0===response.code){
this.closest(".cr-qna-new-q-form").find(".cr-review-form-continue").addClass("cr-review-form-success");
}else{
this.closest(".cr-qna-new-q-form").find(".cr-review-form-continue").addClass("cr-review-form-error");
}},
dataType: "json"
}
);
};
let cr_cptcha=jQuery(this).attr("data-crcptcha");
var rf=this;
if(cr_cptcha&&cr_cptcha.length > 0){
grecaptcha.ready(function(){
grecaptcha.execute(cr_cptcha, {action: 'submit'}).then(function(token){
postQuestion(token, cr_data, rf)
});
});
}else{
postQuestion('', cr_data, rf);
}};});
jQuery(".cr-qna-block").on("click", ".cr-qna-list-inl-answ .cr-review-form-submit", function(e){
jQuery(this).closest(".cr-qna-list-inl-answ").find(".cr-review-form-comment").removeClass("cr-review-form-error");
jQuery(this).closest(".cr-qna-list-inl-answ").find(".cr-review-form-name").removeClass("cr-review-form-error");
jQuery(this).closest(".cr-qna-list-inl-answ").find(".cr-review-form-email").removeClass("cr-review-form-error");
jQuery(this).closest(".cr-qna-list-inl-answ").find(".cr-review-form-terms").removeClass("cr-review-form-error");
if(cr_validate_ans(jQuery(this) )){
let cr_data={
"action": "cr_new_qna",
"crNonce": jQuery(this).closest(".cr-qna-block").data("nonce"),
"currentPostID": jQuery(this).closest(".cr-qna-block").find(".cr-review-form-item-id").val(),
"questionID": jQuery(this).closest(".cr-qna-list-q-b").data("question"),
"productID": jQuery(this).closest(".cr-qna-list-q-b").data("post"),
"text": jQuery(this).closest(".cr-qna-list-inl-answ").find(".cr-review-form-comment-txt").val().trim(),
"name": jQuery(this).closest(".cr-qna-list-inl-answ").find(".cr-review-form-name .cr-review-form-txt").val().trim(),
"email": jQuery(this).closest(".cr-qna-list-inl-answ").find(".cr-review-form-email .cr-review-form-txt").val().trim()
};
jQuery(this).closest(".cr-qna-list-inl-answ").addClass("cr-review-form-submitting");
jQuery(this).closest(".cr-qna-list-inl-answ").find(".cr-review-form-continue").removeClass("cr-review-form-success");
jQuery(this).closest(".cr-qna-list-inl-answ").find(".cr-review-form-continue").removeClass("cr-review-form-error");
const postQuestion=(token, data, ref)=> {
data.cptcha=token;
jQuery.post({
url: cr_ajax_object.ajax_url,
data: data,
context: jQuery(ref),
success: function(response){
this.closest(".cr-qna-list-inl-answ").removeClass("cr-review-form-submitting");
this.closest(".cr-qna-list-inl-answ").addClass("cr-review-form-res");
this.closest(".cr-qna-list-inl-answ").find(".cr-review-form-result span").html(response.description);
this.closest(".cr-qna-list-inl-answ").find(".cr-review-form-continue").html(response.button);
if(0===response.code){
this.closest(".cr-qna-list-inl-answ").find(".cr-review-form-continue").addClass("cr-review-form-success");
}else{
this.closest(".cr-qna-list-inl-answ").find(".cr-review-form-continue").addClass("cr-review-form-error");
}},
dataType: "json"
}
);
};
let cr_cptcha=jQuery(this).attr("data-crcptcha");
var rf=this;
if(cr_cptcha&&cr_cptcha.length > 0&&grecaptcha){
grecaptcha.ready(function(){
grecaptcha.execute(cr_cptcha, {action: 'submit'}).then(function(token){
postQuestion(token, cr_data, rf)
});
});
}else{
postQuestion('', cr_data, rf);
}};});
jQuery(".cr-single-product-review").on("click", ".cr-single-product-rev-submit", function(t){
let validationResult=true;
let reviewForm=jQuery(this).closest(".cr-single-product-review");
reviewForm.find(".cr-review-form-rating-cont.cr-review-form-rating-req").each(function(index){
if(1 > jQuery(this).find(".cr-review-form-rating-actv").length){
jQuery(this).closest(".cr-review-form-rating").addClass("cr-review-form-error");
validationResult=false;
}});
reviewForm.find(".cr-onsite-question.cr-review-form-que-req").each(function(index){
if(1 > jQuery(this).find("input[type=text]").val().trim().length){
jQuery(this).closest(".cr-onsite-question").addClass("cr-review-form-error");
validationResult=false;
}else{
jQuery(this).closest(".cr-onsite-question").removeClass("cr-review-form-error");
}});
reviewForm.find(".cr-review-form-textbox").each(function(index){
if(1 > jQuery(this).val().trim().length){
jQuery(this).addClass("cr-review-form-error");
validationResult=false;
}else{
jQuery(this).removeClass("cr-review-form-error");
}});
if(0 < reviewForm.find('.cr-review-form-terms').length){
if(! reviewForm.find('.cr-review-form-terms .cr-review-form-checkbox').is(':checked')){
alert('Please tick the checkbox to proceed');
validationResult=false;
}}
if(! validationResult){
t.preventDefault();
}});
jQuery(".cr-all-reviews-add-review").on("click", function(t){
t.preventDefault();
if(0 < jQuery(this).closest(".cr-all-reviews-shortcode").length){
jQuery(this).closest(".cr-all-reviews-shortcode").addClass("cr-all-reviews-new-review");
}
if(0 < jQuery(this).closest(".cr-reviews-grid").length){
jQuery(this).closest(".cr-reviews-grid").addClass("cr-reviews-grid-new-review");
}});
jQuery(".cr-review-form-wrap .cr-form-item-media-none").on("click", function(t){
jQuery(this).parent().find("input.cr-form-item-media-file").trigger("click");
});
jQuery(".cr-review-form-wrap .cr-form-item-media-preview").on("click", ".cr-form-item-media-add", function(t){
jQuery(this).parents(".cr-form-item-media").find("input.cr-form-item-media-file").trigger("click");
});
jQuery(".cr-review-form-wrap .cr-form-item-media .cr-form-item-media-file").on("change", function (){
let allowedTypes=['image/jpeg', 'image/png', 'image/jpg', 'image/gif', 'video/mp4', 'video/mpeg', 'video/ogg', 'video/webm', 'video/quicktime', 'video/x-msvideo'],
uploadFiles=jQuery(this),
countFiles=uploadFiles[0].files.length,
lastIndex=1,
mediaPreview=jQuery(this).parent().find(".cr-form-item-media-preview"),
countUploaded=mediaPreview.children(".cr-upload-images-containers").length;
jQuery(this).closest(".cr-form-item-media").removeClass("cr-review-form-error");
if(jQuery(this).attr("data-lastindex")){
lastIndex=parseInt(jQuery(this).attr("data-lastindex") );
}
if(countFiles + countUploaded > cr_ajax_object.cr_images_upload_limit){
jQuery(this).closest(".cr-form-item-media").addClass("cr-review-form-error");
jQuery(this).closest(".cr-form-item-media").find(".cr-review-form-field-error").text(cr_ajax_object.cr_upload_error_too_many);
uploadFiles.val("");
return;
}
for(let i=0; i < countFiles; i++){
if(!allowedTypes.includes(uploadFiles[0].files[i].type)){
jQuery(this).closest(".cr-form-item-media").addClass("cr-review-form-error");
jQuery(this).closest(".cr-form-item-media").find(".cr-review-form-field-error").text(cr_ajax_object.cr_upload_error_file_type);
uploadFiles.val("");
return;
}else if(uploadFiles[0].files[i].size&&uploadFiles[0].files[i].size > cr_ajax_object.cr_images_upload_max_size * 100){
jQuery(this).closest(".cr-form-item-media").addClass("cr-review-form-error");
jQuery(this).closest(".cr-form-item-media").find(".cr-review-form-field-error").text(cr_ajax_object.cr_upload_error_file_size);
uploadFiles.val("");
return;
}else{
let container=jQuery("<div/>", {class:"cr-upload-images-containers cr-upload-images-container-" + (lastIndex + i)});
let progressBar=jQuery("<div/>", {class:"cr-upload-images-pbar"});
progressBar.append(jQuery("<div/>", {class:"cr-upload-images-pbarin"})
);
if(-1===uploadFiles[0].files[i].type.indexOf('image') ){
container.append(jQuery("<svg class='cr-upload-video-thumbnail' viewBox='0 0 576 512'><path d='M336.2 64H47.8C21.4 64 0 85.4 0 111.8v288.4C0 426.6 21.4 448 47.8 448h288.4c26.4 0 47.8-21.4 47.8-47.8V111.8c0-26.4-21.4-47.8-47.8-47.8zm189.4 37.7L416 177.3v157.4l109.6 75.5c21.2 14.6 50.4-.3 50.4-25.8V127.5c0-25.4-29.1-40.4-50.4-25.8z'></path></svg>")
);
}else{
container.append(jQuery("<img>", {class:"cr-upload-images-thumbnail", src:URL.createObjectURL(uploadFiles[0].files[i])})
);
}
container.append(progressBar
);
let removeButton=jQuery("<button/>", {class:"cr-upload-images-delete"});
removeButton.append('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><rect x="0" fill="none" width="20" height="20"/><g><path class="cr-no-icon" d="M12.12 10l3.53 3.53-2.12 2.12L10 12.12l-3.54 3.54-2.12-2.12L7.88 10 4.34 6.46l2.12-2.12L10 7.88l3.54-3.53 2.12 2.12z"/></g></svg>'
);
container.append(removeButton
);
container.append(jQuery("<input>", {name:"cr-upload-images-ids[]",type:"hidden",value:""})
);
container.append(jQuery("<span/>", {class:"cr-upload-images-delete-spinner"})
);
mediaPreview.find(".cr-form-item-media-add").remove();
mediaPreview.append(container);
if(countFiles + countUploaded < cr_ajax_object.cr_images_upload_limit){
mediaPreview.append(jQuery("<div class='cr-form-item-media-add'>+</div>")
);
}}
}
if(0 < mediaPreview.children(".cr-upload-images-containers").length&&! mediaPreview.hasClass("cr-form-visible") ){
mediaPreview.parents(".cr-form-item-subcontainer").addClass("cr-form-visible");
}
for(let i=0; i < countFiles; i++){
let formData=new FormData();
formData.append("action", "cr_upload_media");
formData.append("cr_file", uploadFiles[0].files[i]);
formData.append("cr_item", jQuery(this).closest(".cr-review-form-wrap").find(".cr-review-form-item-id").val());
var currentFileInput=jQuery(this);
jQuery.ajax({
url: cr_ajax_object.ajax_url,
data: formData,
processData: false,
contentType: false,
dataType: "json",
type: "POST",
context: this,
beforeSend: function(){
},
xhr: function(){
var myXhr=jQuery.ajaxSettings.xhr();
if(myXhr.upload){
myXhr.upload.addEventListener('progress', function(e){
if(e.lengthComputable){
let perc=(e.loaded / e.total) * 100;
perc=perc.toFixed(0);
currentFileInput.parent().find(".cr-form-item-media-preview .cr-upload-images-containers.cr-upload-images-container-" + (lastIndex + i) + " .cr-upload-images-pbar .cr-upload-images-pbarin").width(perc + "%");
}}, false);
}
return myXhr;
},
success: function(response){
if(200===response["code"]){
let idkey=JSON.stringify({ "id": response["attachment"]["id"], "key": response["attachment"]["key"] });
currentFileInput.parent().find(".cr-form-item-media-preview .cr-upload-images-containers.cr-upload-images-container-" + (lastIndex + i) + " input").val(idkey);
currentFileInput.parent().find(".cr-form-item-media-preview .cr-upload-images-containers.cr-upload-images-container-" + (lastIndex + i)).addClass("cr-upload-ok");
}else if(500 <=response["code"]){
currentFileInput.parent().find(".cr-form-item-media-preview .cr-upload-images-containers.cr-upload-images-container-" + (lastIndex + i)).remove();
let mediaPreview=jQuery(this).closest(".cr-form-item-media").find(".cr-form-item-media-preview");
let countUploaded=mediaPreview.find(".cr-upload-images-containers").length;
if(0 < countUploaded){
if(0===mediaPreview.children(".cr-form-item-media-add").length){
mediaPreview.append(jQuery("<div class='cr-form-item-media-add'>+</div>")
);
}}else{
mediaPreview.removeClass("cr-form-visible");
mediaPreview.parents(".cr-form-item-subcontainer").removeClass("cr-form-visible");
}
jQuery(this).closest(".cr-form-item-media").addClass("cr-review-form-error");
jQuery(this).closest(".cr-form-item-media").find(".cr-review-form-field-error").text(response["message"]);
}}
});
}
jQuery(this).attr("data-lastindex", lastIndex + countFiles);
uploadFiles.val("");
});
jQuery(".cr-review-form-wrap .cr-form-item-media-preview").on("click", ".cr-upload-images-delete", function (e){
e.preventDefault();
let imgContainer=jQuery(this).parent(),
mediaPreview=imgContainer.parent();
let ajaxData={
"action": "cr_delete_media",
"image": jQuery(this).parent().children("input").eq(0).val()
}
imgContainer.addClass("cr-upload-delete-pending");
jQuery.post(cr_ajax_object.ajax_url, ajaxData, function(response){
imgContainer.removeClass("cr-upload-delete-pending");
if(200===response["code"]){
imgContainer.remove();
let countUploaded=mediaPreview.children(".cr-upload-images-containers").length;
if(0 < countUploaded){
if(0===mediaPreview.children(".cr-form-item-media-add").length){
mediaPreview.append(jQuery("<div class='cr-form-item-media-add'>+</div>")
);
}}else{
mediaPreview.removeClass("cr-form-visible");
mediaPreview.parents(".cr-form-item-subcontainer").removeClass("cr-form-visible");
}}
}, "json");
});
cr_maybe_download_media_frontend();
if("object"===typeof elementorFrontend&&"hooks" in elementorFrontend){
elementorFrontend.hooks.addAction("frontend/element_ready/widget", function($scope){
if(-1!==$scope.data("widget_type").indexOf("shortcode") ){
if(0 < $scope.find(".cr-reviews-grid-inner").length){
crResizeAllGridItems();
}}
});
}});
const crValidateEmail=(email)=> {
return email.match(/^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/
);
};
function initVoteClick(sel1, sel2, action){
jQuery(sel1).on("click", sel2, function(e){
e.preventDefault();
let reviewIDhtml=jQuery(this).data("vote");
let parent=jQuery(this).parents(".cr-voting-cont-uni");
if(reviewIDhtml!=null){
let reviewID=reviewIDhtml;
let data={
"action": action,
"reviewID": reviewID,
"upvote": jQuery(this).data("upvote")
};
parent.find(".cr-voting-a").removeClass("cr-voting-active");
parent.find(".cr-voting-a").addClass("cr-voting-update");
jQuery.post(cr_ajax_object.ajax_url, data, function(response){
parent.find(".cr-voting-a").removeClass("cr-voting-update");
if(response.code===0){
if(response.votes){
parent.find(".cr-voting-upvote-count").text("(" +  response.votes.upvotes + ")");
parent.find(".cr-voting-downvote-count").text("(" +  response.votes.downvotes + ")");
}
if(0!==response.votes.current){
if(0 < response.votes.current){
parent.find(".cr-voting-upvote").addClass("cr-voting-active");
}else{
parent.find(".cr-voting-downvote").addClass("cr-voting-active");
}}
}}, "json");
}});
}
function cr_keyup_delay(fn, ms){
let timer=0;
return function(...args){
clearTimeout(timer);
timer=setTimeout(fn.bind(this, ...args), ms||0);
};}
function cr_filter_all_reviews(refElement, show_more=false){
let attributes=refElement.parents(".cr-all-reviews-shortcode").data("attributes"),
cr_rating=refElement.parents(".cr-all-reviews-shortcode").find(".ivole-summaryBox .ivole-histogramRow.ivole-histogramRow-s .cr-histogram-a").attr("data-rating"),
cr_search=refElement.parents(".cr-all-reviews-shortcode").find(".cr-ajax-search input").val(),
cr_sort=refElement.parents(".cr-all-reviews-shortcode").find(".cr-ajax-reviews-sort").children("option:selected").val();
let cr_tags=[];
refElement.parents(".cr-all-reviews-shortcode").find(".cr-review-tags-filter .cr-tags-filter.cr-tag-selected").each(function(){
cr_tags.push(jQuery(this).attr("data-crtagid"));
}
);
let cr_data={
"action": "cr_show_more_all_reviews",
"attributes": attributes,
"rating": cr_rating,
"page": 0,
"search": cr_search,
"sort": cr_sort,
"tags": cr_tags
};
if(show_more){
cr_data.page=refElement.data("page");
jQuery(".cr-search-no-reviews").hide();
jQuery('.cr-show-more-button').hide();
if(refElement.hasClass("cr-page-numbers-a") ){
refElement.closest(".cr-all-reviews-shortcode").find(".commentlist").addClass("cr-pagination-load");
refElement.closest(".cr-all-reviews-shortcode").find(".cr-all-reviews-pagination").addClass("cr-pagination-load");
}else{
refElement.closest(".cr-all-reviews-shortcode").find(".cr-show-more-review-spinner").show();
}
jQuery.post({
url: cr_ajax_object.ajax_url,
data: cr_data,
context: refElement,
success: function(response){
let shcode=jQuery(this).closest(".cr-all-reviews-shortcode");
shcode.find(".cr-show-more-review-spinner").hide();
if(response.html!==""){
if(jQuery(this).hasClass("cr-page-numbers-a") ){
shcode.find(".commentlist").find("*").not(".cr-pagination-review-spinner").remove();
shcode.find(".commentlist").prepend(response.html);
}else{
shcode.find(".commentlist").append(response.html);
}
if(! response.last_page){
shcode.find(".cr-show-more-button").text(response.show_more_label);
shcode.find(".cr-show-more-button").show();
}
shcode.find(".cr-show-more-button").data("page", response.page);
shcode.find(".cr-count-row .cr-count-row-count").html(response.count_row);
if(response.pagination!==""){
shcode.find(".cr-all-reviews-pagination").html(response.pagination);
}}else{
shcode.find(".cr-show-more-button").hide();
}
if(response.html==""&&response.page===1){
shcode.find(".cr-search-no-reviews").show();
}
shcode.find(".commentlist").removeClass("cr-pagination-load");
shcode.find(".cr-all-reviews-pagination").removeClass("cr-pagination-load");
},
dataType: "json"
}
);
}else{
refElement.closest(".cr-all-reviews-shortcode").find(".cr-search-no-reviews").hide();
refElement.closest(".cr-all-reviews-shortcode").find(".cr-show-more-button").hide();
refElement.closest(".cr-all-reviews-shortcode").find(".commentlist").hide();
refElement.closest(".cr-all-reviews-shortcode").find(".cr-show-more-review-spinner").show();
refElement.closest(".cr-all-reviews-shortcode").find(".ivole-summaryBox").addClass("cr-summaryBar-updating");
refElement.closest(".cr-all-reviews-shortcode").find(".cr-seeAllReviews").addClass("cr-seeAll-updating");
refElement.closest(".cr-all-reviews-shortcode").find(".cr-ajax-reviews-sort").addClass("cr-sort-updating");
refElement.closest(".cr-all-reviews-shortcode").find(".cr-review-tags-filter").addClass("cr-tags-updating");
refElement.closest(".cr-all-reviews-shortcode").find(".cr-all-reviews-pagination").hide();
jQuery.post({
url: cr_ajax_object.ajax_url,
data: cr_data,
context: refElement,
success: function(response){
let shcode=jQuery(this).closest(".cr-all-reviews-shortcode");
shcode.find(".cr-show-more-review-spinner").hide();
shcode.find(".ivole-summaryBox").removeClass("cr-summaryBar-updating");
shcode.find(".cr-seeAllReviews").removeClass("cr-seeAll-updating");
shcode.find(".cr-ajax-reviews-sort").removeClass("cr-sort-updating");
shcode.find(".cr-review-tags-filter").removeClass("cr-tags-updating");
if(response.html!==""){
shcode.find(".commentlist").empty();
shcode.find(".commentlist").append(response.html);
shcode.find(".commentlist").show();
shcode.find(".cr-show-more-button").data("page",response.page);
if(!response.last_page){
shcode.find(".cr-show-more-button").text(response.show_more_label);
shcode.find(".cr-show-more-button").show();
}}else{
shcode.find(".cr-search-no-reviews").show();
}
shcode.find(".cr-count-row .cr-count-row-count").html(response.count_row);
shcode.find(".cr-all-reviews-pagination").html(response.pagination);
shcode.find(".cr-all-reviews-pagination").show();
},
dataType: "json"
}
);
}}
function cr_maybe_download_media_frontend(){
jQuery(".cr-comment-image-ext,.cr-comment-video-ext").each(function(){
let ajaxData={
"action": "cr_auto_download_media_frontend",
"reviewID": jQuery(this).data("reviewid")
}
jQuery.post(cr_ajax_object.ajax_url, ajaxData, function(response){
}, "json");
return false;
});
}
function cr_validate_review_form(submitBtn){
let validationResult=true;
submitBtn.closest(".cr-review-form-wrap").find(".cr-review-form-rating-cont.cr-review-form-rating-req").each(function(index){
if(1 > jQuery(this).find(".cr-review-form-rating-actv").length){
jQuery(this).closest(".cr-review-form-rating").addClass("cr-review-form-error");
validationResult=false;
}});
if(1 > submitBtn.closest(".cr-review-form-wrap").find(".cr-review-form-comment-txt").val().trim().length){
submitBtn.closest(".cr-review-form-wrap").find(".cr-review-form-comment").addClass("cr-review-form-error");
validationResult=false;
}
if(1 > submitBtn.closest(".cr-review-form-wrap").find(".cr-review-form-name .cr-review-form-txt").val().trim().length){
submitBtn.closest(".cr-review-form-wrap").find(".cr-review-form-name").addClass("cr-review-form-error");
validationResult=false;
}
if(! crValidateEmail(submitBtn.closest(".cr-review-form-wrap").find(".cr-review-form-email .cr-review-form-txt").val().trim()) ){
submitBtn.closest(".cr-review-form-wrap").find(".cr-review-form-email").addClass("cr-review-form-error");
validationResult=false;
}
submitBtn.closest(".cr-review-form-wrap").find(".cr-onsite-question.cr-review-form-que-req").each(function(index){
if(0 < jQuery(this).find("input[type=text]").length){
if(1 > jQuery(this).find("input[type=text]").val().trim().length){
jQuery(this).closest(".cr-onsite-question").addClass("cr-review-form-error");
validationResult=false;
}else{
jQuery(this).closest(".cr-onsite-question").removeClass("cr-review-form-error");
}}
if(0 < jQuery(this).find("input[type=number]").length){
if(1 > jQuery(this).find("input[type=number]").val().trim().length){
jQuery(this).closest(".cr-onsite-question").addClass("cr-review-form-error");
validationResult=false;
}else{
jQuery(this).closest(".cr-onsite-question").removeClass("cr-review-form-error");
}}
});
if(0 < submitBtn.closest(".cr-review-form-wrap").find('.cr-review-form-terms').length){
if(! submitBtn.closest(".cr-review-form-wrap").find('.cr-review-form-terms .cr-review-form-checkbox').is(':checked')){
submitBtn.closest(".cr-review-form-wrap").find(".cr-review-form-terms").addClass("cr-review-form-error");
validationResult=false;
}}
if(0 < submitBtn.closest(".cr-review-form-wrap").find('.cr-review-form-captcha .cr-recaptcha').length){
if(grecaptcha){
let widgetId=0;
if(0 < jQuery(".cr-review-form-captcha .cr-recaptcha").length){
jQuery(".cr-review-form-captcha .cr-recaptcha").each(function(index){
if(submitBtn.closest('.cr-review-form-wrap').find('.cr-review-form-captcha .cr-recaptcha').data('crcaptchaid')===jQuery(this).data('crcaptchaid')
){
widgetId=index;
}}
);
}
let captchaCheck="";
if(0 < widgetId){
captchaCheck=grecaptcha.getResponse(widgetId);
}else{
captchaCheck=grecaptcha.getResponse();
}
if(! captchaCheck.length > 0){
submitBtn.closest(".cr-review-form-wrap").find(".cr-review-form-captcha").addClass("cr-review-form-error");
validationResult=false;
}}
}
return validationResult;
}
function cr_validate_qna(submitBtn){
let validationResult=true;
if(1 > submitBtn.closest(".cr-qna-new-q-form").find(".cr-review-form-comment-txt").val().trim().length){
submitBtn.closest(".cr-qna-new-q-form").find(".cr-review-form-comment").addClass("cr-review-form-error");
validationResult=false;
}
if(1 > submitBtn.closest(".cr-qna-new-q-form").find(".cr-review-form-name .cr-review-form-txt").val().trim().length){
submitBtn.closest(".cr-qna-new-q-form").find(".cr-review-form-name").addClass("cr-review-form-error");
validationResult=false;
}
if(! crValidateEmail(submitBtn.closest(".cr-qna-new-q-form").find(".cr-review-form-email .cr-review-form-txt").val().trim()) ){
submitBtn.closest(".cr-qna-new-q-form").find(".cr-review-form-email").addClass("cr-review-form-error");
validationResult=false;
}
if(0 < submitBtn.closest(".cr-qna-new-q-form").find('.cr-review-form-terms').length){
if(! submitBtn.closest(".cr-qna-new-q-form").find('.cr-review-form-terms .cr-review-form-checkbox').is(':checked')){
submitBtn.closest(".cr-qna-new-q-form").find(".cr-review-form-terms").addClass("cr-review-form-error");
validationResult=false;
}}
return validationResult;
}
function cr_validate_ans(submitBtn){
let validationResult=true;
if(1 > submitBtn.closest(".cr-qna-list-inl-answ").find(".cr-review-form-comment-txt").val().trim().length){
submitBtn.closest(".cr-qna-list-inl-answ").find(".cr-review-form-comment").addClass("cr-review-form-error");
validationResult=false;
}
if(1 > submitBtn.closest(".cr-qna-list-inl-answ").find(".cr-review-form-name .cr-review-form-txt").val().trim().length){
submitBtn.closest(".cr-qna-list-inl-answ").find(".cr-review-form-name").addClass("cr-review-form-error");
validationResult=false;
}
if(! crValidateEmail(submitBtn.closest(".cr-qna-list-inl-answ").find(".cr-review-form-email .cr-review-form-txt").val().trim()) ){
submitBtn.closest(".cr-qna-list-inl-answ").find(".cr-review-form-email").addClass("cr-review-form-error");
validationResult=false;
}
if(0 < submitBtn.closest(".cr-qna-list-inl-answ").find('.cr-review-form-terms').length){
if(! submitBtn.closest(".cr-qna-list-inl-answ").find('.cr-review-form-terms .cr-review-form-checkbox').is(':checked')){
submitBtn.closest(".cr-qna-list-inl-answ").find(".cr-review-form-terms").addClass("cr-review-form-error");
validationResult=false;
}}
return validationResult;
}
function cr_reset_review_form(refElement){
refElement.closest(".cr-review-form-wrap").find(".cr-review-form-rating-cont .cr-review-form-rating-inner").removeClass("cr-review-form-rating-actv");
refElement.closest(".cr-review-form-wrap").find(".cr-review-form-rating-cont .cr-review-form-rating-inner .cr-rating-act").hide();
refElement.closest(".cr-review-form-wrap").find(".cr-review-form-rating-cont .cr-review-form-rating-inner .cr-rating-deact").show();
refElement.closest(".cr-review-form-wrap").find(".cr-review-form-rating-cont .cr-review-form-rating-nbr").text("0/5");
refElement.closest(".cr-review-form-wrap").find(".cr-review-form-rating").removeClass("cr-review-form-error");
refElement.closest(".cr-review-form-wrap").find(".cr-review-form-comment-txt").val('');
refElement.closest(".cr-review-form-wrap").find(".cr-review-form-comment").removeClass("cr-review-form-error");
refElement.closest(".cr-review-form-wrap").find(".cr-review-form-name .cr-review-form-txt").val('');
refElement.closest(".cr-review-form-wrap").find(".cr-review-form-name").removeClass("cr-review-form-error");
refElement.closest(".cr-review-form-wrap").find(".cr-review-form-email .cr-review-form-txt").val('');
refElement.closest(".cr-review-form-wrap").find(".cr-review-form-email").removeClass("cr-review-form-error");
refElement.closest(".cr-review-form-wrap").find(".cr-onsite-questions .cr-onsite-question").removeClass("cr-review-form-error");
refElement.closest(".cr-review-form-wrap").find(".cr-onsite-questions .cr-onsite-question input[type='text']").val('');
refElement.closest(".cr-review-form-wrap").find(".cr-onsite-questions .cr-onsite-question input[type='number']").val('');
refElement.closest(".cr-review-form-wrap").find(".cr-onsite-key-question").removeClass("cr-review-form-error");
refElement.closest(".cr-review-form-wrap").find(".cr-onsite-key-question input[type='text']").val('');
refElement.closest(".cr-review-form-wrap").find(".cr-onsite-key-question input[type='number']").val('');
refElement.closest(".cr-review-form-wrap").find(".cr-form-item-media .cr-upload-images-containers").remove();
refElement.closest(".cr-review-form-wrap").find(".cr-form-item-media .cr-form-item-media-preview").removeClass("cr-form-visible");
refElement.closest(".cr-review-form-wrap").find(".cr-form-item-media .cr-form-item-media-preview").parents(".cr-form-item-subcontainer").removeClass("cr-form-visible");
refElement.closest(".cr-review-form-wrap").find(".cr-review-form-terms .cr-review-form-checkbox").prop('checked', false);
refElement.closest(".cr-review-form-wrap").find(".cr-review-form-terms").removeClass("cr-review-form-error");
refElement.closest(".cr-review-form-wrap").find(".cr-review-form-captcha").removeClass("cr-review-form-error");
}
function cr_reset_qna_form(refElement){
refElement.closest(".cr-qna-new-q-form").find(".cr-review-form-comment-txt").val('');
refElement.closest(".cr-qna-new-q-form").find(".cr-review-form-comment").removeClass("cr-review-form-error");
const nameField=refElement.closest(".cr-qna-new-q-form").find(".cr-review-form-name");
nameField.find(".cr-review-form-txt").val(nameField.find(".cr-review-form-txt").data('defval'));
nameField.removeClass("cr-review-form-error");
const emailField=refElement.closest(".cr-qna-new-q-form").find(".cr-review-form-email");
emailField.find(".cr-review-form-txt").val(emailField.find(".cr-review-form-txt").data('defval'));
emailField.removeClass("cr-review-form-error");
refElement.closest(".cr-qna-new-q-form").find(".cr-review-form-terms .cr-review-form-checkbox").prop('checked', false);
refElement.closest(".cr-qna-new-q-form").find(".cr-review-form-terms").removeClass("cr-review-form-error");
}
function cr_reset_ans_form(refElement){
refElement.closest(".cr-qna-list-inl-answ").find(".cr-review-form-comment-txt").val("");
refElement.closest(".cr-qna-list-inl-answ").find(".cr-review-form-comment").removeClass("cr-review-form-error");
const nameField=refElement.closest(".cr-qna-list-inl-answ").find(".cr-review-form-name");
nameField.find(".cr-review-form-txt").val("");
nameField.removeClass("cr-review-form-error");
const emailField=refElement.closest(".cr-qna-list-inl-answ").find(".cr-review-form-email");
emailField.find(".cr-review-form-txt").val("");
emailField.removeClass("cr-review-form-error");
refElement.closest(".cr-qna-list-inl-answ").find(".cr-review-form-terms .cr-review-form-checkbox").prop('checked', false);
refElement.closest(".cr-qna-list-inl-answ").find(".cr-review-form-terms").removeClass("cr-review-form-error");
}
function crDebounce(callback, wait){
let timeout;
return (...args)=> {
clearTimeout(timeout);
if(0 < args.length&&13===args[0].keyCode){
wait=0;
}else{
wait=1000;
}
timeout=setTimeout(function (){ callback.apply(this, args); }, wait);
};}
function crShowMoreReviewsPrd(refElement){
let cr_product_id=refElement.parents(".cr-reviews-ajax-comments").find(".commentlist.cr-ajax-reviews-list").attr("data-product");
let cr_nonce=refElement.parents(".cr-reviews-ajax-comments").attr("data-nonce");
let cr_page=refElement.parents(".cr-reviews-ajax-comments").attr("data-page");
let cr_sort=refElement.parents(".cr-reviews-ajax-comments").find(".cr-ajax-reviews-sort").children("option:selected").val();
let cr_rating=refElement.parents(".cr-reviews-ajax-comments").find(".cr-summaryBox-ajax tr.ivole-histogramRow.ivole-histogramRow-s a.ivole-histogram-a").attr("data-rating");
let cr_search=refElement.parents(".cr-reviews-ajax-comments").find(".cr-ajax-search input").val();
let cr_tags=[];
refElement.parents(".cr-reviews-ajax-comments").find(".cr-review-tags-filter .cr-tags-filter.cr-tag-selected").each(function(){
cr_tags.push(jQuery(this).attr("data-crtagid"));
}
);
if(! cr_rating){
cr_rating=0;
}
let cr_data={
"action": "cr_show_more_reviews",
"productID": cr_product_id,
"page": cr_page,
"sort": cr_sort,
"rating": cr_rating,
"search": cr_search,
"tags": cr_tags,
"security": cr_nonce
};
refElement.parents(".cr-reviews-ajax-comments").find(".cr-summaryBox-ajax").addClass("cr-summaryBar-updating");
refElement.parents(".cr-reviews-ajax-comments").find(".cr-ajax-reviews-sort").addClass("cr-sort-updating");
refElement.parents(".cr-reviews-ajax-comments").find(".cr-review-tags-filter").addClass("cr-review-tags-filter-disabled");
refElement.parents(".cr-reviews-ajax-comments").find(".cr-search-no-reviews").hide();
refElement.parents(".cr-reviews-ajax-comments").find(".cr-show-more-reviews-prd").hide();
refElement.parents(".cr-reviews-ajax-comments").find(".cr-show-more-review-spinner").show();
jQuery.post({
url: cr_ajax_object.ajax_url,
data: cr_data,
context: refElement,
success: function(response){
jQuery(this).parents(".cr-reviews-ajax-comments").find(".cr-show-more-review-spinner").hide();
jQuery(this).parents(".cr-reviews-ajax-comments").find(".cr-summaryBox-ajax").removeClass("cr-summaryBar-updating");
jQuery(this).parents(".cr-reviews-ajax-comments").find(".cr-ajax-reviews-sort").removeClass("cr-sort-updating");
jQuery(this).parents(".cr-reviews-ajax-comments").find(".cr-review-tags-filter").removeClass("cr-review-tags-filter-disabled");
if(response.page > 0){
jQuery(this).parents(".cr-reviews-ajax-comments").find(".commentlist.cr-ajax-reviews-list").append(response.html);
jQuery(this).parents(".cr-reviews-ajax-comments").attr("data-page",response.page);
if(response.show_more_label){
jQuery(this).parents(".cr-reviews-ajax-comments").find(".cr-show-more-reviews-prd").text(response.show_more_label);
}
if(response.count_row){
jQuery(this).parents(".cr-reviews-ajax-comments").find(".cr-count-row .cr-count-row-count").html(response.count_row);
}
if(! response.last_page){
jQuery(this).parents(".cr-reviews-ajax-comments").find(".cr-show-more-reviews-prd").show();
}
cr_maybe_download_media_frontend();
}
if(response.html==null&&response.page===1){
jQuery(this).parents(".cr-reviews-ajax-comments").find(".cr-search-no-reviews").show();
}},
dataType: "json"
});
}})();
function crResizeAllGridItemsUtil(grids){
jQuery(grids).each(function(){
if(800 > jQuery(this).width()){
jQuery(this).find(".cr-reviews-grid-col3").addClass("cr-reviews-grid-col-none");
}
if(550 > jQuery(this).width()){
jQuery(this).find(".cr-reviews-grid-col2").addClass("cr-reviews-grid-col-none");
}
jQuery(this).colcade({
columns: ".cr-reviews-grid-col",
items: ".cr-review-card"
});
});
}
function crResizeAllGridItems(){
if(typeof Colcade!=="undefined" &&
typeof Colcade.makeJQueryPlugin!=="undefined" &&
typeof Colcade.makeJQueryPlugin==="function"
){
if(! typeof jQuery.fn.colcade==="function" ||
typeof jQuery.fn.colcade==="undefined"
){
Colcade.makeJQueryPlugin();
}}
crResizeAllGridItemsUtil(jQuery(".cr-reviews-grid-inner"));
}
function crResizeTrustBadges(){
jQuery(".cr-trustbadgef").each(function(){
let badge=jQuery(this).find(".cr-badge").eq(0);
let scale=jQuery(this).width() / badge.outerWidth();
if(1 > scale){
badge.css("transform", "scale(" + scale + ")");
}
badge.css("visibility", "visible");
});
};
(function(window, factory){
if(typeof define=='function'&&define.amd){
define(factory);
}else if(typeof module=='object'&&module.exports){
module.exports=factory();
}else{
window.Colcade=factory();
}}(window, function factory(){
function Colcade(element, options){
element=getQueryElement(element);
if(element&&element.colcadeGUID){
var instance=instances[ element.colcadeGUID ];
instance.option(options);
return instance;
}
this.element=element;
this.options={};
this.option(options);
this.lastAppend=[];
this.lastColumnHeights=[];
this.create();
element.classList.add('cr-colcade-loaded');
}
var proto=Colcade.prototype;
proto.option=function(options){
this.options=extend(this.options, options);
};
var GUID=0;
var instances={};
proto.create=function(){
this.errorCheck();
var guid=this.guid=++GUID;
this.element.colcadeGUID=guid;
instances[ guid ]=this;
this.reload();
this._windowResizeHandler=this.onWindowResize.bind(this);
this._loadHandler=this.onLoad.bind(this);
window.addEventListener('resize', this._windowResizeHandler);
this.element.addEventListener('load', this._loadHandler, true);
};
proto.errorCheck=function(){
var errors=[];
if(!this.element){
errors.push('Bad element: ' + this.element);
}
if(!this.options.columns){
errors.push('columns option required: ' + this.options.columns);
}
if(!this.options.items){
errors.push('items option required: ' + this.options.items);
}
if(errors.length){
throw new Error('[Colcade error] ' + errors.join('. '));
}};
proto.reload=function(){
this.updateColumns();
this.updateItems();
this.layout();
};
proto.updateColumns=function(){
this.columns=querySelect(this.options.columns, this.element);
};
proto.updateItems=function(){
this.items=querySelect(this.options.items, this.element);
};
proto.getActiveColumns=function(){
return this.columns.filter(function(column){
var style=getComputedStyle(column);
return style.display!='none';
});
};
proto.layout=function(){
this.activeColumns=this.getActiveColumns();
this._layout();
};
proto._layout=function(){
this.columnHeights=this.activeColumns.map(function(){
return 0;
});
this.layoutItems(this.items);
};
proto.layoutItems=function(items){
items.forEach(this.layoutItem, this);
};
proto.layoutItem=function(item){
var minHeight=Math.min.apply(Math, this.columnHeights);
var index=this.columnHeights.indexOf(minHeight);
this.activeColumns[ index ].appendChild(item);
this.columnHeights[ index ] +=item.offsetHeight||1;
};
proto.append=function(elems){
var items=this.getQueryItems(elems);
this.items=this.items.concat(items);
this.lastAppend.length=0;
this.lastAppend=items.slice();
this.lastColumnHeights.length=0;
this.lastColumnHeights=this.columnHeights.slice();
this.layoutItems(items);
};
proto.prepend=function(elems){
var items=this.getQueryItems(elems);
this.items=items.concat(this.items);
this._layout();
};
proto.getQueryItems=function(elems){
elems=makeArray(elems);
var fragment=document.createDocumentFragment();
elems.forEach(function(elem){
fragment.appendChild(elem);
});
return querySelect(this.options.items, fragment);
};
proto.empty=function(){
this.lastAppend.length=0;
this.lastColumnHeights.length=0;
this.items.forEach(function(item){
item.remove();
}, this);
this.items.length=0;
this._layout();
};
proto.measureColumnHeight=function(elem){
var boundingRect=this.element.getBoundingClientRect();
this.activeColumns.forEach(function(column, i){
if(!elem||column.contains(elem) ){
var lastChildRect=column.lastElementChild.getBoundingClientRect();
this.columnHeights[ i ]=lastChildRect.bottom - boundingRect.top;
}}, this);
};
proto.onWindowResize=function(){
clearTimeout(this.resizeTimeout);
this.resizeTimeout=setTimeout(function(){
this.onDebouncedResize();
}.bind(this), 100);
};
proto.onDebouncedResize=function(){
var activeColumns=this.getActiveColumns();
var isSameLength=activeColumns.length==this.activeColumns.length;
var isSameColumns=true;
this.activeColumns.forEach(function(column, i){
isSameColumns=isSameColumns&&column==activeColumns[i];
});
if(isSameLength&&isSameColumns){
return;
}
this.activeColumns=activeColumns;
this._layout();
};
proto.onLoad=function(event){
this.measureColumnHeight(event.target);
if(0 < this.lastColumnHeights.length&&0 < this.lastAppend.length){
this.columnHeights.length=0;
this.columnHeights=this.lastColumnHeights.slice();
this.layoutItems(this.lastAppend);
}};
proto.destroy=function(){
this.items.forEach(function(item){
this.element.appendChild(item);
}, this);
window.removeEventListener('resize', this._windowResizeHandler);
this.element.removeEventListener('load', this._loadHandler, true);
delete this.element.colcadeGUID;
delete instances[ this.guid ];
};
docReady(function(){
var dataElems=querySelect('[data-colcade]');
dataElems.forEach(htmlInit);
});
function htmlInit(elem){
var attr=elem.getAttribute('data-colcade');
var attrParts=attr.split(',');
var options={};
attrParts.forEach(function(part){
var pair=part.split(':');
var key=pair[0].trim();
var value=pair[1].trim();
options[ key ]=value;
});
new Colcade(elem, options);
}
Colcade.data=function(elem){
elem=getQueryElement(elem);
var id=elem&&elem.colcadeGUID;
return id&&instances[ id ];
};
Colcade.makeJQueryPlugin=function($){
$=$||window.jQuery;
if(!$){
return;
}
$.fn.colcade=function(arg0 ){
if(typeof arg0=='string'){
var args=Array.prototype.slice.call(arguments, 1);
return methodCall(this, arg0, args);
}
plainCall(this, arg0);
return this;
};
function methodCall($elems, methodName, args){
var returnValue;
$elems.each(function(i, elem){
var colcade=$.data(elem, 'colcade');
if(!colcade){
return;
}
var value=colcade[ methodName ].apply(colcade, args);
returnValue=returnValue===undefined ? value:returnValue;
});
return returnValue!==undefined ? returnValue:$elems;
}
function plainCall($elems, options){
$elems.each(function(i, elem){
var colcade=$.data(elem, 'colcade');
if(colcade){
colcade.option(options);
colcade.layout();
}else{
colcade=new Colcade(elem, options);
$.data(elem, 'colcade', colcade);
}});
}};
Colcade.makeJQueryPlugin();
function extend(a, b){
for(var prop in b){
a[ prop ]=b[ prop ];
}
return a;
}
function makeArray(obj){
var ary=[];
if(Array.isArray(obj) ){
ary=obj;
}else if(obj&&typeof obj.length=='number'){
for(var i=0; i < obj.length; i++){
ary.push(obj[i]);
}}else{
ary.push(obj);
}
return ary;
}
function querySelect(selector, elem){
elem=elem||document;
var elems=elem.querySelectorAll(selector);
return makeArray(elems);
}
function getQueryElement(elem){
if(typeof elem=='string'){
elem=document.querySelector(elem);
}
return elem;
}
function docReady(onReady){
if(document.readyState=='complete'){
onReady();
return;
}
document.addEventListener('DOMContentLoaded', onReady);
}
return Colcade;
}));
!function(u){"use strict";u(".js-accordion-item").removeClass("no-js"),u.fn.accordionBlockItem=function(o){var n=u.extend({initiallyOpen:!1,autoClose:!0,clickToClose:!0,scroll:!1,scrollOffset:!1},o),t=250,c=window.location.hash.replace("#",""),e={};function i(o){return u(o).children(".js-accordion-controller").attr("id").replace("at-","")}function s(){r(),e.content.clearQueue().stop().slideDown(t,function(){n.scroll&&setTimeout(function(){u("html, body").animate({scrollTop:e.self.offset().top-n.scrollOffset},t)},t)}),u(document).trigger("openAccordionItem",e)}function r(){e.self.addClass("is-open is-read"),e.controller.attr("aria-expanded",!0),e.content.prop("hidden",!1)}function l(){e.content.slideUp(t,function(){a()})}function a(){e.self.removeClass("is-open"),e.controller.attr("aria-expanded",!1),e.content.attr("hidden",!0)}function d(){n.autoClose&&e.self.hasClass("is-open")&&l()}return e.self=u(this),e.id=u(this).attr("id"),e.controller=u(this).children(".js-accordion-controller"),e.uuid=i(e.self),e.content=u("#ac-"+e.uuid),e.accordionGroupItems=[e.uuid],e.accordionAncestorItems=[],e.controller.attr({tabindex:0,"aria-controls":"ac-"+e.uuid}),n.scrollOffset=Math.floor(parseInt(n.scrollOffset,10))||0,u.each(e.self.siblings(".js-accordion-item"),function(o,n){var t=i(n);e.accordionGroupItems.push(t)}),u.each(e.self.parents(".js-accordion-item"),function(o,n){var t=i(n);e.accordionAncestorItems.push(t)}),n.initiallyOpen?r():e.id===c?(s(),u.each(e.accordionAncestorItems,function(o,n){u(document).trigger("openAncestorAccordionItem",n)})):a(),e.controller.on("click",function(){return e.self.hasClass("is-open")?n.clickToClose&&l():s(),!1}),u(document).on("openAccordionItem",function(o,n){n!==e&&0<n.accordionGroupItems.indexOf(e.uuid)&&-1===n.accordionAncestorItems.indexOf(e.uuid)&&d()}),u(document).on("openAncestorAccordionItem",function(o,n){n===e.uuid&&s()}),e.controller.on("keydown",function(o){var n=o.which;"BUTTON"!==e.controller.prop("tagName")&&(13!==n&&32!==n||u(this).click()),27===n&&d()}),u(window).on("hashchange",function(){var o;(c=window.location.hash.replace("#",""))!==e.id||(o=u("#"+c)).length&&o.hasClass("js-accordion-item")&&(s(),u.each(e.accordionAncestorItems,function(o,n){u(document).trigger("openAncestorAccordionItem",n)}))}),this},u(window).on("load",function(){u(".js-accordion-item").each(function(){u(this).accordionBlockItem({initiallyOpen:u(this).data("initially-open"),autoClose:u(this).data("auto-close"),clickToClose:u(this).data("click-to-close"),scroll:u(this).data("scroll"),scrollOffset:u(this).data("scroll-offset")})})})}(jQuery);
function slideUp(e,t){e.style.transitionProperty="height, margin, padding",e.style.transitionDuration=t+"ms",e.style.boxSizing="border-box",e.style.height=e.offsetHeight+"px",e.offsetHeight,e.style.overflow="hidden",e.style.height=0,e.style.paddingTop=0,e.style.paddingBottom=0,e.style.marginTop=0,e.style.marginBottom=0,window.setTimeout(function(){e.style.display="none",e.style.removeProperty("height"),e.style.removeProperty("padding-top"),e.style.removeProperty("padding-bottom"),e.style.removeProperty("margin-top"),e.style.removeProperty("margin-bottom"),e.style.removeProperty("overflow"),e.style.removeProperty("transition-duration"),e.style.removeProperty("transition-property")},t)}function slideDown(e,t){e.style.removeProperty("display");let o=window.getComputedStyle(e).display;"none"===o&&(o="block"),e.style.display=o;var a=e.offsetHeight;e.style.overflow="hidden",e.style.height=0,e.style.paddingTop=0,e.style.paddingBottom=0,e.style.marginTop=0,e.style.marginBottom=0,e.offsetHeight,e.style.boxSizing="border-box",e.style.transitionProperty="height, margin, padding",e.style.transitionDuration=t+"ms",e.style.height=a+"px",e.style.removeProperty("padding-top"),e.style.removeProperty("padding-bottom"),e.style.removeProperty("margin-top"),e.style.removeProperty("margin-bottom"),window.setTimeout(function(){e.style.removeProperty("height"),e.style.removeProperty("overflow"),e.style.removeProperty("transition-duration"),e.style.removeProperty("transition-property")},t)}function setupFAQ(){const e=new RegExp("^[\\w\\-]+$");var t=window.location.hash.substring(1);const o=document.getElementsByClassName("uagb-faq-expand-first-true"),a=document.getElementsByClassName("uagb-faq-inactive-other-false");if(void 0!==document.getElementById(t)&&null!==document.getElementById(t)&&""!==document.getElementById(t)&&e.test(t)){const i=document.getElementById(t);void 0!==i&&(i.classList.add("uagb-faq-item-active"),i.setAttribute("aria-expanded",!0),(t=i.getElementsByClassName("uagb-faq-content")[0])&&slideDown(t,500))}else for(let t=0;t<o.length;t++)if(!0===o[t].classList.contains("uagb-faq-layout-accordion")){let e=o[t].querySelectorAll(".uagb-faq-child__outer-wrap.uagb-faq-item")[0];(e=e||o[t].querySelectorAll(".uagb-faq-child__outer-wrap .uagb-faq-item")[0]).classList.add("uagb-faq-item-active"),e.setAttribute("aria-expanded",!0),e.querySelectorAll(".uagb-faq-content")[0].style.display="block"}for(let e=0;e<a.length;e++)if(!0===a[e].classList.contains("uagb-faq-layout-accordion")){let t=a[e].querySelectorAll(".uagb-faq-child__outer-wrap.uagb-faq-item");t&&0!==t.length||(t=a[e].querySelectorAll(".uagb-faq-child__outer-wrap .uagb-faq-item"));for(let e=0;e<t.length;e++)t[e].classList.add("uagb-faq-item-active"),t[e].setAttribute("aria-expanded",!0),t[e].querySelectorAll(".uagb-faq-content")[0].style.display="block"}}function faqClick(t,o,a){if(13===t.keyCode||32===t.keyCode||0===t.button)if(o.classList.contains("uagb-faq-item-active"))o.classList.remove("uagb-faq-item-active"),o.setAttribute("aria-expanded",!1),slideUp(o.getElementsByClassName("uagb-faq-content")[0],500);else{const i=t.currentTarget.closest(".wp-block-uagb-faq");let e="true";if(i.classList.contains("wp-block-uagb-faq")&&(e=i.getAttribute("data-faqtoggle")),o.classList.add("uagb-faq-item-active"),o.setAttribute("aria-expanded",!0),slideDown(o.getElementsByClassName("uagb-faq-content")[0],500),"true"===e){a=i.querySelectorAll(".uagb-faq-content");for(let e=0;e<a.length;e++){const l=a[e].parentElement;l!==o&&(l.classList.remove("uagb-faq-item-active"),l.setAttribute("aria-expanded",!1),slideUp(l.getElementsByClassName("uagb-faq-content")[0],500))}}}}window.addEventListener("load",function(){setupFAQ();const t=document.getElementsByClassName("uagb-faq-layout-accordion");for(let e=0;e<t.length;e++){const o=t[e].querySelectorAll(".uagb-faq-questions-button"),a=t[e].querySelectorAll(".uagb-faq-item");for(let e=0;e<o.length;e++)o[e].addEventListener("click",function(e){faqClick(e,this.parentElement,o)});for(let e=0;e<a.length;e++)a[e].addEventListener("keyup",function(e){faqClick(e,this,o)})}});
jQuery(document).ready(function($){
var focus_qty;
function open_popup(){
$('.xoo-cp-opac').show();
$('.xoo-cp-modal').addClass('xoo-cp-active');
}
$(document.body).on('added_to_cart',function(){
open_popup();
});
function close_popup(e){
$.each(e.target.classList,function(key,value){
if(value=='xoo-cp-close'||value=='xoo-cp-modal'){
$('.xoo-cp-opac').hide();
$('.xoo-cp-modal').removeClass('xoo-cp-active');
$('.xoo-cp-atcn , .xoo-cp-content').html('');
}})
}
$(document).on('click','.xoo-cp-close , .xoo-cp-modal',close_popup);
function block_popup(){
$('.xoo-cp-outer').show();
}
function unblock_popup(){
$('.xoo-cp-outer').hide();
}
function reset_cart(atc_btn){
$('.xoo-cp-added',atc_btn).remove();
var qty_elem=atc_btn.parents('form.cart').find('.qty');
if(qty_elem.length > 0) qty_elem.val(qty_elem.attr('min')||1);
$('.added_to_cart').remove();
}
function show_notice(notice_type,notice){
$('.xoo-cp-notice').html(notice).attr('class','xoo-cp-notice').addClass('xoo-cp-nt-'+notice_type);
$('.xoo-cp-notice-box').fadeIn('fast');
clearTimeout(fadenotice);
var fadenotice=setTimeout(function(){
$('.xoo-cp-notice-box').fadeOut('slow');
},3000);
};
function add_to_cart(atc_btn,form_data){
$(document.body).trigger('adding_to_cart', [ atc_btn, form_data ]);
$.ajax({
url: xoo_cp_localize.wc_ajax_url.toString().replace('%%endpoint%%', 'xoo_cp_add_to_cart'),
type: 'POST',
data: $.param(form_data),
success: function(response){
$('.xoo-cp-adding',atc_btn).remove();
if(response.fragments){
$(document.body).trigger('added_to_cart', [ response.fragments, response.cart_hash, atc_btn ]);
atc_btn.append('<span class="xoo-cp-icon-check xoo-cp-added"></span>');
}
else if(response.error){
show_notice('error',response.error)
}else{
console.log(response);
}
if(xoo_cp_localize.reset_cart) reset_cart(atc_btn);
}})
}
$(document).on('submit','form.cart',function(e){
var form=$(this);
var atc_btn=form.find('button[type="submit"]');
var form_data=form.serializeArray();
if(atc_btn.attr('name')&&atc_btn.attr('name')=='add-to-cart'&&atc_btn.attr('value')){
form_data.push({ name: 'add-to-cart', value: atc_btn.attr('value') });
}
var is_valid=false;
$.each(form_data, function(index, data){
if(data.name==="add-to-cart"){
is_valid=true;
return false;
}})
if(is_valid){
e.preventDefault();
}else{
return;
}
$('.xoo-cp-added',atc_btn).remove();
atc_btn.append('<span class="xoo-cp-icon-spinner xoo-cp-adding" aria-hidden="true"></span>');
form_data.push({name: 'action', value: 'xoo_cp_add_to_cart'});
add_to_cart(atc_btn,form_data);
})
function xoo_cp_update_ajax(cart_key,new_qty,pid){
return $.ajax({
url: xoo_cp_localize.adminurl,
type: 'POST',
data: {action: 'xoo_cp_change_ajax',
cart_key: cart_key,
new_qty: new_qty,
pid: pid
}})
}
function update_cart(cart_key,new_qty){
block_popup();
$.ajax({
url: xoo_cp_localize.wc_ajax_url.toString().replace('%%endpoint%%', 'xoo_cp_update_cart'),
type: 'POST',
data: {
cart_key: cart_key,
new_qty: new_qty
},
success: function(response){
if(response.fragments){
var fragments=response.fragments,
cart_hash=response.cart_hash;
$.each(response.fragments, function(key, value){
$(key).replaceWith(value);
$(key).stop(true).css('opacity', '1').unblock();
});
if(wc_cart_fragments_params){
var cart_hash_key=wc_cart_fragments_params.ajax_url.toString() + '-wc_cart_hash';
sessionStorage.setItem(wc_cart_fragments_params.fragment_name, JSON.stringify(fragments) );
localStorage.setItem(cart_hash_key, cart_hash);
sessionStorage.setItem(cart_hash_key, cart_hash);
}
$(document.body).trigger('wc_fragments_loaded');
}else{
console.log(response);
}
unblock_popup();
}})
}
$(document).on('focusin','.xoo-cp-qty',function(){
focus_qty=$(this).val();
})
$(document).on('change','.xoo-cp-qty',function(e){
var _this=$(this);
var new_qty=parseFloat($(this).val());
var step=parseFloat($(this).attr('step'));
var min_value=parseFloat($(this).attr('min'));
var max_value=parseFloat($(this).attr('max'));
var invalid=false;
if(new_qty===0){
_this.parents('.xoo-cp-pdetails').find('.xoo-cp-remove-pd').trigger('click');
return;
}
else if(isNaN(new_qty)||new_qty < 0){
invalid=true;
}
else if(new_qty > max_value&&max_value > 0){
alert('Maximum Quantity: '+max_value);
invalid=true;
}
else if(new_qty < min_value){
invalid=true;
}
else if((new_qty % step)!==0){
alert('Quantity can only be purchased in multiple of '+step);
invalid=true;
}else{
var cart_key=$(this).parents('tr').data('xoo_cp_key');
update_cart(cart_key,new_qty);
}
if(invalid===true){
$(this).val(focus_qty);
}})
$(document).on('click', '.xcp-chng' ,function(){
var _this=$(this);
var qty_element=_this.siblings('.xoo-cp-qty');
qty_element.trigger('focusin');
var input_qty=parseFloat(qty_element.val());
var step=parseFloat(qty_element.attr('step'));
var min_value=parseFloat(qty_element.attr('min'));
var max_value=parseFloat(qty_element.attr('max'));
if(_this.hasClass('xcp-plus')){
var new_qty=input_qty + step;
if(new_qty > max_value&&max_value > 0){
alert('Maximum Quantity: '+max_value);
return;
}}
else if(_this.hasClass('xcp-minus')){
var new_qty=input_qty - step;
if(new_qty===0){
_this.parents('.xoo-cp-pdetails').find('.xoo-cp-remove .xcp-icon').trigger('click');
return;
}
else if(new_qty < min_value){
return;
}
else if(input_qty < 0){
alert('Invalid');
return;
}}
var cart_key=$(this).parents('tr').data('xoo_cp_key');
update_cart(cart_key,new_qty);
})
$(document).on('click','.xoo-cp-remove-pd',function(e){
e.preventDefault();
var cart_key=$(this).parents('tr').data('xoo_cp_key');
update_cart(cart_key,0);
})
});
document.addEventListener("DOMContentLoaded",function(){let a=document.getElementById("site-navigation");if(a){let n=a.querySelector("button");if(n){let t=a.querySelector("ul");if(t){n.setAttribute("aria-expanded","false"),t.setAttribute("aria-expanded","false"),t.classList.add("nav-menu"),n.addEventListener("click",function(){a.classList.toggle("toggled");var e=a.classList.contains("toggled")?"true":"false";n.setAttribute("aria-expanded",e),t.setAttribute("aria-expanded",e)});var e=document.getElementsByClassName("handheld-navigation");if(0<e.length&&[].forEach.call(e[0].querySelectorAll(".menu-item-has-children > a, .page_item_has_children > a"),function(e){let t=document.createElement("button"),n=(t.setAttribute("aria-expanded","false"),t.classList.add("dropdown-toggle"),document.createElement("span"));n.classList.add("screen-reader-text"),n.appendChild(document.createTextNode(storefrontScreenReaderText.expand)),t.appendChild(n),e.parentNode.insertBefore(t,e.nextSibling),e.parentNode.classList.contains("current-menu-ancestor")&&(t.setAttribute("aria-expanded","true"),t.classList.add("toggled-on"),t.nextElementSibling.classList.add("toggled-on")),t.addEventListener("click",function(){for(t.classList.toggle("toggled-on");n.firstChild;)n.removeChild(n.firstChild);var e=t.classList.contains("toggled-on");t.setAttribute("aria-expanded",e),n.appendChild(document.createTextNode(e?storefrontScreenReaderText.collapse:storefrontScreenReaderText.expand)),t.nextElementSibling.classList.toggle("toggled-on")})}),[].forEach.call(document.querySelectorAll(".site-header .menu-item > a, .site-header .page_item > a, .site-header-cart a"),function(t){t.addEventListener("focus",function(){var e=document.querySelectorAll(".focus");[].forEach.call(e,function(e){e.contains(t)||(e.classList.remove("focus"),e.firstChild&&e.firstChild.classList&&e.firstChild.classList.remove("blocked"))}),t.parentNode.classList.add("focus")})}),[].forEach.call(document.querySelectorAll("body #page > :not(.site-header)"),function(e){e.addEventListener("click",function(){[].forEach.call(document.querySelectorAll(".focus, .blocked"),function(e){e.classList.remove("focus"),e.classList.remove("blocked")})})}),("ontouchstart"in window||window.navigator.maxTouchPoints)&&767<window.innerWidth){[].forEach.call(document.querySelectorAll(".site-header ul ul, .site-header-cart .widget_shopping_cart"),function(e){e.classList.add("sub-menu--is-touch-device")});let n=!1;[].forEach.call(document.querySelectorAll(".site-header .menu-item > a, .site-header .page_item > a, .site-header-cart a"),function(t){t.addEventListener("click",function(e){t.classList.contains("blocked")&&!1===n&&e.preventDefault(),n=!1}),t.addEventListener("pointerup",function(e){!t.classList.contains("blocked")&&"mouse"!==e.pointerType&&("cart-contents"===t.className&&t.parentNode.nextElementSibling&&""!==t.parentNode.nextElementSibling.textContent.trim()||t.nextElementSibling)?t.classList.add("blocked"):n=!0})})}}else n.style.display="none"}}});