Files
movie-system/target/classes/static/home/js/jquery.jRating.min.js

1 line
2.7 KiB
JavaScript
Raw Normal View History

2024-04-01 10:06:50 +08:00
(function(a){a.fn.jRating=function(t){var u={bigStarsPath:"jquery/icons/stars.png",smallStarsPath:"jquery/icons/small.png",phpPath:"php/jRating.php",type:"big",step:!1,isDisabled:!1,showRateInfo:!0,canRateAgain:!1,sendRequest:!0,length:5,decimalLength:0,rateMax:20,rateInfosX:-45,rateInfosY:5,nbRates:1,onSuccess:null,onError:null,onClick:null};if(0<this.length)return this.each(function(){function l(a){a=parseFloat(100*a/k*parseInt(b.rateMax)/100);var c=Math.pow(10,parseInt(b.decimalLength));return Math.round(a*c)/c}function m(a){return a?a.offsetLeft+m(a.offsetParent):0}var b=a.extend(u,t),f=0,e=0,g=0,n="",p=!1,q=0,r=b.nbRates,v=a(this).hasClass("jDisabled")||b.isDisabled?!0:!1;switch(b.type){case "small":e=13;g=12;n=b.smallStarsPath;break;default:e=18,g=16,n=b.bigStarsPath}a(this).height(g);var h=parseFloat(a(this).attr("data-average")),s=parseInt(a(this).attr("data-id")),k=e*b.length;a("\x3cdiv\x3e",{"class":"jRatingColor",css:{width:h/b.rateMax*k}}).appendTo(a(this));h=a("\x3cdiv\x3e",{"class":"jRatingAverage",css:{width:0,top:-g}}).appendTo(a(this));a("\x3cdiv\x3e",{"class":"jStar",css:{width:k,height:g,top:-(2*g),background:"url("+n+") repeat-x"}}).appendTo(a(this));a(this).css({width:k,overflow:"hidden",zIndex:1,position:"relative"});v||a(this).unbind().bind({mouseenter:function(d){var c=m(this),c=d.pageX-c;b.showRateInfo&&a("\x3cp\x3e",{"class":"jRatingInfos",html:l(c)+' \x3cspan class\x3d"maxRate"\x3e/ '+b.rateMax+"\x3c/span\x3e",css:{top:d.pageY+b.rateInfosY,left:d.pageX+b.rateInfosX}}).appendTo("body").show()},mouseover:function(b){a(this).css("cursor","pointer")},mouseout:function(){a(this).css("cursor","default");p?h.width(q):h.width(0)},mousemove:function(d){var c=m(this),c=d.pageX-c;f=b.step?Math.floor(c/e)*e+e:c;h.width(f);b.showRateInfo&&a("p.jRatingInfos").css({left:d.pageX+b.rateInfosX}).html(l(f)+' \x3cspan class\x3d"maxRate"\x3e/ '+b.rateMax+"\x3c/span\x3e")},mouseleave:function(){a("p.jRatingInfos").remove()},click:function(d){var c=this;p=!0;q=f;r--;(!b.canRateAgain||0>=parseInt(r))&&a(this).unbind().css("cursor","default").addClass("jDisabled");b.showRateInfo&&a("p.jRatingInfos").fadeOut("fast",function(){a(this).remove()});d.preventDefault();var e=l(f);h.width(f);a(".datasSent p").html("\x3cstrong\x3eidBox : \x3c/strong\x3e"+s+"\x3cbr /\x3e\x3cstrong\x3erate : \x3c/strong\x3e"+e+"\x3cbr /\x3e\x3cstrong\x3eaction :\x3c/strong\x3e rating");a(".serverResponse p").html("\x3cstrong\x3eLoading...\x3c/strong\x3e");if(b.onClick)b.onClick(c,e);b.sendRequest&&a.post(b.phpPath,{idBox:s,rate:e,action:"rating"},function(d){if(d.error){if(a(".serverResponse p").html(d.server),b.onError)b.onError(c,e)}else if(a(".serverResponse p").html(d.server),b.onSuccess)b.onSuccess(c,e)},"json")}})})}})(jQuery);