/*Cached on 30 Dec 2020 01:27:46*/

(function($){$.fn.pHRating=function(op){var defaults={url:pH7Url.base+'asset/ajax/Rating/',bigStarUrl:pH7Url.stic+'img/icon/m-star.png',smallStarUrl:pH7Url.stic+'img/icon/s-star.png',type:'big',step:false,isDisabled:false,showRateInfo:true,length:5,decimalLength:0,rateMax:20,rateInfosX:-45,rateInfosY:5,onSuccess:null,onError:null};if(this.length>0)
return this.each(function(){var opts=$.extend(defaults,op),newWidth=0,starWidth=0,starHeight=0,bgUrl='';if($(this).hasClass('jDisabled')||opts.isDisabled)
var jDisabled=true;else
var jDisabled=false;getStarWidth();$(this).height(starHeight);var average=parseFloat($(this).attr('id').split('_')[0]),id=parseInt($(this).attr('id').split('_')[1]),table=$(this).attr('id').split('_')[2],widthRatingContainer=starWidth*opts.length,widthColor=average/opts.rateMax*widthRatingContainer,quotient=$('<div>',{'class':'pHRatingColor',css:{width:widthColor}}).appendTo($(this)),average=$('<div>',{'class':'pHRatingAverage',css:{width:0,top:-starHeight}}).appendTo($(this)),pHStar=$('<div>',{'class':'pHStar',css:{width:widthRatingContainer,height:starHeight,top:-(starHeight*2),background:'url('+bgUrl+')repeat-x'}}).appendTo($(this));$(this).css({width:widthRatingContainer,overflow:'hidden',zIndex:1,position:'relative'});if(!jDisabled)
$(this).bind({mouseenter:function(e){var realOffsetLeft=findRealLeft(this);var relativeX=e.pageX-realOffsetLeft;if(opts.showRateInfo)
var tooltip=$('<p>',{'class':'pHRatingInfo',html:getNote(relativeX)+' <span class="maxRate">/ '+opts.rateMax+'</span>',css:{top:(e.pageY+opts.rateInfosY),left:(e.pageX+opts.rateInfosX)}}).appendTo('body').show();},mouseover:function(e){$(this).css('cursor','pointer');},mouseout:function(){$(this).css('cursor','default');average.width(0);},mousemove:function(e){var realOffsetLeft=findRealLeft(this);var relativeX=e.pageX-realOffsetLeft;if(opts.step)newWidth=Math.floor(relativeX/starWidth)*starWidth+starWidth;else newWidth=relativeX;average.width(newWidth);if(opts.showRateInfo)
$("p.pHRatingInfo").css({left:(e.pageX+opts.rateInfosX)}).html(getNote(newWidth)+' <span class="maxRate">/ '+opts.rateMax+'</span>');},mouseleave:function(){$("p.pHRatingInfo").remove();},click:function(e){$(this).unbind().css('cursor','default').addClass('jDisabled');if(opts.showRateInfo)$("p.pHRatingInfo").fadeOut('fast',function(){$(this).remove();});e.preventDefault();var rate=getNote(newWidth);average.width(newWidth);$.post(opts.url,{id:id,table:table,score:rate,action:'rating'},function(data){var txt_class='.pHS'+id+table+'_txt';if(data.status==1)
$(txt_class).html(data.txt).show('slow');else
$(txt_class).addClass('alert alert-danger').html(data.txt).delay(3000).fadeOut();},'json');}});function getNote(relativeX){var noteBrut=parseFloat((relativeX*100/widthRatingContainer)*opts.rateMax/100);switch(opts.decimalLength){case 1:var note=Math.round(noteBrut*10)/10;break;case 2:var note=Math.round(noteBrut*100)/100;break;case 3:var note=Math.round(noteBrut*1000)/1000;break;default:var note=Math.round(noteBrut*1)/1;}
return note;};function getStarWidth(){switch(opts.type){case'small':starWidth=12;starHeight=10;bgUrl=opts.smallStarUrl;break;default:starWidth=23;starHeight=20;bgUrl=opts.bigStarUrl;}};function findRealLeft(obj){if(!obj)return 0;return obj.offsetLeft+findRealLeft(obj.offsetParent);};});}})(jQuery);