jQuery Raty - A Star Rating Plugin (current version: 1.0.0)
jQuery Raty is a plugin that generates a customizable star rating automatically.
With default options:
$('#default').raty();
<div id="default"></div>
Started with a score and read only value:
$('#fixed').raty({
readOnly: true,
start: 2
});
<div id="fixed"></div>
A hint for no rated elements when it's read-only:
$('#anyone').raty({
readOnly: true,
noRatedMsg: 'anyone rated this product yet!'
});
<div id="anyone"></div>
With a custom score name and a number of stars:
$('#number').raty({
scoreName: 'entity.score',
number: 10
});
<div id="number"></div>
Using onClick function:
$('#click').raty({
onClick: function(score) {
alert('score: ' + score);
}
});
<div id="click"></div>
Displaying half star:
$('#half').raty({
start: 3.3,
showHalf: true
});
<div id="half"></div>
With a default cancel button:
$('#cancel').raty({
showCancel: true
});
<div id="cancel"></div>
With a custom cancel button:
$('#cancel-custom').raty({
cancelHint: 'remove my rating!',
cancelPlace: 'right',
showCancel: true
onClick: function(score) {
alert('score: ' + score);
}
});
<div id="cancel-custom"></div>
With a custom hint and icons:
$('#icon').raty({
hintList: ['a', '', null, 'd', '5'],
starOn: 'medal-on.png',
starOff: 'medal-off.png'
});
<div id="icon"></div>
With a range of custom icons:
$('#range').raty({
iconRange: [['face-a.png', 2], ['face-b.png', 3], ['face-c.png', 4], ['face-d.png', 5]],
starOff: 'face-off.png'
});
<div id="range"></div>
With a group of elements:
$('.group').raty();
<div class="group"></div>
<div class="group"></div>
<div class="group"></div>
Using directed actions with public functions:
love:
happy:
your last rate:
$('.target').raty({
showHalf: true,
onClick: function(score) {
$.fn.raty.start(0, '.target');
$.fn.raty.start(score, '#result');
}
});
<div class="target"></div>
<div class="target"></div>
<div id="result"></div>
Default options:
cancelHint: 'cancel this rating!'
The hint information.
cancelOff: 'cancel-off.png'
Name of the cancel image off.
cancelOn: 'cancel-on.png'
Name of the cancel image on.
cancelPlace: 'left'
Position of the cancel button.
hintList: ['bad', 'poor', 'regular', 'good', 'gorgeous']
List of names that will be used as a hint on each star.
iconRange: []
Path where are the images of the stars.
noRatedMsg: 'not rated yet'
A hint for no rated elements when it's read-only.
number: 5
Number of stars that will be presented.
path: 'img/'
A range of custom icons that you can set.
readOnly: false
If the stars will be read-only.
scoreName: 'score'
Name of the hidden field that holds the score value.
showCancel: false
If will be showed a button to cancel the rating.
showHalf: false
If will show half star if come a float number as score.
starHalf: 'star-half.png'
The name of the half star image.
starOff: 'star-off.png'
Name of the star image off.
starOn: 'star-on.png'
Name of the star image on.
start: 0
Number of stars to be selected.
onClick: null
Function that returns the selected value.
Public functions:
$.fn.raty.start(3);
Starting the rating with 3 stars later.
$.fn.raty.readOnly(true);
Adjusts the rating for read-only later.
$.fn.raty.click(2);
Click in the star number 2 later.