From 9fbfe8b181c512d21242d87969778474932f9f33 Mon Sep 17 00:00:00 2001 From: prrashi Date: Thu, 12 Feb 2015 12:34:09 -0500 Subject: [PATCH] Added programatic access to halfstar and fullstar options --- min/jquery.rateyo.min.js | 2 +- min/jquery.rateyo.min.js.map | 2 +- src/jquery.rateyo.js | 32 ++++++++++++++++++++++++++++++++ 3 files changed, 34 insertions(+), 2 deletions(-) diff --git a/min/jquery.rateyo.min.js b/min/jquery.rateyo.min.js index 1e9748b..f7e16e8 100644 --- a/min/jquery.rateyo.min.js +++ b/min/jquery.rateyo.min.js @@ -1,4 +1,4 @@ /*rateYo V1.2.2, A simple and flexible star rating plugin prashanth pamidi (https://github.com/prrashi)*/ -!function(a){"use strict";function b(a,b,c){return a===b?a=b:a===c&&(a=c),a}function c(a,b,c){var d=a>=b&&c>=a;if(!d)throw Error("Invalid Rating, expected value between "+b+" and "+c);return a}function d(b,c){var d;return a.each(c,function(){return b===this.node?(d=this,!1):void 0}),d}function e(b,c){return a.each(c,function(a){if(b===this.node){var d=c.slice(0,a),e=c.slice(a+1,c.length);return c=d.concat(e),!1}}),c}function f(a){return"undefined"!=typeof a}function g(d,h){function i(a){f(a)||(a=h.rating);var b=h.minValue,c=h.maxValue,d=(a-b)/(c-b)*100;G.css("width",d+"%")}function k(a){if(!f(a))return h.starWidth;h.starWidth=h.starHeight=a;var b=parseInt(h.starWidth.replace("px","").trim());return b*=h.numStars,d.width(b),F.find("svg").attr({width:h.starWidth,height:h.starHeight}),G.find("svg").attr({width:h.starWidth,height:h.starHeight}),d}function l(a){return f(a)?(h.normalFill=a,F.find("svg").attr({fill:h.normalFill}),d):h.normalFill}function m(a){return f(a)?(h.ratedFill=a,G.find("svg").attr({fill:h.ratedFill}),d):h.ratedFill}function n(b){if(!f(b))return h.numStars;h.numStars=b,F.empty(),G.empty();for(var c=0;ci?b=f:i>e?b=g:(b=(i-d)/(e-d),b*=g-f,b+=f),h.halfStar&&(b=b>Math.ceil(b)-.5?Math.ceil(b):Math.ceil(b)-.5),h.fullStar&&(b=Math.ceil(b)),b}function s(a){var c=r(a).toFixed(h.precision),e=h.minValue,f=h.maxValue;c=b(parseFloat(c),e,f),i(c),d.trigger("rateyo.change",{rating:c})}function t(){i(),d.trigger("rateyo.change",{rating:h.rating})}function u(a){var b=r(a).toFixed(h.precision);b=parseFloat(b),D.rating(b)}function v(a,b){h.onChange&&"function"==typeof h.onChange&&h.onChange.apply(this,[b.rating,D])}function w(a,b){h.onSet&&"function"==typeof h.onSet&&h.onSet.apply(this,[b.rating,D])}function x(){d.on("mousemove",s).on("mouseenter",s).on("mouseleave",t).on("click",u).on("rateyo.change",v).on("rateyo.set",w)}function y(){d.off("mousemove",s).off("mouseenter",s).off("mouseleave",t).off("click",u).off("rateyo.change",v).off("rateyo.set",w)}function z(a){return f(a)?(h.readOnly=a,d.attr("readonly",!0),y(),a||(d.removeAttr("readonly"),x()),d):h.readOnly}function A(a){if(!f(a))return h.rating;var e=a,g=h.maxValue,j=h.minValue;return"string"==typeof e&&("%"===e[e.length-1]&&(e=e.substr(0,e.length-1),g=100,j=0,p(g),o(j)),e=parseFloat(e)),c(e,j,g),e=parseFloat(e.toFixed(h.precision)),b(parseFloat(e),j,g),h.rating=e,i(),d.trigger("rateyo.set",{rating:e}),d}function B(a){return f(a)?(h.onSet=a,d):h.onSet}function C(a){return f(a)?(h.onChange=a,d):h.onChange}this.$node=d,this.node=d.get(0);var D=this;d.addClass("jq-ry-container");var E=a("
").addClass("jq-ry-group-wrapper").appendTo(d),F=a("
").addClass("jq-ry-normal-group").addClass("jq-ry-group").appendTo(E),G=a("
").addClass("jq-ry-rated-group").addClass("jq-ry-group").appendTo(E);this.rating=function(a){return f(a)?(A(a),d):h.rating},this.destroy=function(){return h.readOnly||y(),g.prototype.collection=e(d.get(0),this.collection),d.removeClass("jq-ry-container").children().remove(),d},this.method=function(a){if(!a)throw Error("Method name not specified!");if(!f(this[a]))throw Error("Method "+a+" doesn't exist!");var b=Array.prototype.slice.apply(arguments,[]),c=b.slice(1),d=this[a];return d.apply(this,c)},this.option=function(a,b){if(!f(a))return h;var c;switch(a){case"starWidth":c=k;break;case"numStars":c=n;break;case"normalFill":c=l;break;case"ratedFill":c=m;break;case"minValue":c=o;break;case"maxValue":c=p;break;case"precision":c=q;break;case"rating":c=A;break;case"readOnly":c=z;break;case"onSet":c=B;break;case"onChange":c=C;break;default:throw Error("No such option as "+a)}return c(b)},n(h.numStars),z(h.readOnly),this.collection.push(this),this.rating(h.rating)}function h(b){var c=g.prototype.collection,e=a(this);if(0===e.length)return e;var f=Array.prototype.slice.apply(arguments,[]);if(0===f.length)b=f[0]={};else{if(1!==f.length||"object"!=typeof f[0]){if(f.length>=1&&"string"==typeof f[0]){var h=f[0],i=f.slice(1),j=[];return a.each(e,function(a,b){var e=d(b,c);if(!e)throw Error("Trying to set options before even initialization");var f=e[h];if(!f)throw Error("Method "+h+" does not exist!");var g=f.apply(e,i);j.push(g)}),j=1===j.length?j[0]:a(j)}throw Error("Invalid Arguments")}b=f[0]}return b=a.extend(JSON.parse(JSON.stringify(k)),b),a.each(e,function(){var e=d(this,c);return e?void 0:new g(a(this),b)})}function i(){return h.apply(this,Array.prototype.slice.apply(arguments,[]))}var j='',k={starWidth:"32px",normalFill:"gray",ratedFill:"#f39c12",numStars:5,minValue:0,maxValue:5,precision:1,rating:0,fullStar:!1,halfStar:!1,readOnly:!1,onChange:null,onSet:null};g.prototype.collection=[],a.fn.rateYo=i}(jQuery); +!function(a){"use strict";function b(a,b,c){return a===b?a=b:a===c&&(a=c),a}function c(a,b,c){var d=a>=b&&c>=a;if(!d)throw Error("Invalid Rating, expected value between "+b+" and "+c);return a}function d(b,c){var d;return a.each(c,function(){return b===this.node?(d=this,!1):void 0}),d}function e(b,c){return a.each(c,function(a){if(b===this.node){var d=c.slice(0,a),e=c.slice(a+1,c.length);return c=d.concat(e),!1}}),c}function f(a){return"undefined"!=typeof a}function g(d,h){function i(a){f(a)||(a=h.rating);var b=h.minValue,c=h.maxValue,d=(a-b)/(c-b)*100;I.css("width",d+"%")}function k(a){if(!f(a))return h.starWidth;h.starWidth=h.starHeight=a;var b=parseInt(h.starWidth.replace("px","").trim());return b*=h.numStars,d.width(b),H.find("svg").attr({width:h.starWidth,height:h.starHeight}),I.find("svg").attr({width:h.starWidth,height:h.starHeight}),d}function l(a){return f(a)?(h.normalFill=a,H.find("svg").attr({fill:h.normalFill}),d):h.normalFill}function m(a){return f(a)?(h.ratedFill=a,I.find("svg").attr({fill:h.ratedFill}),d):h.ratedFill}function n(b){if(!f(b))return h.numStars;h.numStars=b,H.empty(),I.empty();for(var c=0;ci?b=f:i>e?b=g:(b=(i-d)/(e-d),b*=g-f,b+=f),h.halfStar&&(b=b>Math.ceil(b)-.5?Math.ceil(b):Math.ceil(b)-.5),h.fullStar&&(b=Math.ceil(b)),b}function u(a){var c=t(a).toFixed(h.precision),e=h.minValue,f=h.maxValue;c=b(parseFloat(c),e,f),i(c),d.trigger("rateyo.change",{rating:c})}function v(){i(),d.trigger("rateyo.change",{rating:h.rating})}function w(a){var b=t(a).toFixed(h.precision);b=parseFloat(b),F.rating(b)}function x(a,b){h.onChange&&"function"==typeof h.onChange&&h.onChange.apply(this,[b.rating,F])}function y(a,b){h.onSet&&"function"==typeof h.onSet&&h.onSet.apply(this,[b.rating,F])}function z(){d.on("mousemove",u).on("mouseenter",u).on("mouseleave",v).on("click",w).on("rateyo.change",x).on("rateyo.set",y)}function A(){d.off("mousemove",u).off("mouseenter",u).off("mouseleave",v).off("click",w).off("rateyo.change",x).off("rateyo.set",y)}function B(a){return f(a)?(h.readOnly=a,d.attr("readonly",!0),A(),a||(d.removeAttr("readonly"),z()),d):h.readOnly}function C(a){if(!f(a))return h.rating;var e=a,g=h.maxValue,j=h.minValue;return"string"==typeof e&&("%"===e[e.length-1]&&(e=e.substr(0,e.length-1),g=100,j=0,p(g),o(j)),e=parseFloat(e)),c(e,j,g),e=parseFloat(e.toFixed(h.precision)),b(parseFloat(e),j,g),h.rating=e,i(),d.trigger("rateyo.set",{rating:e}),d}function D(a){return f(a)?(h.onSet=a,d):h.onSet}function E(a){return f(a)?(h.onChange=a,d):h.onChange}this.$node=d,this.node=d.get(0);var F=this;d.addClass("jq-ry-container");var G=a("
").addClass("jq-ry-group-wrapper").appendTo(d),H=a("
").addClass("jq-ry-normal-group").addClass("jq-ry-group").appendTo(G),I=a("
").addClass("jq-ry-rated-group").addClass("jq-ry-group").appendTo(G);this.rating=function(a){return f(a)?(C(a),d):h.rating},this.destroy=function(){return h.readOnly||A(),g.prototype.collection=e(d.get(0),this.collection),d.removeClass("jq-ry-container").children().remove(),d},this.method=function(a){if(!a)throw Error("Method name not specified!");if(!f(this[a]))throw Error("Method "+a+" doesn't exist!");var b=Array.prototype.slice.apply(arguments,[]),c=b.slice(1),d=this[a];return d.apply(this,c)},this.option=function(a,b){if(!f(a))return h;var c;switch(a){case"starWidth":c=k;break;case"numStars":c=n;break;case"normalFill":c=l;break;case"ratedFill":c=m;break;case"minValue":c=o;break;case"maxValue":c=p;break;case"precision":c=q;break;case"rating":c=C;break;case"halfStar":c=r;break;case"fullStar":c=s;break;case"readOnly":c=B;break;case"onSet":c=D;break;case"onChange":c=E;break;default:throw Error("No such option as "+a)}return c(b)},n(h.numStars),B(h.readOnly),this.collection.push(this),this.rating(h.rating)}function h(b){var c=g.prototype.collection,e=a(this);if(0===e.length)return e;var f=Array.prototype.slice.apply(arguments,[]);if(0===f.length)b=f[0]={};else{if(1!==f.length||"object"!=typeof f[0]){if(f.length>=1&&"string"==typeof f[0]){var h=f[0],i=f.slice(1),j=[];return a.each(e,function(a,b){var e=d(b,c);if(!e)throw Error("Trying to set options before even initialization");var f=e[h];if(!f)throw Error("Method "+h+" does not exist!");var g=f.apply(e,i);j.push(g)}),j=1===j.length?j[0]:a(j)}throw Error("Invalid Arguments")}b=f[0]}return b=a.extend(JSON.parse(JSON.stringify(k)),b),a.each(e,function(){var e=d(this,c);return e?void 0:new g(a(this),b)})}function i(){return h.apply(this,Array.prototype.slice.apply(arguments,[]))}var j='',k={starWidth:"32px",normalFill:"gray",ratedFill:"#f39c12",numStars:5,minValue:0,maxValue:5,precision:1,rating:0,fullStar:!1,halfStar:!1,readOnly:!1,onChange:null,onSet:null};g.prototype.collection=[],a.fn.rateYo=i}(jQuery); //# sourceMappingURL=jquery.rateyo.min.js.map \ No newline at end of file diff --git a/min/jquery.rateyo.min.js.map b/min/jquery.rateyo.min.js.map index d424f0e..719a0c4 100644 --- a/min/jquery.rateyo.min.js.map +++ b/min/jquery.rateyo.min.js.map @@ -1 +1 @@ -{"version":3,"file":"jquery.rateyo.min.js","sources":["../src/jquery.rateyo.js"],"names":["$","checkPrecision","value","minValue","maxValue","checkBounds","isValid","Error","getInstance","node","collection","instance","each","this","deleteInstance","index","firstPart","slice","secondPart","length","concat","isDefined","RateYo","$node","options","showRating","ratingVal","rating","percent","$ratedGroup","css","setStarWidth","newWidth","starWidth","starHeight","containerWidth","parseInt","replace","trim","numStars","width","$normalGroup","find","attr","height","setNormalFill","newFill","normalFill","fill","setRatedFill","ratedFill","setNumStars","newValue","empty","i","append","BASICSTAR","setMinValue","setMaxValue","setPrecision","precision","calculateRating","e","calculatedRating","position","offset","nodeStartX","left","nodeEndX","pageX","halfStar","Math","ceil","fullStar","onMouseEnter","toFixed","parseFloat","trigger","onMouseLeave","onMouseClick","resultantRating","that","onChange","data","apply","onSet","bindEvents","on","unbindEvents","off","setReadOnly","readOnly","removeAttr","setRating","substr","setOnSet","method","setOnChange","get","addClass","$groupWrapper","appendTo","destroy","prototype","removeClass","children","remove","methodName","args","Array","arguments","params","option","optionName","param","push","_rateYo","rateYoInstances","$nodes","result","existingInstance","returnVal","extend","JSON","parse","stringify","DEFAULTS","rateYo","fn","jQuery"],"mappings":";;CAME,SAAUA,GACV,YAmCA,SAASC,GAAgBC,EAAOC,EAAUC,GAYxC,MATIF,KAAUC,EAEZD,EAAQC,EAEFD,IAAUE,IAEhBF,EAAQE,GAGHF,EAGT,QAASG,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Precision","value","minValue","maxValue","checkBounds","isValid","Error","getInstance","node","collection","instance","each","this","deleteInstance","index","firstPart","slice","secondPart","length","concat","isDefined","RateYo","$node","options","showRating","ratingVal","rating","percent","$ratedGroup","css","setStarWidth","newWidth","starWidth","starHeight","containerWidth","parseInt","replace","trim","numStars","width","$normalGroup","find","attr","height","setNormalFill","newFill","normalFill","fill","setRatedFill","ratedFill","setNumStars","newValue","empty","i","append","BASICSTAR","setMinValue","setMaxValue","setPrecision","precision","setHalfStar","halfStar","setFullStar","fullStar","calculateRating","e","calculatedRating","position","offset","nodeStartX","left","nodeEndX","pageX","Math","ceil","onMouseEnter","toFixed","parseFloat","trigger","onMouseLeave","onMouseClick","resultantRating","that","onChange","data","apply","onSet","bindEvents","on","unbindEvents","off","setReadOnly","readOnly","removeAttr","setRating","substr","setOnSet","method","setOnChange","get","addClass","$groupWrapper","appendTo","destroy","prototype","removeClass","children","remove","methodName","args","Array","arguments","params","option","optionName","param","push","_rateYo","rateYoInstances","$nodes","result","existingInstance","returnVal","extend","JSON","parse","stringify","DEFAULTS","rateYo","fn","jQuery"],"mappings":";;CAME,SAAUA,GACV,YAmCA,SAASC,GAAgBC,EAAOC,EAAUC,GAYxC,MATIF,KAAUC,EAEZD,EAAQC,EAEFD,IAAUE,IAEhBF,EAAQE,GAGHF,EAGT,QAASG,GAAaH,EAAOC,EAAUC,GAErC,GAAIE,GAAUJ,GAASC,GAAqBC,GAATF,CAEnC,KAAII,EAEA,KAAMC,OAAM,0CAA2CJ,EAC3C,QAAUC,EAG1B,OAAOF,GAGT,QAASM,GAAaC,EAAMC,GAE1B,GAAIC,EAWJ,OATAX,GAAEY,KAAKF,EAAY,WAEjB,MAAGD,KAASI,KAAKJ,MAEfE,EAAWE,MACJ,GAHT,SAOKF,EAGT,QAASG,GAAgBL,EAAMC,GAe7B,MAbAV,GAAEY,KAAKF,EAAY,SAAUK,GAE3B,GAAIN,IAASI,KAAKJ,KAAM,CAEtB,GAAIO,GAAYN,EAAW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ID,GAAaC,EAAK,GAClBG,EAASH,EAAK7F,MAAM,GAEpBwG,IAyBJ,OAvBAzH,GAAEY,KAAK4G,EAAQ,SAAUlE,EAAG7C,GAE1B,GAAIiH,GAAmBlH,EAAYC,EAAM8G,EAEzC,KAAIG,EAEF,KAAMnH,OAAM,mDAGd,IAAI2F,GAASwB,EAAiBb,EAE9B,KAAKX,EAEH,KAAM3F,OAAM,UAAYsG,EAAa,mBAGvC,IAAIc,GAAYzB,EAAOZ,MAAMoC,EAAkBT,EAE/CQ,GAAOJ,KAAKM,KAGdF,EAA2B,IAAlBA,EAAOtG,OAAcsG,EAAO,GAAIzH,EAAEyH,GAK3C,KAAMlH,OAAM,qBAlCZiB,EAAUsF,EAAK,GAuCjB,MAFAtF,GAAUxB,EAAE4H,OAAOC,KAAKC,MAAMD,KAAKE,UAAUC,IAAYxG,GAElDxB,EAAEY,KAAK4G,EAAQ,WAEX,GAAIE,GAAmBlH,EAAYK,KAAM0G,EAEzC,OAAKG,GAAL,OAES,GAAIpG,GAAOtB,EAAEa,MAAOW,KAK1C,QAASyG,KAGP,MAAOX,GAAQhC,MAAMzE,KAAMkG,MAAMN,UAAUxF,MAAMqE,MAAM0B,eA9qBzD,GAAIxD,GAAY,2WAcZwE,GAEF/F,UAAW,OACXc,WAAY,OACZG,UAAW,UACXX,SAAU,EACVpC,SAAU,EACVC,SAAU,EACVwD,UAAW,EACXjC,OAAQ,EACRqC,UAAU,EACVF,UAAU,EACV+B,UAAU,EACVT,SAAU,KACVG,MAAO,KAskBTjE,GAAOmF,UAAU/F,cA+EjBV,EAAEkI,GAAGD,OAASA,GAEdE"} \ No newline at end of file diff --git a/src/jquery.rateyo.js b/src/jquery.rateyo.js index 751aa66..af3ee4f 100644 --- a/src/jquery.rateyo.js +++ b/src/jquery.rateyo.js @@ -271,6 +271,30 @@ return $node; } + function setHalfStar (newValue) { + + if (!isDefined(newValue)) { + + return options.halfStar; + } + + options.halfStar = newValue; + + return $node; + } + + function setFullStar (newValue) { + + if (!isDefined(newValue)) { + + return options.fullStar; + } + + options.fullStar = newValue; + + return $node; + } + function calculateRating (e) { var position = $normalGroup.offset(), @@ -560,6 +584,14 @@ method = setRating; break; + case "halfStar": + + method = setHalfStar; + break; + case "fullStar": + + method = setFullStar; + break; case "readOnly": method = setReadOnly;