MIT License

项目介绍

wbotelhos/raty 是一个托管在 GitHub 上的开源项目,主要使用 JavaScript 编写,采用 MIT License 许可证,目前获得 2.3k 个 Star、636 次 Fork。

仓库全名
wbotelhos/raty
开源许可证
MIT License
Star 数
2.3k
Fork 数
636
未关闭 Issue
59

README 摘要

Raty - A Star Rating Plugin. Rating for Rails? It's Rating: https://github.com/wbotelhos/rating :star: Help Check the Tutorial to learn about all available features. If you're migrating from v3 to v4 check the Upgrade document. Usage with Image raty.js star-off.png star-on.png Usage with Font raty.css raty.[eot|svg|ttf|woff] raty.js Options Property | Default |Description | cancelButton |false |Creates a cancel…

完整内容见 GitHub 原始 README 或本页 。

常见问题

raty 用什么语言开发?

主要使用 JavaScript 编写,采用 MIT License 许可证,目前有 2.3k 个 Star。

raty 可以免费商用吗?

仓库采用 MIT License 许可证,可免费使用与修改,商业使用请遵守许可证条款(例如保留版权声明与许可声明)。

如何获取 raty 的源码?

可以直接克隆仓库:git clone https://github.com/wbotelhos/raty.git,默认分支为 main;安装与运行步骤见仓库 README。

raty 最近还在维护吗?

仓库最近一次更新为 2024年4月28日,当前有 59 个未关闭 Issue;Star 数为 2.3k,可作为社区活跃度的参考。

简要分析

热度分
3679
价值分
1595
活跃状态
活跃

语言占比

CSS
JavaScript

Release

README

Raty - A Star Rating Plugin.

Tests NPM Version Maintainability Sponsor

Rating for Rails?

It’s Rating: https://github.com/wbotelhos/rating :star:

Help

  • Check the Tutorial to learn about all available features.
  • If you’re migrating from v3 to v4 check the Upgrade document.

Usage with Image

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

<div data-raty></div>
const raty = new Raty(document.querySelector('[data-raty]'));

raty.init();

Usage with Font

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

<script src="raty.js"></script>

<div data-raty></div>
new Raty(document.querySelector('[data-raty]'), { starType: 'i' });

Options

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.

Functions

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.

Build

gulp 'amd'
gulp 'umd'
gulp 'commonjs'
gulp 'systemjs'
gulp 'es6'
gulp 'es5'
gulp 'es5-test'

评论

暂无评论