One Hat Cyber Team
  • Dir : ~/usr/local/psa/admin/cp/public/javascript/app/
  • View File Name : rating.js
    ${this.lmsg("voteDislikeHint")}
    `,buttons:[{title:this.lmsg("voteButtonOk"),id:"rating-vote-button-ok",class:"action",handler:this.handleVoteButton.bind(this)},{title:s.Locale.getSection("components.buttons").lmsg("cancel"),id:"rating-vote-button-cancel",handler(e,t){t.hide()}}],...e}),this.dialogCause=this._getConfigParam("dialogCause","manual"),this.supportUrl=this._getConfigParam("supportUrl")}_initComponentElement(){super._initComponentElement(),(0,s.render)(this._componentElement.querySelector("#nps-rating"),[0,1,2,3,4,5,6,7,8,9,10].map((e=>(0,s.createElement)("label",{class:`nps-survey__score nps-survey__score--${e}`,onclick:this.checkPossibleSendVote.bind(this)},[(0,s.createElement)("input",{type:"radio",name:"nps-survey-option",value:e}),(0,s.createElement)("span",{class:"nps-survey__score-label"})]))))}show(){super.show(),this.showTime=Date.now()}hide(){super.hide(),this.voted||((this.checkPossibleSendVote()||this.getFeedbackLike()||this.getFeedbackDislike())&&this.sendVote(),"timeout"===this.dialogCause&&this.sendPostpone())}handleVoteButton(){this.checkPossibleSendVote()&&(this.voted=!0,this.sendVote(),this.hide(),new a({supportUrl:this.supportUrl,feedbackLike:this.getFeedbackLike(),feedbackDislike:this.getFeedbackDislike()}))}checkPossibleSendVote(){const e=this._componentElement.querySelector(".nps-survey"),t=this.getRate();if(t){e.classList.remove("error");const t=e.querySelector(".field-errors");t&&t.parentNode.removeChild(t)}else{e.classList.add("error");e.querySelector(".field-errors")||(0,s.render)(e,`${this.lmsg("voteRequire")}`)}return t}getRate(){const e=this._componentElement.querySelector(`#${this.getId()}-form input[name=nps-survey-option]:checked`);return e?e.value:""}getFeedbackLike(){return this._componentElement.querySelector("#rating-like").value.trim()}getFeedbackDislike(){return this._componentElement.querySelector("#rating-dislike").value.trim()}sendVote(){s.api.post((0,s.prepareUrl)("/admin/rating/vote"),{voted:this.voted,dialogCause:this.dialogCause,rate:this.getRate(),feedbackLike:this.getFeedbackLike(),feedbackDislike:this.getFeedbackDislike(),dialogDuration:Math.round((Date.now()-this.showTime)/1e3),dialogAtPage:window.location.pathname})}sendPostpone(){s.api.post((0,s.prepareUrl)("/admin/rating/postpone"))}}class a extends s.Popup{_initConfiguration(e){this.setLocale(s.Locale.getSection("components.rating"));let t=[{title:this.lmsg("thankButtonClose"),class:"action",handler(e,t){t.hide()}}],i=`

    ${this.lmsg("thankHint")}

    `;if(e.feedbackDislike){i+=`

    ${this.lmsg("thankSupportCenter",{link:`${this.lmsg("supportCenter")}`})}

    `}else if(e.feedbackLike){const s=this.lmsg("introductionText",{message:e.feedbackLike});i+=`

    ${this.lmsg("thankSocialChoose")}

    `,t=[]}super._initConfiguration({id:"thank-dialog",title:this.lmsg("thankTitle"),closeButtonEnabled:!0,hideOnEscape:!0,content:i,buttons:t,...e})}_addEvents(){super._addEvents(),document.getElementById("rating-dialog-support-link")&&document.getElementById("rating-dialog-support-link").addEventListener("click",(()=>{s.api.post((0,s.prepareUrl)("/admin/rating/support-center"))})),document.getElementById("rating-dialog-tweet-button")&&document.getElementById("rating-dialog-tweet-button").addEventListener("click",(()=>{window.open(`${(0,s.prepareUrl)("/admin/rating/social")}?button=twitter&text=${encodeURIComponent(document.getElementById("rating-dialog-share-text").value)}`,"social-share","width=600,height=460"),this.hide()})),document.getElementById("rating-dialog-close-button")&&document.getElementById("rating-dialog-close-button").addEventListener("click",(()=>{this.hide()}))}}const o=e=>new n(e)}}]); //# sourceMappingURL=rating.js.map?939a480cdfdf342295d3