GithubHelp home page GithubHelp logo

starrr's Introduction

starrr

1-5 (or 1-n) star rating in < 75 lines of code.

Requirements

  • jQuery

Usage

Create the stars

<div class='starrr'></div>
$('.starrr').starrr()

With an existing rating

$('.starrr').starrr({
  rating: 4
})

With more than 5 stars

$('.starrr').starrr({
  max: 10
})

Read-only

$('.starrr').starrr({
  readOnly: true
})

Do something with the rating...

$('.starrr').starrr({
  change: function(e, value){
    alert('new rating is ' + value)
  }
})

Or if you prefer events:

$('.starrr').on('starrr:change', function(e, value){
  alert('new rating is ' + value)
})

Developing

  • npm install
  • npm install -g grunt-cli
  • Make changes in src/
  • Run grunt to compile them

License

MIT

starrr's People

Contributors

ajb avatar placha433 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

starrr's Issues

Ajax response Star is not displaying

In my code html content with

was displaying into a div in ajax success

success:function(data) { $('.review_data').html(data.review_data);

here star was not displaying

hover event?

First off,
Amazing little star rating plugin.
Thank you for creating it!

Would like to add a hover event so that if you hover above star 1,2,3,4,5 the value is send back to the browser so you could do an alert. Just like the regular click star -> alert. But then on hover.
Is this hard to add ? Im not a jquery coder myself but will try to digg your code a bit more to see where I could come up with.

I suggest removing the font-size 16px on the .starrr i element so you can use fa-2x to have bigger icons also.

Does not work in IE7

Mouse over effect does not work...
Can you please make it work in IE7?
Thanks!

Support for half stars

Is there any way to allow half stars (3.5 stars for example)? I know FontAwesome has the icon for a half star

Can we replace star images?

Hi, i am new to Web Development. can anyone please tell if i can add my custom star image ? if No then there is any other way to do so?

iPad trouble on click

sharing my resolution: adding "touchstart" event to starrr.js
this.$el.on('click.starrr touchstart.starrr', 'i', (function(_this) {

readOnly not working

$('.starrr').starrr({
readOnly: true
})

i have problem with read only option its not working

clicking twice at the same star = undefined

In example:

When the star-rating is 5, and you click at the 5'th star again, the rating-value is undefined in the onchange.

$('.starrr').starrr ({ change: function(e, value){ alert('new rating is ' + value) // First time all good, second time clicking the same star result is undefined } })

Default font-awesome classes should be updated

With font-awesome 5.8.2 (as of 2019-06-05),
the star classes should be these:

        $('.starrr').starrr({
            rating: 5,
            emptyClass: 'far fa-star',
            fullClass: 'fas fa-star',
        })

In your current code, the default class for empty is: fa fa-star-o
which is not supported anymore, and so nothing will display, which is confusing.

How to re-initialize the rating?

Hello,

Thanks a lot for your very efficient plugin. Nevertheless, I met an issue: in my project, end-users could use this rating function several times in the same page. Ideally the value of starrr would be re-initialized each time an item is evaluated but it is not, so end-users always see the previous rating. I tried the following line $('.starrr').data('rating',0); but this does not work. Is there any way to re-initialize the value of starr ?

Thanks,

Pierre

Read-Only

Hi,

Thanks for a great snippet. Is it possible to have this be read-only in order to display the reviews previously set?

Best regards

How to show starrr as disabled?

I want to show final rating based on the rating given by users. How can I do that? I do not want stars to go away on mouseover at result page.

Set Rating dynamically

When i use this:

$('.starrr').starrr({ rating: $(this).attr('data-rating'),

It does not set the rating...

Add gradient to stars

It would be nice if this plugin can also support gradient stars. Users will be able to set start color and end color and stars will be rendered with linear gradient from start color to end color.

How to initialize multiple star ratings

I'am trying to use this plugin into a simple comment system, more then one user can leave ratings of a product, so I must initialize several star ratings with its own rating value, until now I have done the following code:

$('.stars-users').starrr({
    readOnly: true,
    rating: $(this).data('rating')
});

Can anybody give me a help?

Thanks!

Keyboard support and half star rating

Hi there!

Thanks for your nice code.

Is there any chance you would add a keyboard support : tabulation and space bar ?

And secondly, any chance the code may work for intermediate rate levels (half star or even less) : 1.5, 2.5?

Thanks in advance for your reading.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.