Security News
The Dark Side of Open Source
At Node Congress, Socket CEO Feross Aboukhadijeh uncovers the darker aspects of open source, where applications that rely heavily on third-party dependencies can be exploited in supply chain attacks.
raty-js
Advanced tools
Changelog
v4.2.0
half
option is true
; #249 by fono09Readme
It's Rating: https://github.com/wbotelhos/rating :star:
v3
to v4
check the Upgrade document.<script src="raty.js"></script>
<div data-raty></div>
new Raty(document.querySelector('[data-raty]'));
<link rel="stylesheet" href="raty.css">
<script src="raty.js"></script>
<div data-raty></div>
new Raty(document.querySelector('[data-raty]'), { starType: 'i' });
Property | Default | Description |
---|---|---|
cancelButton | 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. |
To call some function, first save the Raty instance on a variable and then call the functions:
var raty = new Raty(document.querySelector('[data-raty]'));
Function | Description |
---|---|
raty.score() | Get the current score. |
raty.score(number) | Set a score. |
raty.click(number) | Click on a star. |
raty.readOnly(boolean) | Change the read-only state. |
raty.cancel(boolean) | Cancel the rating. The last param force the click callback. |
raty.move(number) | Move the mouse to the given score point position. |
FAQs
Raty - A Star Rating Plugin
The npm package raty-js receives a total of 10,331 weekly downloads. As such, raty-js popularity was classified as popular.
We found that raty-js demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
At Node Congress, Socket CEO Feross Aboukhadijeh uncovers the darker aspects of open source, where applications that rely heavily on third-party dependencies can be exploited in supply chain attacks.
Research
Security News
The Socket Research team found this npm package includes code for collecting sensitive developer information, including your operating system username, Git username, and Git email.
Security News
OpenJS is warning of social engineering takeovers targeting open source projects after receiving a credible attempt on the foundation.