Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
 7d9fe731-5e54-0410-9b70-c3ef49213c18
  • Loading branch information
diego.alto committed Mar 13, 2009
1 parent e4c2dd1 commit f6d07dd
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 48 deletions.
8 changes: 4 additions & 4 deletions 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.62 (2009-03-12)</title>
<title>jQuery Star Rating Plugin v2.63 (2009-03-13)</title>
<!--// documentation resources //-->
<script src="jquery-1.31.js" type="text/javascript"></script>
<script src="documentation.js" type="text/javascript"></script>
Expand Down Expand Up @@ -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.62</strong>
v<strong>2.63</strong>
</span>
</td>
<td valign="middle" width="450" align="right">
Expand Down Expand Up @@ -748,7 +748,7 @@ <h2>Download</h2>
<td valign="top">
<big>
<img src="/@/download.gif" style="margin:0 5px 5px 0; float:left;">
v<strong>2.62</strong>
v<strong>2.63</strong>
<a href="http://jquery-star-rating-plugin.googlecode.com/svn/trunk/star-rating.zip"><strong>star-rating.zip</strong></a>
</big>
</td>
Expand Down Expand Up @@ -827,7 +827,7 @@ <h2>Alternative Download - From this website</h2>
<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.62</strong>
v<strong>2.63</strong>
<a href="star-rating.zip"><strong>star-rating.zip</strong></a>
</td>
</tr>
Expand Down
84 changes: 42 additions & 42 deletions jquery.rating.js
@@ -1,5 +1,5 @@
/*
### jQuery Star Rating Plugin v2.62 - 2009-03-12 ###
### jQuery Star Rating Plugin v2.63 - 2009-03-13 ###
* Home: http://www.fyneworks.com/jquery/star-rating/
* Code: http://code.google.com/p/jquery-star-rating-plugin/
*
Expand Down Expand Up @@ -46,35 +46,35 @@
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]);
this.drain(n);
$(el).prevAll('.star_group_'+n).andSelf().addClass('star_'+(state || 'hover'));
fill: function(gid, el, settings, state){ // fill to the current mouse position.
//if(window.console) console.log(['fill', $(el), $(el).prevAll('.star_group_'+gid), arguments]);
this.drain(gid);
$(el).prevAll('.star_group_'+gid).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.group[n].valueElem[0], [val, lnk[0]]);
if(settings.focus) settings.focus.apply($.rating.group[gid].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.group[n].valueElem.siblings('.star_group_'+n).removeClass('star_on').removeClass('star_hover');
drain: function(gid, el, settings) { // drain all the stars.
//if(window.console) console.log(['drain', $(el), $(el).prevAll('.star_group_'+gid), arguments]);
$.rating.group[gid].valueElem.siblings('.star_group_'+gid).removeClass('star_on').removeClass('star_hover');
},
reset: function(n, el, settings){ // Reset the stars to the default index.
if(!$($.rating.group[n].current).is('.cancel'))
$($.rating.group[n].current).prevAll('.star_group_'+n).andSelf().addClass('star_on');
reset: function(gid, el, settings){ // Reset the stars to the default index.
if(!$($.rating.group[gid].current).is('.cancel'))
$($.rating.group[gid].current).prevAll('.star_group_'+gid).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.group[n].valueElem[0], [val, lnk[0]]);
if(settings.blur) settings.blur.apply($.rating.group[gid].valueElem[0], [val, lnk[0]]);
},
click: function(n, el, settings){ // Selected a star or cancelled
$.rating.group[n].current = el;
click: function(gid, el, settings){ // Selected a star or cancelled
$.rating.group[gid].current = el;
var lnk = $(el).children('a'); val = lnk.text();
// Set value
$.rating.group[n].valueElem.val(val);
$.rating.group[gid].valueElem.val(val);
// Update display
$.rating.event.drain(n, el, settings);
$.rating.event.reset(n, el, settings);
$.rating.event.drain(gid, el, settings);
$.rating.event.reset(gid, el, settings);
// click callback, as requested here: http://plugins.jquery.com/node/1655
if(settings.callback) settings.callback.apply($.rating.group[n].valueElem[0], [val, lnk[0]]);
if(settings.callback) settings.callback.apply($.rating.group[gid].valueElem[0], [val, lnk[0]]);
}
}// plugin events
};
Expand Down Expand Up @@ -103,36 +103,36 @@

// Generate internal control ID
// - ignore square brackets in element names
var n = (this.name || 'unnamed-rating').replace(/\[|\]+/g, "_");
var eid = (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;
var gid = $.rating.calls +'_'+ eid;

// Grouping
if(!$.rating.group[n]) $.rating.group[n] = {count: 0};
i = $.rating.group[n].count; $.rating.group[n].count++;
if(!$.rating.group[gid]) $.rating.group[gid] = {count: 0};
i = $.rating.group[gid].count; $.rating.group[gid].count++;

// Accept readOnly setting from 'disabled' property
$.rating.group[n].readOnly = $.rating.group[n].readOnly || settings.readOnly || $(this).attr('disabled');
$.rating.group[gid].readOnly = $.rating.group[gid].readOnly || settings.readOnly || $(this).attr('disabled');

// Things to do with the first element...
if(i == 0){
// Create value element (disabled if readOnly)
$.rating.group[n].valueElem = $('<input type="hidden" name="' + n + '" value=""' + (settings.readOnly ? ' disabled="disabled"' : '') + '/>');
$.rating.group[gid].valueElem = $('<input type="hidden" name="' + eid + '" value=""' + (settings.readOnly ? ' disabled="disabled"' : '') + '/>');
// Insert value element into form
$(this).before($.rating.group[n].valueElem);
$(this).before($.rating.group[gid].valueElem);

if($.rating.group[n].readOnly || settings.required){
if($.rating.group[gid].readOnly || settings.required){
// DO NOT display 'cancel' button
}
else{
// Display 'cancel' button
$(this).before(
$('<div class="cancel"><a title="' + settings.cancel + '">' + settings.cancelValue + '</a></div>')
.mouseover(function(){ $.rating.event.drain(n, this, settings); $(this).addClass('star_on'); })
.mouseout(function(){ $.rating.event.reset(n, this, settings); $(this).removeClass('star_on'); })
.click(function(){ $.rating.event.click(n, this, settings); })
.mouseover(function(){ $.rating.event.drain(gid, this, settings); $(this).addClass('star_on'); })
.mouseout(function(){ $.rating.event.reset(gid, this, settings); $(this).removeClass('star_on'); })
.click(function(){ $.rating.event.click(gid, this, settings); })
);
}
}; // if (i == 0) (first element)
Expand All @@ -157,10 +157,10 @@
};

// Remember group name so controls within the same container don't get mixed up
$(eStar).addClass('star_group_'+n);
$(eStar).addClass('star_group_'+gid);

// readOnly?
if($.rating.group[n].readOnly)//{ //save a byte!
if($.rating.group[gid].readOnly)//{ //save a byte!
// Mark star as readOnly so user can customize display
$(eStar).addClass('star_readonly');
//} //save a byte!
Expand All @@ -169,29 +169,29 @@
// Enable hover css effects
.addClass('star_live')
// Attach mouse events
.mouseover(function(){ $.rating.event.drain(n, this, settings); $.rating.event.fill(n, this, settings, 'hover'); })
.mouseout(function(){ $.rating.event.drain(n, this, settings); $.rating.event.reset(n, this, settings); })
.click(function(){ $.rating.event.click(n, this, settings); });
.mouseover(function(){ $.rating.event.drain(gid, this, settings); $.rating.event.fill(gid, this, settings, 'hover'); })
.mouseout(function(){ $.rating.event.drain(gid, this, settings); $.rating.event.reset(gid, this, settings); })
.click(function(){ $.rating.event.click(gid, this, settings); });
//}; //save a byte!

////if(window.console) console.log(['###', n, this.checked, $.rating.group[n].initial]);
if(this.checked) $.rating.group[n].current = eStar;
////if(window.console) console.log(['###', gid, this.checked, $.rating.group[gid].initial]);
if(this.checked) $.rating.group[gid].current = eStar;

// remove this checkbox - values will be stored in a hidden field
$(this).remove();

// reset display if last element
if(i + 1 == this.length) $.rating.event.reset(n, this, settings);
if(i + 1 == this.length) $.rating.event.reset(gid, this, settings);

}); // each element

// initialize groups...
for(n in $.rating.group)//{ not needed, save a byte!
(function(c, v, n){ if(!c) return;
$.rating.event.fill(n, c, instanceSettings || {}, 'on');
for(gid in $.rating.group)//{ not needed, save a byte!
(function(c, v, gid){ if(!c) return;
$.rating.event.fill(gid, c, instanceSettings || {}, 'on');
$(v).val($(c).children('a').text());
})
($.rating.group[n].current, $.rating.group[n].valueElem, n);
($.rating.group[gid].current, $.rating.group[gid].valueElem, gid);
//}; not needed, save a byte!

return this; // don't break the chain...
Expand Down
4 changes: 2 additions & 2 deletions jquery.rating.pack.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified star-rating.zip
Binary file not shown.

0 comments on commit f6d07dd

Please sign in to comment.