Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

git-svn-id: http://jquery-star-rating-plugin.googlecode.com/svn/trunk@16

 7d9fe731-5e54-0410-9b70-c3ef49213c18
  • Loading branch information...
commit e4c2dd160e6f95dee7c1cd65d81769ac3ea4fb2b 1 parent 1085db0
diego.alto authored
View
8 index.html
@@ -1,7 +1,7 @@
<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
- <title>jQuery Star Rating Plugin v2.61 (2009-01-23)</title>
+ <title>jQuery Star Rating Plugin v2.62 (2009-03-12)</title>
<!--// documentation resources //-->
<script src="jquery-1.31.js" type="text/javascript"></script>
<script src="documentation.js" type="text/javascript"></script>
@@ -37,7 +37,7 @@
<td valign="middle">
<h1>jQuery Star Rating Plugin</h1>
<span style="cursor:help; background:#C00; padding:2px; color:#FFF;" title="Current Version">
- v<strong>2.61</strong>
+ v<strong>2.62</strong>
</span>
</td>
<td valign="middle" width="450" align="right">
@@ -748,7 +748,7 @@
<td valign="top">
<big>
<img src="/@/download.gif" style="margin:0 5px 5px 0; float:left;">
- v<strong>2.61</strong>
+ v<strong>2.62</strong>
<a href="http://jquery-star-rating-plugin.googlecode.com/svn/trunk/star-rating.zip"><strong>star-rating.zip</strong></a>
</big>
</td>
@@ -827,7 +827,7 @@
<td valign="top" align="right">Full Package:</td>
<td valign="top">
<img src="/@/download.gif" style="margin:0 5px 5px 0; float:left;">
- v<strong>2.61</strong>
+ v<strong>2.62</strong>
<a href="star-rating.zip"><strong>star-rating.zip</strong></a>
</td>
</tr>
View
55 jquery.rating.js
@@ -1,5 +1,5 @@
/*
- ### jQuery Star Rating Plugin v2.61 - 2009-01-23 ###
+ ### jQuery Star Rating Plugin v2.62 - 2009-03-12 ###
* Home: http://www.fyneworks.com/jquery/star-rating/
* Code: http://code.google.com/p/jquery-star-rating-plugin/
*
@@ -43,7 +43,8 @@
//callback: function(){}, // executed when a star is clicked
// required properties:
- groups: {},// allows multiple star ratings on one page
+ group: {},// holds details of a group of elements which form a star rating widget
+ calls: 0,// differentiates groups of the same name to be created on separate plugin calls
event: {// plugin event handlers
fill: function(n, el, settings, state){ // fill to the current mouse position.
//if(window.console) console.log(['fill', $(el), $(el).prevAll('.star_group_'+n), arguments]);
@@ -51,29 +52,29 @@
$(el).prevAll('.star_group_'+n).andSelf().addClass('star_'+(state || 'hover'));
// focus handler, as requested by focusdigital.co.uk
var lnk = $(el).children('a'); val = lnk.text();
- if(settings.focus) settings.focus.apply($.rating.groups[n].valueElem[0], [val, lnk[0]]);
+ if(settings.focus) settings.focus.apply($.rating.group[n].valueElem[0], [val, lnk[0]]);
},
drain: function(n, el, settings) { // drain all the stars.
//if(window.console) console.log(['drain', $(el), $(el).prevAll('.star_group_'+n), arguments]);
- $.rating.groups[n].valueElem.siblings('.star_group_'+n).removeClass('star_on').removeClass('star_hover');
+ $.rating.group[n].valueElem.siblings('.star_group_'+n).removeClass('star_on').removeClass('star_hover');
},
reset: function(n, el, settings){ // Reset the stars to the default index.
- if(!$($.rating.groups[n].current).is('.cancel'))
- $($.rating.groups[n].current).prevAll('.star_group_'+n).andSelf().addClass('star_on');
+ if(!$($.rating.group[n].current).is('.cancel'))
+ $($.rating.group[n].current).prevAll('.star_group_'+n).andSelf().addClass('star_on');
// blur handler, as requested by focusdigital.co.uk
var lnk = $(el).children('a'); val = lnk.text();
- if(settings.blur) settings.blur.apply($.rating.groups[n].valueElem[0], [val, lnk[0]]);
+ if(settings.blur) settings.blur.apply($.rating.group[n].valueElem[0], [val, lnk[0]]);
},
click: function(n, el, settings){ // Selected a star or cancelled
- $.rating.groups[n].current = el;
+ $.rating.group[n].current = el;
var lnk = $(el).children('a'); val = lnk.text();
// Set value
- $.rating.groups[n].valueElem.val(val);
+ $.rating.group[n].valueElem.val(val);
// Update display
$.rating.event.drain(n, el, settings);
$.rating.event.reset(n, el, settings);
// click callback, as requested here: http://plugins.jquery.com/node/1655
- if(settings.callback) settings.callback.apply($.rating.groups[n].valueElem[0], [val, lnk[0]]);
+ if(settings.callback) settings.callback.apply($.rating.group[n].valueElem[0], [val, lnk[0]]);
}
}// plugin events
};
@@ -87,6 +88,9 @@
instanceSettings || {} /* just-in-time settings */
);
+ // increment plugin calls
+ $.rating.calls++;
+
// loop through each matched element
this.each(function(i){
@@ -95,28 +99,31 @@
instanceSettings || {} /* current call settings */,
($.metadata? $(this).metadata(): ($.meta?$(this).data():null)) || {} /* metadata settings */
);
-
////if(window.console) console.log([this.name, settings.half, settings.split], '#');
// Generate internal control ID
// - ignore square brackets in element names
var n = (this.name || 'unnamed-rating').replace(/\[|\]+/g, "_");
-
+
+ // differentiate groups of the same name on separate plugin calls
+ // SEE: http://code.google.com/p/jquery-star-rating-plugin/issues/detail?id=5
+ n = $.rating.calls +'_'+ n;
+
// Grouping
- if(!$.rating.groups[n]) $.rating.groups[n] = {count: 0};
- i = $.rating.groups[n].count; $.rating.groups[n].count++;
+ if(!$.rating.group[n]) $.rating.group[n] = {count: 0};
+ i = $.rating.group[n].count; $.rating.group[n].count++;
// Accept readOnly setting from 'disabled' property
- $.rating.groups[n].readOnly = $.rating.groups[n].readOnly || settings.readOnly || $(this).attr('disabled');
+ $.rating.group[n].readOnly = $.rating.group[n].readOnly || settings.readOnly || $(this).attr('disabled');
// Things to do with the first element...
if(i == 0){
// Create value element (disabled if readOnly)
- $.rating.groups[n].valueElem = $('<input type="hidden" name="' + n + '" value=""' + (settings.readOnly ? ' disabled="disabled"' : '') + '/>');
+ $.rating.group[n].valueElem = $('<input type="hidden" name="' + n + '" value=""' + (settings.readOnly ? ' disabled="disabled"' : '') + '/>');
// Insert value element into form
- $(this).before($.rating.groups[n].valueElem);
+ $(this).before($.rating.group[n].valueElem);
- if($.rating.groups[n].readOnly || settings.required){
+ if($.rating.group[n].readOnly || settings.required){
// DO NOT display 'cancel' button
}
else{
@@ -153,7 +160,7 @@
$(eStar).addClass('star_group_'+n);
// readOnly?
- if($.rating.groups[n].readOnly)//{ //save a byte!
+ if($.rating.group[n].readOnly)//{ //save a byte!
// Mark star as readOnly so user can customize display
$(eStar).addClass('star_readonly');
//} //save a byte!
@@ -167,10 +174,10 @@
.click(function(){ $.rating.event.click(n, this, settings); });
//}; //save a byte!
- ////if(window.console) console.log(['###', n, this.checked, $.rating.groups[n].initial]);
- if(this.checked) $.rating.groups[n].current = eStar;
+ ////if(window.console) console.log(['###', n, this.checked, $.rating.group[n].initial]);
+ if(this.checked) $.rating.group[n].current = eStar;
- //remove this checkbox
+ // remove this checkbox - values will be stored in a hidden field
$(this).remove();
// reset display if last element
@@ -179,12 +186,12 @@
}); // each element
// initialize groups...
- for(n in $.rating.groups)//{ not needed, save a byte!
+ for(n in $.rating.group)//{ not needed, save a byte!
(function(c, v, n){ if(!c) return;
$.rating.event.fill(n, c, instanceSettings || {}, 'on');
$(v).val($(c).children('a').text());
})
- ($.rating.groups[n].current, $.rating.groups[n].valueElem, n);
+ ($.rating.group[n].current, $.rating.group[n].valueElem, n);
//}; not needed, save a byte!
return this; // don't break the chain...
View
4 jquery.rating.pack.js
@@ -1,5 +1,5 @@
/*
- ### jQuery Star Rating Plugin v2.61 - 2009-01-23 ###
+ ### jQuery Star Rating Plugin v2.62 - 2009-03-12 ###
* Home: http://www.fyneworks.com/jquery/star-rating/
* Code: http://code.google.com/p/jquery-star-rating-plugin/
*
@@ -8,4 +8,4 @@
* http://www.gnu.org/licenses/gpl.html
###
*/
-eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}(';6(1M.P)(7($){6($.19.1h)1k{1l.1o("1q",1r,1s)}1t(e){}$.3={x:\'1d 1g\',T:\'\',o:0,L:16,5:{},8:{I:7(n,a,b,c){4.m(n);$(a).O(\'.u\'+n).Q().k(\'1p\'+(c||\'J\'));j d=$(a).s(\'a\');9=d.y();6(b.Y)b.Y.D($.3.5[n].f[0],[9,d[0]])},m:7(n,a,b){$.3.5[n].f.1e(\'.u\'+n).A(\'t\').A(\'1i\')},r:7(n,a,b){6(!$($.3.5[n].q).1n(\'.x\'))$($.3.5[n].q).O(\'.u\'+n).Q().k(\'t\');j c=$(a).s(\'a\');9=c.y();6(b.W)b.W.D($.3.5[n].f[0],[9,c[0]])},p:7(n,a,b){$.3.5[n].q=a;j c=$(a).s(\'a\');9=c.y();$.3.5[n].f.9(9);$.3.8.m(n,a,b);$.3.8.r(n,a,b);6(b.11)b.11.D($.3.5[n].f[0],[9,c[0]])}}};$.13.3=7(d){6(4.14==0)F 4;d=$.K({},$.3,d||{});4.1y(7(i){j a=$.K({},d||{},($.M?$(4).M():($.15?$(4).17():18))||{});j n=(4.N||\'1a-3\').1b(/\\[|\\]+/g,"1c");6(!$.3.5[n])$.3.5[n]={z:0};i=$.3.5[n].z;$.3.5[n].z++;$.3.5[n].l=$.3.5[n].l||a.l||$(4).1f(\'B\');6(i==0){$.3.5[n].f=$(\'<R S="1j" N="\'+n+\'" C=""\'+(a.l?\' B="B"\':\'\')+\'/>\');$(4).U($.3.5[n].f);6($.3.5[n].l||a.1m){}V{$(4).U($(\'<w X="x"><a E="\'+a.x+\'">\'+a.T+\'</a></w>\').Z(7(){$.3.8.m(n,4,a);$(4).k(\'t\')}).10(7(){$.3.8.r(n,4,a);$(4).A(\'t\')}).p(7(){$.3.8.p(n,4,a)}))}};h=$(\'<w X="12"><a E="\'+(4.E||4.C)+\'">\'+4.C+\'</a></w>\');$(4).1u(h);6(a.1O)a.o=2;6(1w a.o==\'1x\'&&a.o>0){j b=($.13.G?$(h).G():0)||a.L;j c=(i%a.o),H=1z.1A(b/a.o);$(h).G(H).1B(\'a\').1C({\'1D-1E\':\'-\'+(c*H)+\'1F\'})};$(h).k(\'u\'+n);6($.3.5[n].l)$(h).k(\'1G\');V $(h).k(\'1H\').Z(7(){$.3.8.m(n,4,a);$.3.8.I(n,4,a,\'J\')}).10(7(){$.3.8.m(n,4,a);$.3.8.r(n,4,a)}).p(7(){$.3.8.p(n,4,a)});6(4.1I)$.3.5[n].q=h;$(4).1J();6(i+1==4.14)$.3.8.r(n,4,a)});1K(n 1L $.3.5)(7(c,v,n){6(!c)F;$.3.8.I(n,c,d||{},\'1N\');$(v).9($(c).s(\'a\').y())})($.3.5[n].q,$.3.5[n].f,n);F 4};$(7(){$(\'R[S=1v].12\').3()})})(P);',62,113,'|||rating|this|groups|if|function|event|val||||||valueElem||eStar||var|addClass|readOnly|drain||split|click|current|reset|children|star_on|star_group_||div|cancel|text|count|removeClass|disabled|value|apply|title|return|width|spw|fill|hover|extend|starWidth|metadata|name|prevAll|jQuery|andSelf|input|type|cancelValue|before|else|blur|class|focus|mouseover|mouseout|callback|star|fn|length|meta||data|null|browser|unnamed|replace|_|Cancel|siblings|attr|Rating|msie|star_hover|hidden|try|document|required|is|execCommand|star_|BackgroundImageCache|false|true|catch|after|radio|typeof|number|each|Math|floor|find|css|margin|left|px|star_readonly|star_live|checked|remove|for|in|window|on|half'.split('|'),0,{}))
+eval(function(p,a,c,k,e,r){e=function(c){return(c<62?'':e(parseInt(c/62)))+((c=c%62)>35?String.fromCharCode(c+29):c.toString(36))};if('0'.replace(0,e)==0){while(c--)r[e(c)]=k[c];k=[function(e){return r[e]||e}];e=function(){return'([3-9i-mo-zA-Z]|1\\w)'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}(';6(window.J)(7($){6($.browser.msie)try{document.execCommand("BackgroundImageCache",false,true)}catch(e){}$.3={t:\'Cancel Rating\',K:\'\',l:0,L:16,5:{},z:0,8:{A:7(c,b,a,d){4.m(c);$(b).M(\'.u\'+c).N().o(\'star_\'+(d||\'O\'));k f=$(b).v(\'a\');9=f.w();6(a.P)a.P.B($.3.5[c].i[0],[9,f[0]])},m:7(c,b,a){$.3.5[c].i.siblings(\'.u\'+c).C(\'x\').C(\'star_hover\')},q:7(c,b,a){6(!$($.3.5[c].r).is(\'.t\'))$($.3.5[c].r).M(\'.u\'+c).N().o(\'x\');k d=$(b).v(\'a\');9=d.w();6(a.Q)a.Q.B($.3.5[c].i[0],[9,d[0]])},s:7(c,b,a){$.3.5[c].r=b;k d=$(b).v(\'a\');9=d.w();$.3.5[c].i.9(9);$.3.8.m(c,b,a);$.3.8.q(c,b,a);6(a.R)a.R.B($.3.5[c].i[0],[9,d[0]])}}};$.S.3=7(g){6(4.T==0)D 4;g=$.U({},$.3,g||{});$.3.z++;4.each(7(c){k b=$.U({},g||{},($.V?$(4).V():($.meta?$(4).data():null))||{});k a=(4.W||\'unnamed-3\').replace(/\\[|\\]+/g,"_");a=$.3.z+\'_\'+a;6(!$.3.5[a])$.3.5[a]={E:0};c=$.3.5[a].E;$.3.5[a].E++;$.3.5[a].p=$.3.5[a].p||b.p||$(4).attr(\'F\');6(c==0){$.3.5[a].i=$(\'<X Y="hidden" W="\'+a+\'" G=""\'+(b.p?\' F="F"\':\'\')+\'/>\');$(4).Z($.3.5[a].i);6($.3.5[a].p||b.required){}10{$(4).Z($(\'<y 11="t"><a H="\'+b.t+\'">\'+b.K+\'</a></y>\').12(7(){$.3.8.m(a,4,b);$(4).o(\'x\')}).13(7(){$.3.8.q(a,4,b);$(4).C(\'x\')}).s(7(){$.3.8.s(a,4,b)}))}};j=$(\'<y 11="14"><a H="\'+(4.H||4.G)+\'">\'+4.G+\'</a></y>\');$(4).after(j);6(b.half)b.l=2;6(typeof b.l==\'number\'&&b.l>0){k d=($.S.I?$(j).I():0)||b.L;k f=(c%b.l),h=Math.floor(d/b.l);$(j).I(h).find(\'a\').css({\'margin-left\':\'-\'+(f*h)+\'px\'})};$(j).o(\'u\'+a);6($.3.5[a].p)$(j).o(\'star_readonly\');10 $(j).o(\'star_live\').12(7(){$.3.8.m(a,4,b);$.3.8.A(a,4,b,\'O\')}).13(7(){$.3.8.m(a,4,b);$.3.8.q(a,4,b)}).s(7(){$.3.8.s(a,4,b)});6(4.checked)$.3.5[a].r=j;$(4).remove();6(c+1==4.T)$.3.8.q(a,4,b)});for(n in $.3.5)(7(c,b,a){6(!c)D;$.3.8.A(a,c,g||{},\'on\');$(b).9($(c).v(\'a\').w())})($.3.5[n].r,$.3.5[n].i,n);D 4};$(7(){$(\'X[Y=radio].14\').3()})})(J);',[],67,'|||rating|this|group|if|function|event|val|||||||||valueElem|eStar|var|split|drain||addClass|readOnly|reset|current|click|cancel|star_group_|children|text|star_on|div|calls|fill|apply|removeClass|return|count|disabled|value|title|width|jQuery|cancelValue|starWidth|prevAll|andSelf|hover|focus|blur|callback|fn|length|extend|metadata|name|input|type|before|else|class|mouseover|mouseout|star'.split('|'),0,{}))
View
BIN  star-rating.zip
Binary file not shown
Please sign in to comment.
Something went wrong with that request. Please try again.