🌜
🌞
jquery-raty-js

jquery-raty-js

v2.8.0

jQuery Raty - A Star Rating Plugin

npm install jquery-raty-js

README

jQuery Raty - A Star Rating Plugin

Build Status NPM Version Dependency Dev Dependency Code Climate Support jQuery Raty

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

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.
mouseout:    undefined                                      // Callback executed on mouseout.
mouseover:   undefined                                      // Callback executed on mouseover.
noRatedMsg:  'Not rated yet!'                               // Hint for no rated elements when it's readOnly.
number:      5                                              // Number of stars that will be presented.
numberMax:   20                                             // Max of star the option number can creates.
path:        undefined                                      // A global locate where the icon will be looked.
precision:   false                                          // Enables the selection of a precision score.
readOnly:    false                                          // Turns the rating read-only.
round:       { down: .25, full: .6, up: .76 }               // Included values attributes to do the score round math.
score:       undefined                                      // Initial rating.
scoreName:   'score'                                        // Name of the hidden field that holds the score value.
single:      false                                          // Enables just a 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.
targetForma: '{score}'                                      // Template to interpolate the score in.
targetKeep:  false                                          // If the last rating value will be keeped after mouseout.
targetScore: undefined                                      // Element selector where the score will be filled, instead of creating a new hidden field (scoreName option).
targetText:  ''                                             // Default text setted on target.
targetType:  'hint'                                         // Option to choose if target will receive hint o 'score' type.
starType:    'img'                                          // Element used to represent a star.

Functions

$('div').raty('score');                  // Get the current score.

$('div').raty('score', number);          // Set the score.

$('div').raty('click', number);          // Click on some star.

$('div').raty('readOnly', boolean);      // Change the read-only state.

$('div').raty('cancel', boolean);        // Cancel the rating. The last param force the click callback.

$('div').raty('reload');                 // Reload the rating with the current configuration.

$('div').raty('set', { option: value }); // Reset the rating with new configurations.

$('div').raty('destroy');                // Destroy the bind and give you the raw element.

$('div').raty('move', number);           // Move the mouse to the given score point position.

Contributors

Check it out

Love it!

Via PayPal or Gratipay. Thanks! (:

Release Notes

2.8.0
By Washington Botelho • Published on April 23, 2018

News

  • Add support to configure options via $.data().

General

Typescript Types
None found
Tree-shakeable
No

Popularity

GitHub Stargazers
2,326
Community Interest
3,023
Number of Forks
661

Maintenance

Commits
11/2110/22065
Last Commit
Open Issues
50
Closed Issues
130
Open Pull Requests
7
Closed Pull Requests
21

Versions

Versions Released
11/2110/2201
Latest Version Released
Apr 23, 2018
Current Tags
latest2.8.0

Contributors

wbotelhos
wbotelhos
Commits: 509
stecb
stecb
Commits: 7
danielpsf
danielpsf
Commits: 6
fsouza
fsouza
Commits: 3
eriwen
eriwen
Commits: 3
yadhu
yadhu
Commits: 2
hpgihan
hpgihan
Commits: 2
tfantina
tfantina
Commits: 2
juriejan
juriejan
Commits: 2
ecabuk
ecabuk
Commits: 1
janapol
janapol
Commits: 1
havvg
havvg
Commits: 1
OlegKi
OlegKi
Commits: 1
nazarhussain
nazarhussain
Commits: 1
henrikhannemose
henrikhannemose
Commits: 1