static.org.tinygroup.ratymaster.js.jquery.raty.tiny.min.js Maven / Gradle / Ivy
/*!
* jQuery Raty - A Star Rating Plugin
*
* The MIT License
*
* @author : Washington Botelho
* @doc : http://wbotelhos.com/raty
* @version : 2.7.0
*
*/
(function(b){var a={init:function(c){return this.each(function(){this.self=b(this);a.destroy.call(this.self);this.opt=b.extend(true,{},b.fn.raty.defaults,c);a._adjustCallback.call(this);a._adjustNumber.call(this);a._adjustHints.call(this);this.opt.score=a._adjustedScore.call(this,this.opt.score);if(this.opt.starType!=="img"){a._adjustStarType.call(this)}a._adjustPath.call(this);a._createStars.call(this);if(this.opt.cancel){a._createCancel.call(this)}if(this.opt.precision){a._adjustPrecision.call(this)}a._createScore.call(this);a._apply.call(this,this.opt.score);a._setTitle.call(this,this.opt.score);a._target.call(this,this.opt.score);if(this.opt.readOnly){a._lock.call(this)}else{this.style.cursor="pointer";a._binds.call(this)}})},_adjustCallback:function(){var c=["number","readOnly","score","scoreName","target","path"];for(var d=0;d0){this.score.val(c)}a._roundStars.call(this,c)}},_between:function(e,d,c){return Math.min(Math.max(parseFloat(e),d),c)},_binds:function(){if(this.cancel){a._bindOverCancel.call(this);a._bindClickCancel.call(this);a._bindOutCancel.call(this)}a._bindOver.call(this);a._bindClick.call(this);a._bindOut.call(this)},_bindClick:function(){var c=this;c.stars.on("click.raty",function(d){var e=true,f=(c.opt.half||c.opt.precision)?c.self.data("score"):(this.alt||b(this).data("alt"));if(c.opt.click){e=c.opt.click.call(c,+f,d)}if(e||e===undefined){if(c.opt.half&&!c.opt.precision){f=a._roundHalfScore.call(c,f)}a._apply.call(c,f)}})},_bindClickCancel:function(){var c=this;c.cancel.on("click.raty",function(d){c.score.removeAttr("value");if(c.opt.click){c.opt.click.call(c,null,d)}})},_bindOut:function(){var c=this;c.self.on("mouseleave.raty",function(d){var e=+c.score.val()||undefined;a._apply.call(c,e);a._target.call(c,e,d);a._resetTitle.call(c);if(c.opt.mouseout){c.opt.mouseout.call(c,e,d)}})},_bindOutCancel:function(){var c=this;c.cancel.on("mouseleave.raty",function(d){var e=c.opt.cancelOff;if(c.opt.starType!=="img"){e=c.opt.cancelClass+" "+e}a._setIcon.call(c,this,e);if(c.opt.mouseout){var f=+c.score.val()||undefined;c.opt.mouseout.call(c,f,d)}})},_bindOver:function(){var c=this,d=c.opt.half?"mousemove.raty":"mouseover.raty";c.stars.on(d,function(e){var f=a._getScoreByPosition.call(c,e,this);a._fill.call(c,f);if(c.opt.half){a._roundStars.call(c,f,e);a._setTitle.call(c,f,e);c.self.data("score",f)}a._target.call(c,f,e);if(c.opt.mouseover){c.opt.mouseover.call(c,f,e)}})},_bindOverCancel:function(){var c=this;c.cancel.on("mouseover.raty",function(d){var f=c.opt.path+c.opt.starOff,e=c.opt.cancelOn;if(c.opt.starType==="img"){c.stars.attr("src",f)}else{e=c.opt.cancelClass+" "+e;c.stars.attr("class",f)}a._setIcon.call(c,this,e);a._target.call(c,null,d);if(c.opt.mouseover){c.opt.mouseover.call(c,null)}})},_buildScoreField:function(){return b("",{name:this.opt.scoreName,type:"hidden"}).appendTo(this)},_createCancel:function(){var c=this.opt.path+this.opt.cancelOff,d=b("<"+this.opt.starType+" />",{title:this.opt.cancelHint,"class":this.opt.cancelClass});if(this.opt.starType==="img"){d.attr({src:c,alt:"x"})}else{d.attr("data-alt","x").addClass(c)}if(this.opt.cancelPlace==="left"){this.self.prepend(" ").prepend(d)}else{this.self.append(" ").append(d)}this.cancel=d},_createScore:function(){var c=b(this.opt.targetScore);this.score=c.length?c:a._buildScoreField.call(this)},_createStars:function(){for(var e=1;e<=this.opt.number;e++){var d=a._nameForIndex.call(this,e),c={alt:e,src:this.opt.path+this.opt[d]};if(this.opt.starType!=="img"){c={"data-alt":e,"class":c.src}}c.title=a._getHint.call(this,e);b("<"+this.opt.starType+" />",c).appendTo(this);if(this.opt.space){this.self.append(eg){var h=this.opt.iconRange[g];d=a._getRangeIcon.call(this,h,e);if(c<=h.range){a._setIcon.call(this,f,d)}if(c===h.range){g++}}else{d=this.opt[e?"starOn":"starOff"];a._setIcon.call(this,f,d)}}},_getFirstDecimal:function(e){var d=e.toString().split(".")[1],c=0;if(d){c=parseInt(d.charAt(0),10);if(d.slice(1,5)==="9999"){c++}}return c},_getRangeIcon:function(d,c){return c?d.on||this.opt.starOn:d.off||this.opt.starOff},_getScoreByPosition:function(c,e){var g=parseInt(e.alt||e.getAttribute("data-alt"),10);if(this.opt.half){var d=a._getWidth.call(this),f=parseFloat((c.pageX-b(e).offset().left)/d);g=g-1+f}return g},_getHint:function(h,d){if(h!==0&&!h){return this.opt.noRatedMsg}var c=a._getFirstDecimal.call(this,h),e=Math.ceil(h),f=this.opt.hints[(e||1)-1],g=f,i=!d||this.move;if(this.opt.precision){if(i){c=c===0?9:c-1}g=f[c]}else{if(this.opt.halfShow||this.opt.half){c=i&&c===0?1:c>5?1:0;g=f[c]}}return g===""?"":g||h},_getWidth:function(){var c=this.stars[0].width||parseFloat(this.stars.eq(0).css("font-size"));if(!c){a._error.call(this,"Could not get the icon width!")}return c},_lock:function(){var c=a._getHint.call(this,this.score.val());this.style.cursor="";this.title=c;this.score.prop("readonly",true);this.stars.prop("title",c);if(this.cancel){this.cancel.hide()}this.self.data("readonly",true)},_nameForIndex:function(c){return this.opt.score&&this.opt.score>=c?"starOn":"starOff"},_resetTitle:function(d){for(var c=0;c5?1:0.5}return d+c},_roundStars:function(h,d){var c=(h%1).toFixed(2),e;if(d||this.move){e=c>0.5?"starOn":"starHalf"}else{if(c>this.opt.round.down){e="starOn";if(this.opt.halfShow&&c1)?d:d[0]},move:function(c){return this.each(function(){var g=parseInt(c,10),e=a._getFirstDecimal.call(this,c);if(g>=this.opt.number){g=this.opt.number-1;e=10}var h=a._getWidth.call(this),f=h/10,j=b(this.stars[g]),i=j.offset().left+f*e,d=b.Event("mousemove",{pageX:i});this.move=true;j.trigger(d);this.move=false})},readOnly:function(c){return this.each(function(){var d=b(this);if(d.data("readonly")!==c){if(c){d.off(".raty").children(this.opt.starType).off(".raty");a._lock.call(this)}else{a._binds.call(this);a._unlock.call(this)}d.data("readonly",c)}})},reload:function(){return a.set.call(this,{})},score:function(){var c=b(this);return arguments.length?a.setScore.apply(c,arguments):a.getScore.call(c)},set:function(c){return this.each(function(){b(this).raty(b.extend({},this.opt,c))})},setScore:function(c){return this.each(function(){if(b(this).data("readonly")!==true){c=a._adjustedScore.call(this,c);a._apply.call(this,c);a._target.call(this,c)}})}};b.fn.raty=function(c){if(a[c]){return a[c].apply(this,Array.prototype.slice.call(arguments,1))}else{if(typeof c==="object"||!c){return a.init.apply(this,arguments)}else{b.error("Method "+c+" does not exist!")}}};b.fn.raty.defaults={cancel:false,cancelClass:"raty-cancel",cancelHint:"Cancel this rating!",cancelOff:"cancel-off.png",cancelOn:"cancel-on.png",cancelPlace:"left",click:undefined,half:false,halfShow:true,hints:["bad","poor","regular","good","gorgeous"],iconRange:undefined,mouseout:undefined,mouseover:undefined,noRatedMsg:"Not rated yet!",number:5,numberMax:20,path:undefined,precision:false,readOnly:false,round:{down:0.25,full:0.6,up:0.76},score:undefined,scoreName:"score",single:false,space:true,starHalf:"star-half.png",starOff:"star-off.png",starOn:"star-on.png",starType:"img",target:undefined,targetFormat:"{score}",targetKeep:false,targetScore:undefined,targetText:"",targetType:"hint"}})(jQuery); © 2015 - 2025 Weber Informatics LLC | Privacy Policy