You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1 lines
3.1 KiB
1 lines
3.1 KiB
!function(d){woodmartThemeModule.singleProdReviews=function(){let n=d("#reviews");function r(){let e=d(".wd-rating-summary-cont").find(".wd-active");return 0<e.length?e.find(".wd-rating-label").data("rating").toString():""}function t(e=!1,t=!1){let i=d(".commentlist"),o=0<i.length?i.data("reviews-columns"):{},s={action:"woodmart_filter_review",rating:r(),product_id:n.data("product-id"),order_by:0<n.find(".wd-reviews-sorting-select :checked").length?n.find(".wd-reviews-sorting-select :checked").val():"newest",only_images:d("#wd-with-image-checkbox").is(":checked"),summary_criteria_ids:woodmart_settings.summary_criteria_ids};o.hasOwnProperty("reviews_columns")&&(s.reviews_columns=o.reviews_columns),o.hasOwnProperty("reviews_columns_tablet")&&(s.reviews_columns_tablet=o.reviews_columns_tablet),o.hasOwnProperty("reviews_columns_mobile")&&(s.reviews_columns_mobile=o.reviews_columns_mobile),e&&(s.rating="",s.only_images=!1),d.ajax({url:woodmart_settings.ajaxurl,method:"GET",data:s,beforeSend:function(){let e=n.find("#comments .commentlist");n.find("#comments .wd-loader-overlay").addClass("wd-loading"),t&&n.find(".wd-rating-summary-wrap .wd-loader-overlay").addClass("wd-loading"),e.removeClass("wd-active"),e.removeClass("wd-in")},complete:function(){n.find("#comments .wd-loader-overlay").removeClass("wd-loading"),t&&n.find(".wd-rating-summary-wrap .wd-loader-overlay").removeClass("wd-loading"),setTimeout(function(){n.find("#comments .commentlist").addClass("wd-active")},50),setTimeout(function(){n.find("#comments .commentlist").addClass("wd-in")},100)},success:function(e){(!s.rating??!s.only_images)&&d(".wd-reviews-sorting-clear").addClass("wd-hide"),e.title&&n.find(".woocommerce-Reviews-title").html(e.title),d(document).trigger("woodmart_reviews_sorting_clear",s),e.content&&n.find("#comments .wd-reviews-content").html(e.content),woodmartThemeModule.hasOwnProperty("photoswipeImages")&&"function"==typeof woodmartThemeModule.photoswipeImages&&woodmartThemeModule.photoswipeImages()},error:function(e){console.error(e)}})}n.on("click",".wd-rating-summary-item",function(){if(woodmart_settings.is_rating_summary_filter_enabled&&!d(this).hasClass("wd-empty")){d(this).siblings().removeClass("wd-active"),d(this).toggleClass("wd-active");let i=r();d(document).on("woodmart_reviews_sorting_clear",function(e,t){i?d(".wd-reviews-sorting-clear").removeClass("wd-hide"):d(".wd-reviews-sorting-clear").addClass("wd-hide")}),t(!1,!0)}}).on("click",".wd-reviews-sorting-clear",function(e){e.preventDefault(),d(".wd-rating-summary-item").each(function(){d(this).removeClass("wd-active")}),d(document).on("woodmart_reviews_sorting_clear",function(e,t){d(".wd-reviews-sorting-clear").addClass("wd-hide")}),d("#wd-with-image-checkbox").prop("checked",!1),t(!0,!0)}).on("click","#wd-with-image-checkbox",function(){let i=d(this).is(":checked");d(document).on("woodmart_reviews_sorting_clear",function(e,t){i?d(".wd-reviews-sorting-clear").removeClass("wd-hide"):0===t.rating.length&&d(".wd-reviews-sorting-clear").addClass("wd-hide")}),t()}).on("change",".wd-reviews-sorting-select",function(){t()})},d(document).ready(function(){woodmartThemeModule.singleProdReviews()})}(jQuery); |