1;(function($){let Util=function(){const self=this 2self.currentPage=1 3self.totalReviewCount=0 4self.didFirstCount=false} 5let once_=false 6Util.prototype.createEmotionUserID=function(){return'user_'+parseInt(Math.random()*9999999)} 7Util.prototype.getEmotionUserID=function(){let user_id=document.cookie.match('(^|;) ?'+'r-em-id'+'=([^;]*)(;|$)') 8user_id=user_id?user_id[2]:null 9if(null==user_id){user_id=this.createEmotionUserID() 10this.setEmotionUserID(user_id)} 11return user_id} 12Util.prototype.setEmotionUserID=function(){let date=new Date() 13date.setTime(date.getTime()+1*24*60*60*1000) 14document.cookie='r-em-id='+this.createEmotionUserID()+';expires='+date.toUTCString()+';path=/'} 15Util.prototype.getFilters=function(){let filters={filter_score:new Array(),} 16let $actions=$('.lv-post-review-list-actions') 17$('[data-review-filter]').each(function(){const filterKey=$(this).data('review-filter') 18filters[filterKey]=$(this).val()}) 19$('[data-review-filter][data-score].filter-active').each(function(){const $scoreFilter=$(this) 20filters.filter_score.push($scoreFilter.data('score'))}) 21if(filters.filter_score.length){let selectedStarsString=new Array() 22for(let score_index in filters.filter_score){selectedStarsString.push('"'+filters.filter_score[score_index]+' '+$('.review-selected-stars',$actions).data('prefix')+'"')} 23$('.review-selected-stars-wrap',$actions).removeClass('d-none') 24$('.review-selected-stars',$actions).html(selectedStarsString.join(', '))}else{$('.review-selected-stars-wrap',$actions).addClass('d-none')} 25return filters} 26Util.prototype.buttonToggle=function($button,onoff){onoff?($button.prop('disabled',false),$('.spinner-border',$button).addClass('d-none'),$('.button-label',$button).removeClass('d-none')):($button.prop('disabled',true),$('.spinner-border',$button).removeClass('d-none'),$('.button-label',$button).addClass('d-none'))} 27Util=new Util() 28var lava_post_review_func=function(element,args){this.el=$('#javo-review-form-container') 29this.selector=element 30this.isConditionForm=this.el.hasClass('is-condition-form') 31this.isCommentForm=false 32if(args){this.args=$.extend(true,{},lavaDirectoryReview,args)}else{this.args=lavaDirectoryReview} 33this.init()} 34lava_post_review_func.prototype={constructor:lava_post_review_func,init:function(){var obj=this,el=obj.el,form=el.find('form') 35obj.form=form 36obj.list_offset=0 37if('yes'!==form.data('show')){form.removeClass('hidden').hide()} 38this.getReviewListActions() 39this.setInputRatingFields() 40this.setSubmitButton() 41this.setSubmitButtonAction() 42this.onShowAllDetailModal() 43this.emailVerify() 44obj.$commentContent=$('textarea[name=comment_content]',form) 45obj.$commentContentPassed=$('.review-content-limit-passed',form) 46obj.$commentContentNonPassed=$('.review-content-limit-non-passed',form) 47obj.ContentStartLimit=parseInt(obj.$commentContent.data('contents-start-limit')||0) 48obj.ContentLimit=parseInt(obj.$commentContent.data('contents-limit')) 49obj.isOnContentLimit=0<obj.ContentLimit 50if(obj.isOnContentLimit){let commentContentKeyUpCallback=function(){let currentLength=$(this).val().length 51obj.$commentContentPassed.addClass('hidden') 52obj.$commentContentNonPassed.addClass('hidden') 53$('.review-content-current-length',form).text(currentLength) 54if(currentLength<obj.ContentLimit){obj.$commentContentPassed.removeClass('hidden')}else{obj.$commentContentNonPassed.removeClass('hidden')}} 55obj.$commentContent.on('keyup',commentContentKeyUpCallback).trigger('keyup')} 56form.on('submit',obj.submit_rating()) 57$('.lv-review-submit',obj.el).on('click',obj.showWriteForm()) 58if(this.isConditionForm){$('select[data-condition-comment-type]').on('change',function(){var commentType=$(this).val(),selectors='.jv-rating-top-inner, .jv-rating-middle-inner' 59$(selectors).removeClass('hidden') 60if('comment'==commentType){obj.isCommentForm=true 61$(selectors).addClass('hidden')}})}},ajax:function(param,callback,failCallback){return $.post(this.args.url,param,callback,'json').fail(failCallback)},showWriteForm:function(){var self=this 62return function(e){var $this=$(this),form=$('form',self.el) 63if($this.hasClass('link-login')){window.location.href=$this.data('url') 64return false} 65if($(this).hasClass('open')){form.slideUp('fast') 66$(this).removeClass('open') 67$(this).text($(this).data('open'))}else{form.slideDown('fast') 68$(this).addClass('open') 69$(this).text($(this).data('close'))}}},setInputRatingFields:function(reset){var self=this,star_elements=$('.jvbpd_rat_star'),slider_elements=$('.jvbpd-rat-slider-wrap') 70star_elements.each(function(k,v){if(!reset){$(this).rating({size:'sm',theme:'krajee-svg',filledStar:'<span class="krajee-icon" style="background-image:url('+self.args.urlImage+'star-pink-grad.svg'+')"></span>',emptyStar:'<span class="krajee-icon" style="background-image:url('+self.args.urlImage+'star-blue-grad-empty.svg'+')"></span>',starCaptions:function(val){return val},})}else{$(this).rating('reset')}}) 71if(typeof jQuery.noUiSlider!='undefined'){slider_elements.each(function(){var $this=$(this) 72$this.noUiSlider({start:0,step:1,connect:'lower',range:{min:0,max:5},tooltips:[true],serialization:{lower:[$.Link({target:$('[name="'+$this.data('input')+'"]'),format:{decimals:1,},}),$.Link({target:'-tooltip-<div class="noUi-tooltips-wrap"></div>',format:{decimals:0,thousand:',',},}),],},}).on('slide',function(){var total=0,count=0,average=0,output=$('h3.rating-form-average',self.el) 73slider_elements.each(function(){var $slider=$(this) 74total+=parseInt($slider.val()) 75count++}) 76average=(total/count).toFixed(1) 77output.html(average)})})} 78return this},setSubmitButton:function(){const self=this 79const $modal=$('.lava-review-form-modal') 80$('button[data-find-submit-review-form]').on('click',function(){if($modal.length){$modal.modal('show')}else{$('html').animate({scrollTop:$('.jv-rating-form-wrap').offset().top,},500)}})},setSubmitButtonAction:function(){var self=this 81$('button[type=submit]',self.form).each(function(){var $button=$(this) 82$button.data('html',$button.html()) 83self.form.on('post-review/submit/before',function(e){$button.html('<i class="fa fa-spin fa-spinner"></i>').prop('disabled',true).addClass('disabled')}) 84self.form.on('post-review/submit/after',function(e){$button.html($button.data('html')).prop('disabled',false).removeClass('disabled')})})},onShowAllDetailModal:function(){const $wrap=$('.lv-review-item-holder') 85const $modal=$('#review-show-all-content') 86$wrap.on('click','a[data-show-all-contents]',function(event){const $item=$(this).closest('.review-content-wrap') 87let content=$('div[data-full-content]',$item).html() 88$('.modal-body',$modal).html(content),$modal.modal('show')})},emailVerify:function(){const self=this 89const $email=$('#lv-review-author-email',self.el) 90const $notice=$('[data-review-submit-form-notice]',self.el) 91const $submit=$('[data-review-submit]',self.el) 92const $accessType=$('input[name=no_user_access_type]',self.el) 93const $verifyCode=$('input[name=verify_code]',self.el) 94const $codeContainer=$('.code-container',self.el) 95const $passwordContaier=$('.password-container',self.el) 96const inputs=document.querySelectorAll('.code-input') 97function moveToNextInput(currentInput,nextInput){if(currentInput.value.length===1&&nextInput){nextInput.focus()}} 98$(self.form).on('post-review/submit/before',function(event){$notice.addClass('d-none')}) 99$(self.form).on('post-review/submit/after',function(event,obj,response){!response.state&&$notice.html(response.message).removeClass('d-none')})
100inputs.forEach((input,index)=>{input.addEventListener('input',(e)=>{const nextInput=inputs[index+1] 101moveToNextInput(input,nextInput)}) 102input.addEventListener('paste',(e)=>{e.preventDefault() 103const pasteData=e.clipboardData.getData('text') 104const pasteArray=pasteData.split('') 105inputs.forEach((input,i)=>{input.value=pasteArray[i]||''})})}) 106$('[data-send-email-verify-code]',self.el).on('click',function(event){event.preventDefault() 107const $button=$(this) 108$notice.addClass('d-none') 109new Array($codeContainer,$passwordContaier).map(function($el){$el.addClass('d-none')}) 110if(!$email.val()){$notice.html(self.args.strings.email.empty_email).removeClass('d-none') 111return false} 112Util.buttonToggle($button,false) 113self.ajax({email:$email.val(),post_id:self.args.post_id,action:'not_logged_user_email_vertification',},function(xhr){switch(xhr.status){case 1:$codeContainer.removeClass('d-none') 114$submit.data('verify-code',xhr.code).prop('disabled',false).removeClass('disabled') 115$accessType.val('code') 116$verifyCode.val(xhr.code) 117break 118case 2:$passwordContaier.removeClass('d-none') 119$accessType.val('login') 120break} 121$notice.html(xhr.message).removeClass('d-none') 122Util.buttonToggle($button,true)})})},setRatings:function(){const self=this 123$('[data-score]:not(.bind-star)',$('.lv-review-item-holder')).each(function(){const $raty=$(this) 124$raty.html(self.render_raty_icon($raty.data('score'))) 125$raty.addClass('bind-star')})},empty_field:function(elements){var self=this,output='' 126self.el.find('form [required]').each(function(i,k){var value 127if(typeof $(this).data('input-name')!='undefined'){value=$("[name='"+$(this).data('input-name')+"']").val()}else{value=$(this).val()} 128if(!value)output+=self.args.strings.strFillRaty.replace(/%s/g,$(this).data('label'))+'<br>'}) 129if(output){self.message({content:output,button:self.args.strings.strOK,}) 130return false} 131return true},submit_rating:function(){var obj=this 132var strings=obj.args.strings 133return function(e){e.preventDefault() 134var form=$(this) 135var ajax_url=obj.args.url 136var el=$('.lv-review-item-holder') 137var param=form.serialize() 138let isUserLogin=form.data('user-login') 139if(0<obj.ContentStartLimit&&obj.$commentContent.val().length<obj.ContentStartLimit){alert(strings.review.content_limit) 140return} 141if(!obj.isCommentForm&&!obj.empty_field()){return false} 142if(!isUserLogin){param+='&author_name='+$('#lv-review-author-name',form).val()} 143if(obj.isCommentForm){param+='&type=comment'}else{param+='&type=review'} 144form.trigger('post-review/submit/before') 145$.post(ajax_url,param,function(response){if(response.state){if(response.approve){if(typeof response.is_low_score!='undefined'){$('#review-low-score-message').modal()}else{response.data.prepend=true 146obj.list_offset=parseInt(obj.list_offset)+1 147obj.add_listing(response.data) 148el.find('.dismiss-ready').remove() 149obj.setReviewImageSlider() 150form.closest('.modal').length&&form.closest('.modal').modal('hide') 151obj.message({icon:'feather-icon feather-check-circle',height:143,content:strings.review.success+response.low_score_message,refresh:obj.args.success_popup_action,})}}else{form.closest('.modal').length&&form.closest('.modal').modal('hide') 152obj.message({icon:'feather-icon feather-check-circle',content:strings.strPending+response.low_score_message,refresh:obj.args.success_popup_action,})} 153obj.reset_review_form()}else{obj.message({icon:'feather-icon feather-check-circle',content:strings.review.fail,})} 154form.trigger('post-review/submit/after',new Array(obj,response))},'json').fail(function(xhr){console.log(xhr.responseText) 155form.trigger('post-review/submit/after',new Array(obj,xhr))})}},reset_review_form:function(){var obj=this,image_container=obj.el.find('.comment_image_preview') 156obj.el.find("[name='comment_content']").val(null) 157obj.setInputRatingFields(true) 158image_container.html(false)},setReviewImageSlider:function(){$('.lv-review-item-holder .review-thumbnails-inner').each(function(){let $inner=$(this) 159if(typeof $.fn.lightGallery!='undefined'){$('div.item-image',$inner).on('click',function(){$inner.lightGallery({dynamic:true,hash:false,dynamicEl:$inner.data('images'),}) 160$inner.data('lightGallery').index=parseInt($(this).data('index'),10)||0})}})}
160,detailPopover:function(holder){var self=this 161return function(event){if(typeof $(this).data('bs.popover')=='undefined'){return} 162let popover=$($(this).data('bs.popover').tip) 163let id='#'+popover.prop('id') 164let popoverClasses=new Array() 165popoverClasses.push('lv-post-review-detail-popover') 166popoverClasses.push(holder.data('popover-classes')) 167popover.addClass(popoverClasses.join(' '))}},render_raty_icon:function(score){let icon={fill:'fas fa-star',empty:'far fa-star',half:'fas fa-star-half-alt',} 168let remain=5 169let intScore=parseInt(score) 170let output='' 171for(let iLoop=0;iLoop<intScore;iLoop++){output+=`<i class="rating-score-icon ${icon.fill}"></i>` 172remain--} 173if(0<remain&&score%1!==0){output+=`<i class="rating-score-icon ${icon.half}"></i>` 174remain--} 175if(0<remain){for(let iLoop=0;iLoop<remain;iLoop++){output+=`<i class="rating-score-icon ${icon.empty}"></i>`}} 176return output},add_listing:function(data){var obj=this,str=$('#javo-detail-item-review-template').html()||'',objStr,emp=$('#javo-detail-item-review-empty').html(),el=$('.lv-review-item-holder'),edit_link,del_link,detail_ratings='<div class="lv-review-score"><i class="fas fa-star me-2 mb-2"></i><span class="fs-1">'+parseFloat(data.rating_average).toFixed(1)+'</span></div>',remove_reply=false,tempalte='<a class="{class}" data-comment-id="{comment_id}" data-before="{icon} {before}" data-after="{icon} {after}">{icon} {before}</a>' 177let emotions=el.data('emotions')||new Array() 178el.find('.dismiss-ready').remove() 179if(data){if(typeof data.is_author!='undefined'&&data.is_author){edit_link=del_link=tempalte 180edit_link=edit_link.replace(/{class}/g,'javo-detail-item-edit-comment dropdown-item fs-7 px-3 py-2') 181edit_link=edit_link.replace(/{icon}/g,'') 182edit_link=edit_link.replace(/{comment_id}/g,data.id) 183edit_link=edit_link.replace(/{before}/g,obj.args.strings.review.edit) 184edit_link=edit_link.replace(/{after}/g,obj.args.strings.review.edit) 185del_link=del_link.replace(/{class}/g,'javo-detail-item-delete-comment') 186del_link=del_link.replace(/{icon}/g,"<i class='fa fa-remove'></i>") 187del_link=del_link.replace(/{comment_id}/g,data.id) 188del_link=del_link.replace(/{before}/g,obj.args.strings.review.remove) 189del_link=del_link.replace(/{after}/g,obj.args.strings.review.remove)} 190let replies=data.reply 191let replies_count=0 192if(replies){replies_count=replies.length} 193str=str.replace(/{comment-id}/g,data.id||'') 194str=str.replace(/{author}/g,data.author||'') 195str=str.replace(/{avatar}/g,data.avatar||'') 196str=str.replace(/{jv_current_user_avatar_src}/g,data.jv_current_user_avatar_src||'') 197str=str.replace(/{content}/g,(data.content||'').replace(/(\n|\r\n)/g,'<br>')) 198str=str.replace(/{content_excerpt}/g,(data.content_excerpt||'').replace(/(\n|\r\n)/g,'<br>')) 199str=str.replace(/{date}/g,data.date||'') 200str=str.replace(/{attach_count}/g,data.attach_count||0) 201str=str.replace(/{{{content_min_length}}}/g,data.content_min_length||0) 202str=str.replace(/{{{content_max_length}}}/g,data.content_max_length||0) 203str=str.replace(/{content_length}/g,data.content_length||0) 204str=str.replace(/{ratings}/g,data.ratings||'') 205str=str.replace(/{rating_sum}/g,data.rating_sum||0) 206str=str.replace(/{rating_average}/g,data.rating_average||0) 207str=str.replace(/{rating_visible}/g,data.type=='non-review'?'hidden':'') 208str=str.replace(/{condition}/g,data.type=='non-review'?'<i class="fa fa-check"></i> Study':'') 209str=str.replace(/{thumbnails}/g,data.thumbnails||'') 210str=str.replace(/{reviews}/g,obj.add_listing_reply(data)) 211str=str.replace(/{has_replies}/g,0<replies_count?'':' '+'hidden') 212str=str.replace(/{replies}/g,replies_count) 213str=str.replace(/{edit}/g,edit_link||'') 214str=str.replace(/{del}/g,del_link||'') 215str=str.replace(/{approval}/g,data.approval||'') 216str=str.replace(/{reward_point_btn_visibility}/g,data.reward_point_btn_visibility||' '+'hidden') 217if(typeof data.ratings=='object'){var dr_score=new Array(),is_mobile=$(window).width()<768,popup_width=is_mobile?150:250,template='<div class="row lv-detail-review" style="width:{popup_width}px;">'+'<div class="col-7">'+'<div class="rating-score-label">{title}</div>'+'</div>'+'<div class="col-5">'+'<div class="rating-score">{score_stars}</div>'+'</div>'+'</div>' 218$.each(data.ratings,function(title,score){var buff=template 219buff=buff.replace(/{popup_width}/g,popup_width) 220buff=buff.replace(/{title}/g,title) 221buff=buff.replace(/{score}/g,score) 222buff=buff.replace(/{score_stars}/g,obj.render_raty_icon(score)) 223dr_score.push(buff)}) 224detail_ratings+=dr_score.join('')} 225objStr=$(str) 2261!=data.edit_button&&$('.review-edit-btn',objStr).remove()'yes'!=data.report_button&&$('.show-review-report-modal',objStr).remove() 227$('[data-add-reply]',objStr).on('click',function(){let $button=$(this) 228let $form=$button.closest('.reply-form') 229obj.regsiterReply({parent:$form.data('review-id'),content:$('textarea[name=txt_review_reply]',$form).val(),},function(){$('textarea[name=txt_review_reply]',$form).addClass('disabled').attr('disabled',true) 230$button.addClass('disabled').attr('disabled',true)},function(xhr){$('textarea[name=txt_review_reply]',$form).removeClass('disabled').attr('disabled',false) 231$button.removeClass('disabled').attr('disabled',false) 232$('.collapse',$form).collapse('hide')})}) 233$('.javo-detail-item-comment-content',objStr).on('keyup',function(){let currentLength=$(this).val().length 234$('.review-content-current-length',objStr).text(currentLength)}).trigger('keyup') 235remove_reply='disabled'==obj.args.reply 236remove_reply=1==obj.args.reply_paid?false:remove_reply
237if(remove_reply){$('.review-reply-btn',objStr).remove()} 238if(0<emotions.length){for(let emotionIDX in emotions){let emotion=emotions[emotionIDX] 239let dataEmotion=data.emotion[emotion] 240let $emotion=$('.review-action.emotion-'+emotion,objStr) 241if('undefined'!=typeof dataEmotion){$('.action-count',$emotion).text(dataEmotion.count) 242if(dataEmotion.active){$emotion.addClass('active') 243$('a.btn',$emotion).addClass('active')}}}} 244str=$('<div>').append(objStr.clone()).html() 245$(window).trigger('lava:post-review/add-listing/template/before-insert',[objStr,{getData:function(){return data},getStr:function(){return str},setStr:function(str){objStr=str},},]) 246if(!data.noAppend){if(data.prepend){objStr.prependTo(el).find('[data-score]').css('cursor','pointer').popover({content:detail_ratings,sanitize:false,html:true,trigger:'hover',placement:'top',}).on('show.bs.popover',obj.detailPopover(el))}else{var is_mobile=$(window).width()<768 247objStr.appendTo(el).find('[data-score]').css('cursor','pointer').popover({content:detail_ratings,sanitize:false,html:true,trigger:'hover',placement:is_mobile?'right':'top',}).on('show.bs.popover',obj.detailPopover(el))}}}else{el.append(emp)} 248obj.setRatings() 249obj.setActions() 250obj.useRwardPointButton() 251$('[data-bs-toggle="popover"]').popover() 252$(window).trigger('javo:refresh/tooltips') 253return objStr?objStr:emp},add_listing_reply:function(data){var result='' 254if(typeof data.reply=='undefined')return'' 255$.each(data.reply,function(i,k){var str=$('#reply-input-box-template').html() 256str=str.replace(/{author}/g,k.author||'') 257str=str.replace(/{content}/g,k.content||'') 258str=str.replace(/{date}/g,k.date||'') 259result+=str}) 260return result},regsiterReply:function(opt,before,after){var self=this 261typeof before=='function'&&before() 262self.ajax({action:'add_comment_reply',comment_id:opt.parent,post_id:self.args.post_id,content:opt.content,},function(xhr){var str='',data=xhr.data 263if(xhr.state=='success'){if(xhr.approve){str=$('#reply-input-box-template').html() 264str=str.replace(/{author}/g,data.author||'') 265str=str.replace(/{content}/g,data.content||'') 266str=str.replace(/{date}/g,data.date||'') 267$(".review-reply-wrap[data-parent-id='"+opt.parent+"']").prepend(str) 268self.message({content:self.args.strings.reply.success,refresh:self.args.success_popup_action,})}else{self.message({content:self.args.strings.strPending})} 269typeof after=='function'&&after(xhr)}})},setEditCommentMode:function(){const self=this 270return function(event){const $el=$(this) 271const $wrap=$el.closest('.lv-review-item') 272const $contentField=$('.review-content',$wrap) 273const $display=$('.review-content-display',$contentField) 274const $edit=$('.review-content-edit',$contentField) 275$display.addClass('d-none')&&$edit.removeClass('d-none')}},editComment:function(){const self=this 276return function(event){const el=$(this) 277const $item=el.closest('.lv-review-item') 278const $items=el.closest('.lv-review-list-items') 279var PROCESSING='loading',commentID=$item.data('id') 280const content_length=$items.data('content-length') 281event.preventDefault() 282if(el.hasClass(PROCESSING)){return} 283el.addClass(PROCESSING) 284self.ajax({action:'lvdr_review_update_content',comment:commentID,content:$('textarea.javo-detail-item-comment-content',$item).val(),content_length:content_length,},function(response){if(typeof response.error==='undefined'){if(response.state==='OK'){$('.review-content-display',$item).html(response.excerpt) 285$('[data-full-content]',$item).html(response.content)}else{self.message({content:self.args.strings.reply.fail,delay:5000,refresh:self.args.success_popup_action,})}}else{self.message({content:response.error,delay:5000})} 286el.removeClass(PROCESSING) 287$('.javo-detail-item-edit-cancel-comment').trigger('click')})}},useRwardPointButton:function(){let self=this 288let $wrap=$('.lv-review-list-items') 289let $holder=$('.lv-review-item-holder',$wrap) 290$('[data-read-review]:not(.bind)',$holder).each(function(){$(this).on('click',function(event){let $button=$(this) 291let $review=$button.closest('.lv-review-item') 292let reviewID=$review.data('id') 293$button.html('<i class="fas fa-spin fa-spinner"></i>').addClass('disabled').attr('disabled',true) 294self.ajax({action:'get_review_content_on_reward',post_id:self.args.post_id,emotions:$holder.data('emotions'),review:reviewID,},function(response){if('success'==response.status){if('undefined'!=typeof response.data[0]){response.data[0].noAppend=true 295$review.html(self.add_listing(response.data[0]).html())}}})}) 296$(this).addClass('bind')})},message:function(objMsg,args){let self=this 297let modal=$('div.post-review-modal') 298objMsg=$.extend({},{icon:null,content:null,delay:100,height:'auto',refresh:false,},objMsg) 299if(!modal.length){modal=$('<div>').addClass('post-review-modal') 300modal.appendTo($('body'))} 301objMsg.content='<p class="mb-2 lh-base">'+objMsg.content+'</p>' 302if(null!==objMsg.icon){objMsg.content='<h3 class="pt-2 fs-1">'+'<i class="'+objMsg.icon+'"></i>'+'</h3>'+objMsg.content} 303modal.html(objMsg.content).dialog({modal:true,height:objMsg.height,buttons:new Array({text:self.args.strings.strClose,class:'btn btn-light',click:function(){if('refresh'==objMsg.refresh){window.location.reload()}else{$(this).dialog('close')}},}),}) 304var $dialog=modal.closest('.ui-dialog') 305$dialog.addClass('lava-post-review-message shadow-sm') 306$('.ui-dialog-titlebar',$dialog).addClass('hidden')},} 307lava_post_review_func.prototype.getReviewListActions=function(){const self=this 308const filters={'#javo-detail-item-review-loadmore':{event:'click',reload:false,},'select[data-review-filter]':{event:'change',reload:true,},'div[data-review-filter]':{event:'click',toggle:true,reload:true,},'.lv-review-clear-selected-star':{event:'click',reload:true,clear:true,},} 309const $scope=self.args.scope||$(document) 310Object.entries(filters).map(function(filter){$(filter[0],$scope).on(filter[1].event,function(event){let callback=self.getReviewLists() 311if(filter[1].reload){self.list_offset=0 312$('.lv-review-item-holder',$scope).empty()} 313if(filter[1].toggle){$(this).toggleClass('filter-active')} 314if(filter[1].clear){$('[data-review-filter][data-score]').removeClass('filter-active')} 315callback(event)})}) 316if($('.lv-review-item-holder',$scope).length>0){self.getReviewLists().call(this,new Event('click'))} 317$(document).on('click','.javo-detail-item-edit-comment',this.setEditCommentMode()) 318$(document).on('click','.javo-detail-item-save-comment',this.editComment()) 319$(document).on('click','.javo-detail-item-edit-cancel-comment',function(){let $wrap=$(this).closest('.review-content') 320$('.review-content-edit',$wrap).addClass('d-none')&&$('.review-content-display',$wrap).removeClass('d-none')}) 321$(document).on('click','.pagination a',function(e){e.preventDefault() 322Util.currentPage=$(this).data('page') 323self.loadReviewsByPage($(this).data('page'),Util.totalReviewCount)})} 324$(document).ready(function(){$(document).on('ajaxComplete',function(){const holderHeight=$('.lv-review-item-holder').outerHeight()
325if(holderHeight>0){$('#review-loading-spinner').css('min-height',`${holderHeight}px`)}})}) 326lava_post_review_func.prototype.loadReviewsByPage=function(pageNumber,totalReviewCount){const self=this 327var postId=$('#post_id').val() 328var reviewsPerPage=$('#reviews_per_page').val() 329var nonce=$('#review_pagination_nonce').val() 330console.log('totalReviewCount= '+totalReviewCount) 331const content_length=$('.lv-review-list-items').data('content-length') 332$.ajax({url:self.args.url,type:'POST',data:{action:'get_reviews_by_page',page_number:pageNumber,reviews_per_page:reviewsPerPage,total_review_count:totalReviewCount,nonce:nonce,post_id:postId,content_length:content_length,filters:Util.getFilters(),},beforeSend:function(){$('.lv-review-item-holder').addClass('loading') 333$('.lv-review-item-holder').addClass('d-none') 334$('#review-loading-spinner').removeClass('d-none').addClass('d-flex')},success:function(response){if(response.success){$('.lv-review-item-holder').empty() 335response.data.data.map(function(data){self.add_listing(data)}) 336self.updatePagination(response.data.total_pages,response.data.current_page) 337Util.totalReviewCount=parseInt(response.data.total_comments) 338const holderHeight=$('.lv-review-item-holder').outerHeight() 339if(holderHeight>0){$('#review-loading-spinner').css('min-height',`${holderHeight}px`)}}else{alert('Failed to load reviews.')}},error:function(xhr,status,error){console.error('Error status:',status) 340console.error('Error thrown:',error) 341console.error('Response:',xhr.responseText) 342alert('There was an error processing the request.')},complete:function(){$('.lv-review-item-holder').removeClass('loading') 343$('#review-loading-spinner').removeClass('d-flex').addClass('d-none') 344$('.lv-review-item-holder').removeClass('d-none')},})} 345lava_post_review_func.prototype.updatePagination=function(totalPages,currentPage){var paginationHtml='' 346for(var i=1;i<=totalPages;i++){paginationHtml+='<li class="page-item'+(i===currentPage?' active':'')+'">' 347paginationHtml+='<a class="page-link" href="#" data-page="'+i+'">'+i+'</a></li>'} 348$('.review-pagination ul').html(paginationHtml)} 349lava_post_review_func.prototype.getReviewLists=function(){const self=this 350const $scope=self.args.scope||document.body 351return function(event){event.preventDefault() 352const $loadmore=$('#javo-detail-item-review-loadmore') 353var $this=$(this),appendObject=new Array(),computedObject,wrap=$('.lv-review-list-items',$scope),holder=$('.lv-review-item-holder',wrap) 354let reviewCount=wrap.data('num') 355if(!Util.didFirstCount){reviewCount=wrap.data('first-num') 356Util.didFirstCount=true} 357$loadmore.prop('disabled',true).addClass('disabled') 358self.ajax({action:'get_item_review',page:wrap.data('page-type'),user_id:wrap.data('user-id'),post_id:self.args.post_id,offset:self.list_offset,num:reviewCount,emotions:holder.data('emotions'),content_length:wrap.data('content-length'),filter:Util.getFilters(),},function(response){var is_finish='finish'==(response.finish||false) 359if(response.state){if(response.data.length>0){$.each(response.data,function(i,data){data.edit_button=wrap.data('edit-button') 360data.report_button=wrap.data('report-button') 361appendObject.push(self.add_listing(data))}) 362self.list_offset+=response.data.length}}else{self.message({content:'Error'})} 363self.setReviewImageSlider() 364$loadmore.prop('disabled',false).removeClass('disabled') 365self.setRatings() 366if(wrap.hasClass('type-masonry')){$('hr',wrap).remove() 367if(!holder.data('masonry')){holder.masonry()}else{appendObject=$.map(appendObject,function(i,k){return i[0]}) 368holder.masonry('appended',appendObject)}} 369$('.review-count-number').text(response.all_found_count) 370Util.totalReviewCount=response.all_found_count 371self.updatePagination(Math.ceil(parseInt(Util.totalReviewCount)/parseInt($('#reviews_per_page').val())),1) 372if(is_finish){$loadmore.remove()}},function(xhr){console.log(xhr.responseText)}) 373return}} 374lava_post_review_func.prototype.setActions=function(){let self=this 375let $el=$('.lv-review-item-holder') 376let loadingTemplate='<i class="fas fa-spin fa-spinner"></i>' 377$('.review-action:not(.bind)',$el).each(function(){let $actions=$(this) 378let temp=$('> a',$actions).html() 379let xhr=false 380let $wrap=$actions.closest('.lv-review-item') 381$('a',$actions).on('click',function(event){let $button=$(this) 382if($button.hasClass('disabled')){return} 383$button.addClass('disabled') 384xhr&&xhr.abort() 385$(this).html(loadingTemplate) 386xhr=self.ajax({action:'lvdr_review_register_emotion',comment_id:$wrap.data('id'),cookie_user_id:Util.getEmotionUserID(),emotion:$actions.data('action'),},function(response){$button.html(temp) 387true===response.registered?$button.addClass('active'):$button.removeClass('active') 388$button.removeClass('disabled') 389$('.action-count',$button).text(response.count||0) 390xhr=false})}) 391$actions.addClass('bind')})} 392$('.lv-post-review-do-approve').on('click',function(event){let $button=$(this) 393let review_id=$button.data('review-id') 394$button.addClass('disabled').prop('disabled',true) 395$('.spinner-border',$button).removeClass('hidden') 396$.post(lavaDirectoryReview.url,{action:'lvdr_review_do_approve',review_id:review_id,},function(xhr){$button.html(xhr.success_message)},'json')}) 397$(document).ready(function(){if($('body').hasClass('author')||$('body').hasClass('single-lv_listing')){new lava_post_review_func() 398once_=true}}) 399let inst=[] 400$(window).on('lava-post-review/init',function(event,args){if(-1==inst.indexOf(args.scope)){inst[args.scope_id]=new lava_post_review_func(null,args)}})})(jQuery)
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.