storefront.comments=function(){var n={view:!1,firstExecution:!1,idClient:null,idProfessionalProfile:null,idContactPerson:null,idButton:"",idForm:"",dataPost:"",idContent:"",nameController:"",attachEvents:function(){$(n.idForm).validate({errorPlacement:validation.errorPlacement,highlight:validation.highlight,unhighlight:validation.unhighlight,rules:{txtCommentArea:{required:!0}},onfocusout:function(n){$(n).valid()}});$("#js-reviews-comments-section").off("click",".js-review-comment-delete");$("#js-reviews-comments-section").on("click",".js-review-comment-delete",function(){var t=$(this).data("idcomment");n.deleteComment(t)})},attachNoModal:function(){$(n.idButton).off("click");$(n.idButton).click(function(t){t.preventDefault();t.stopPropagation();$(n.idForm).valid()&&n.sendComment()})},attachModal:function(){$(n.idButton).off("click");$(n.idButton).loadView({view:modalViewer.urlViews.modalViewerSignUp,container:"#headerSite",identifyPreposition:"js-pad-",idmodal:"sign-up-add-your-comment-modal",title:" to add your comment",callbackMethodjs:"addComment",callbackElementjs:n.idForm,successCallback:function(){window.dispatchEvent(new window.CustomEvent("comments:view"))},preCallback:function(){return $(n.idForm).valid()}})},sendComment:function(){var t=n.dataPost?n.dataPost:$(n.idForm).serialize();$.ajax({url:"/"+n.nameController+"/PostComment/"+n.idContent,data:t,type:"post",beforeSend:function(){$("#js-review-comment-submit").addClass("disabled");$("#js-review-comment-submit").append('<i class="fa fa-refresh fa-spin fa-fw"><\/i> ')},success:function(t){n.dataPost=null;$("#js-reviews-comments-section").html(t);$("#js-review-comment-submit, #js-review-comment-text").hide();$("#js-review-comment-success").show()},error:function(){console.log("An error has accoured");$("#js-review-comment-submit").removeClass("disabled");$("#js-review-comment-submit>i").remove()}})},deleteComment:function(t){user.idContactPerson>0&&$.ajax({url:"/"+storefront.nameController+"/DeleteComment/"+t,data:{idProduct:storefront.idContent,idProductType:storefront.idProductType,contentName:storefront.contentName},type:"post",success:function(t){$("#js-reviews-comments-section").html(t);n.attachEvents();n.attachNoModal()},error:function(){console.log("An error has accoured")}})},init:function(){n.attachEvents();user.idContactPerson>0&&n.view&&!n.firstExecution?(n.firstExecution=!0,n.attachNoModal(),$(n.idForm).valid()&&n.sendComment()):user.idContactPerson>0&&n.dataPost&&xprtUtils.getURLParameters("callBackMethodJs").includes("addComment")?(n.firstExecution=!0,n.attachNoModal(),n.sendComment()):user.idContactPerson>0?n.attachNoModal():n.attachModal()}};return n}()