!function(t,e){"function"==typeof define&&define.amd?define(["jquery"],e):"object"==typeof module&&module.exports?module.exports=e(require("jquery")):e(t.jQuery)}(this,function(o){"use strict";function t(t,e){this.element=t,this.self=o(t),this.opt=o.extend(!0,{},o.raty,e,this.self.data())}o.raty={cancelButton:!1,cancelClass:"raty-cancel",cancelHint:"Cancel this rating!",cancelOff:"cancel-off.png",cancelOn:"cancel-on.png",cancelPlace:"left",click:void 0,half:!1,halfShow:!0,hints:["bad","poor","regular","good","gorgeous"],iconRange:void 0,iconRangeSame:!1,mouseout:void 0,mouseover:void 0,noRatedMsg:"Not rated yet!",number:5,numberMax:20,path:void 0,precision:!1,readOnly:!1,round:{down:.25,full:.6,up:.76},score:void 0,scoreName:"score",single:!1,space:!0,starHalf:"star-half.png",starOff:"star-off.png",starOn:"star-on.png",starType:"img",target:void 0,targetFormat:"{score}",targetKeep:!1,targetScore:void 0,targetText:"",targetType:"hint"},o.fn.raty=function(t){return this.each(function(){return new o.raty.Raty(this,t)._create()})},o.raty.Raty=(t.prototype={_create:function(){this._executeCallbacks(),this._adjustNumber(),this._adjustHints(),this.opt.score=this._adjustedScore(this.opt.score),"img"!==this.opt.starType&&this._adjustStarName(),this._setPath(),this._createStars(),this.opt.cancelButton&&this._createCancel(),this.opt.precision&&this._adjustPrecision(),this._createScore(),this._apply(this.opt.score),this._setTitle(this.opt.score),this._target(this.opt.score),this.opt.readOnly?this._lock():(this.element.style.cursor="pointer",this._binds()),this.self.data("raty",this)},_adjustedScore:function(t){if(t||0===t)return this._between(t,0,this.opt.number)},_adjustHints:function(){if(this.opt.hints||(this.opt.hints=[]),this.opt.halfShow||this.opt.half)for(var t=this.opt.precision?10:2,e=0;e",{name:this.opt.scoreName,type:"hidden"}).appendTo(this.self)},_createCancel:function(){var t=this.opt.path+this.opt.cancelOff,e=o("<"+this.opt.starType+" />",{title:this.opt.cancelHint,class:this.opt.cancelClass});"img"===this.opt.starType?e.attr({src:t,alt:"x"}):e.attr("data-alt","x").addClass(t),"left"===this.opt.cancelPlace?this.self.prepend(" ").prepend(e):this.self.append(" ").append(e),this.cancelButton=e},_createScore:function(){var t=o(this.opt.targetScore);this.scoreField=t.length?t:this._buildScoreField()},_createStars:function(){for(var t=1;t<=this.opt.number;t++){var e=this._attributesForIndex(t);o("<"+this.opt.starType+" />",e).appendTo(this.element),this.opt.space&&te?(i=this.opt.iconRange[e],o=this._getRangeIcon(i,a),s<=i.range&&this._setIcon(n,o),s===i.range&&e++):(o=this.opt[a?"starOn":"starOff"],this._setIcon(n,o))}},_getDecimal:function(t,e){var s=t.toString().split(".")[1],t=0;return s&&(t=parseInt(s.slice(0,e),10),"9999"===s.slice(1,5)&&t++),t},_getRangeIcon:function(t,e){return e?t.on||this.opt.starOn:t.off||this.opt.starOff},_getScoreByPosition:function(t,e){var s,i=parseInt(e.alt||e.getAttribute("data-alt"),10);return this.opt.half&&(s=this._getWidth(),i=i-1+parseFloat((t.pageX-o(e).offset().left)/s)),i},_getHint:function(t,e){if(0!==t&&!t)return this.opt.noRatedMsg;var s=this._getDecimal(t,1),i=Math.ceil(t),o=this.opt.hints[(i||1)-1],i=o,e=!e||this.isMove;return this.opt.precision?i=o[s=e?0===s?9:s-1:s]:(this.opt.halfShow||this.opt.half)&&(i=o[s=e&&0===s||5=t?"starOn":"starOff"},_resetTitle:function(){for(var t=0;t=this.opt.number&&(e=this.opt.number-1,s=10);t=this._getWidth()/10,e=o(this.stars[e]),s=e.offset().left+t*s,s=o.Event("mousemove",{pageX:s});this.isMove=!0,e.trigger(s),this.isMove=!1},readOnly:function(t){this.self.data("readonly")!==t&&(t?(this.self.off(".raty").children(this.opt.starType).off(".raty"),this._lock()):(this._binds(),this._unlock()),this.self.data("readonly",t))},score:function(){return arguments.length?this.setScore.apply(this,arguments):this.getScore()},setScore:function(t){!0!==this.self.data("readonly")&&(t=this._adjustedScore(t),this._apply(t),this._target(t))}},t)});