🌜
🌞
raty-js

raty-js

v3.1.1

Raty - A Star Rating Plugin

npm install raty-js

README

Raty - A Star Rating Plugin

CI NPM Version Maintainability Sponsor

Rails Rating?

This is Rating: https://github.com/wbotelhos/rating :star:

Usage with Image

  • jquery.raty.js
  • star-off.png
  • star-on.png
<script src="jquery.raty.js"></script>

<div></div>
$('div').raty();

Usage with Font

  • jquery.raty.js
  • jquery.raty.[eot|svg|ttf|woff]
  • jquery.raty.css
<link rel="stylesheet" href="jquery.raty.css">
<script src="jquery.raty.js"></script>

<div></div>
$('div').raty({ starType: 'i' });

Options

Property Default Description
cancel false Creates a cancel button to cancel the rating.
cancelClass 'raty-cancel' Name of cancel's class.
cancelHint 'Cancel this rating!' The cancel's button hint.
cancelOff 'cancel-off.png' Icon used on active cancel.
cancelOn 'cancel-on.png' Icon used inactive cancel.
cancelPlace 'left' Cancel's button position.
click undefined Callback executed on rating click.
half false Enables half star selection.
halfShow true Enables half star display.
hints ['bad', 'poor', 'regular', 'good', 'gorgeous'] Hints used on each star.
iconRange undefined Object list with position and icon on and off to do a mixed icons
iconRangeSame false All icons prior to selection will be the same as the selection.
mouseout undefined Callback executed on mouseout.
mouseover undefined Callback executed on mouseover.
noRatedMsg 'Not rated yet!' Hint for non rated elements when it's readOnly.
number 5 The number of stars that will be presented.
numberMax 20 Max number of stars star the option number will create.
path undefined A global path where the icon will be found.
precision false Enables the selection of a precise score.
readOnly false Turns the rating read-only.
round { down: .25, full: .6, up: .76 } Includes value attributes to do the score rounding math.
score undefined Initial rating.
scoreName 'score' Name of the hidden field that holds the score value.
single false Enables single star selection.
space true Puts space between the icons.
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.
target undefined Element selector where the score will be displayed.
targetFormat '{score}' Template to interpolate the score in.
targetKeep false If the last rating value will be kept on mouseout.
targetScore undefined Score field target avoiding hidden field creation
targetText '' Default text in a target.
targetType 'hint' Choose if target will receive a hint or the score number
starType 'img' Element used to represent a star.

Functions

Function Description
$('div').data('raty).score(); Get the current score.
$('div').data('raty).score(number); Set a score.
$('div').data('raty).click(number); Click on a star.
$('div').data('raty).readOnly(boolean); Change the read-only state.
$('div').data('raty).cancel(boolean); Cancel the rating. The last param force the click callback.
$('div').data('raty).move(number); Move the mouse to the given score point position.

Release Notes

3.1.1
By Washington Botelho • Published on September 30, 2021

Bugfix

3.1.0
By Washington Botelho • Published on September 28, 2021

News

  • Adds iconRangeSame option where the previous stars will be the same as the selected one; #135 by viniciusjl

Update

3.0.0
By Washington Botelho • Published on October 31, 2020

Break Change

  • Function destroy was removed;
  • Function reload was removed;
  • Function set was removed;
  • Functions now is accessed via element.data('raty').FUNCTION_NAME();
  • Option cancel was renamed to cancelButton;

Bugfix

Update

  • Grammars fixes; #217 by tfantina
  • All the code were migrated to pure Prototype. Vanilla JS coming soon!;
2.9.0
By Washington Botelho • Published on October 25, 2018

Changes

Drops engines from package.json for greater flexibility;

2.8.0
By Washington Botelho • Published on November 2, 2017

News

  • Add support to configure options via $.data().
2.7.1
By Washington Botelho • Published on September 23, 2016

Fixes

  • Fix readOnly when using fonts; (Amaia Baigorri)

News

  • Added Bower package; (yadhu)
  • Added path options as callback; (tyler-king)
2.7.0
By Washington Botelho • Published on January 25, 2016

Fixes

  • Function move was losing precision with float with more then one digit;
  • Function move was losing the saved options data;
  • With half enable, mousemove was not changing to full star after 0.5 point;
  • With half enable, score field was receiving precision value. (reported by hoangnham01)

Changes

  • If you returns false into click callback, the action will be prevented;
  • When precision is on it won't force targetType to be score anymore.

News

  • Added support to float hints;

General

License
MIT
Typescript Types
None found
Tree-shakeable
No

Popularity

GitHub Stargazers
2,322
Community Interest
3,046
Number of Forks
662

Maintenance

Commits
11/2110/2204
Last Commit
Open Issues
51
Closed Issues
129
Open Pull Requests
8
Closed Pull Requests
21

Versions

Versions Released
11/2110/2201
Latest Version Released
Sep 30, 2021
Current Tags
latest3.1.1

Contributors

wbotelhos
wbotelhos
Commits: 516
stecb
stecb
Commits: 7
danielpsf
danielpsf
Commits: 6
fsouza
fsouza
Commits: 3
eriwen
eriwen
Commits: 3
tfantina
tfantina
Commits: 2
hpgihan
hpgihan
Commits: 2
juriejan
juriejan
Commits: 2
yadhu
yadhu
Commits: 2
muratguzel
muratguzel
Commits: 1
havvg
havvg
Commits: 1
dentarg
dentarg
Commits: 1
danielfariati
danielfariati
Commits: 1
OlegKi
OlegKi
Commits: 1
eblanshey
eblanshey
Commits: 1