Giter VIP home page Giter VIP logo

gjunge / rateit.js Goto Github PK

View Code? Open in Web Editor NEW
162.0 8.0 45.0 633 KB

Rating plugin for jQuery. Fast, Progressive enhancement, touch support, icon-font support, highly customizable, unobtrusive JavaScript (using HTML5 data-* attributes), RTL support, supports as many stars as you'd like, and also any step size.

License: MIT License

CSS 14.98% JavaScript 85.02%
star rating-plugin rateit jquery rating

rateit.js's Introduction

RateIt

Rating plugin for jQuery.

npm version NuGet

Quick start

Several quick start options are available:

  • Download the latest release.
  • Clone the repo: git clone https://github.com/gjunge/rateit.js.git.
  • Install with npm: npm install jquery.rateit.
  • Install with NuGet: Install-Package jQuery.RateIt.

Read the Wiki documentation or look at the examples page.

About

Fast, Progressive enhancement, touch support, customizable (just swap out the images, or change some CSS), Unobtrusive JavaScript (using HTML5 data-* attributes), RTL support, supports as many stars as you'd like, and also any step size.

Your feedback is more than welcome!

Why is RateIt different

Although it does the same job as the rest of the jQuery star rating plugins, the main difference is its simplicity. Most plugins create an element for each (partial) star, be it a div with a star background, or an img tag. Each of these tags gets a hover event, and a click event. And on these hover/click events it has to go and talk to the other stars, telling them to change their state.

So each star plugin does a lot of DOM alterations (adding the number of stars as elements), and adds lots of events (again the number of stars times 2).

RateIt uses basically three divs. One background (the inactive state), and two divs on top (the hover, and selected state). In addition it only attaches three event handlers (not counting the use of the reset button aside). Each of these divs has a x-repeating background, enabling as many stars as you want (or a big image with for example 5 different smilies one next to the other) without adding more elements or event handlers. Based on the position of the mouse, or the selected value, a certain width is applied to the selection div or the hover div.

Credits

rateit.js's People

Contributors

bryant1410 avatar dandv avatar dependabot[bot] avatar gjunge avatar jgierer12 avatar lal65 avatar maurojs10 avatar mossaab0 avatar mpolleke 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

rateit.js's Issues

rateit.js tooltip in Meteor

I have this which is working well:

    <div class="form-group">
                            <label for="difficulty" class="col-sm-2 control-label">
                                Condition
                            </label>
                            <div class="col-sm-10">
                                <select id="difficulty" class="form-control select2">
                                    {{#each difficultyLevels}}
                                        <option value="{{_id}}">{{level}}</option>
                                    {{/each}}
                                </select>
                                <div class="rateit" data-rateit-backingfld="#difficulty" data-rateit-step="1"></div>                            
                            </div>
                        </div>

Helper:

    difficultyLevels(){
            return DifficultyLevels.find({}, {sort: {"_id":1}});
        }

Now I would like to add a tooltip to each option (star). The text is the same {{level}} value.
How can I do that in meteor 1.3?

I've seen this: rateit tooltip but still cannot make it work.

Thank you

rateit with jquery mobile

Rate it is not displaying my stars properly when i'm trying to load it on my phonegap / cordova jquery mobile app. It's displaying stars as â~... for 1 star and so on. Do you have a fix?

Unable to get step=0.25 , It always remain 0.5

Hi , I am trying to set step value on 0.25 but its always acting on 0.25. My code is

 <div class="y-meter-rating">

                                <div style="font-size:53px" id="y-demo" class="rateit" data-rateit-icon="M"
                                     data-rateit-mode="font">
                                </div>
                                <script type="text/javascript">
                                    $('#y-demo').rateit({
                                        max: 5,
                                        step: 0.25,

                                    });
                                    var selected = 0;
                                    $("#y-demo").bind('over', function (event, value) {
                                        if (value == null) {
                                            $('#value6').text(selected);
                                        } else {
                                            $('#value6').text(value);
                                        }
                                    });

                                    $("#y-demo").bind('rated', function (event, value) {
                                        selected = value
                                        $('#value6').text(value);
                                    });


                                </script>
                                {#                                <div id="rateYo1" style="width: 200px !important;"></div>#}
                                <div id="data-show" class="data-show data-show-y" style="width: 100%;">
                                    <p id="value6">0.0</p>
                                </div>
                            </div>
                        </div>
                    </div>

Kindly notify if its plugin issue or I am doing something wrong. I am drawing on M alphabet

The reset button is not accessible to visually impaired users

Because the reset button is given a role of none, it's not announced by assistive technology.

To resolve this, I think all that we have to do is remove the role attribute and let the button semantics reflect through. I'll open a pull request shortly.

Thanks!

rateit version with wordpress version

i belive the rateit version not is compatible with the lastest wordpress version, when i used the plugin, stars do not display in my div in theme.

i needs help, please.

Resize issue

Cannot able to re size the star icon followed as per the documentation . And also when the value is being reset rateit star icon is not getting resetted .

<td><span> error!

I tried implementing rateit into my table with but its not showing up. The table is dynamically generated. Any idea why?

dir="rtl" not working programmatically

dir="rtl" on the rateit element seem to work, but dir="auto" does not work.

My language direction is not known in advance, and I need to set it programmatically.
Setting the css attribute "direction" or attr "dir" doesn't seem to have an impact on direction.

Please advise.

Step size with custom image star

Hi!! I have added custom star image(using CSS), and I have set "readonly: true; ispreset: true; step: 0.5", but it's still showing 0.1 step increment.

Large formatting issue

We are using this HTML code, which is pretty straightforward:

<div class='my-4' data-controller='rated'>
    <div class='rateit' data-rateit-mode='font' data-rateit-resetable='false' style='font-size: 58px'></div>
</div>

But are seeing this when hovering:

Screen Shot 2021-08-27 at 8 21 51 AM

Screen Shot 2021-08-27 at 8 26 11 AM

Any thoughts? We tried reinstantiating the plugin but the same thing happens

Examples page request

Great plugin! Thank you.

I have two sets of review stars for an item. One is the "overall rating" and the other is "my rating" - allows people to see how they rated the item. I'd like to use ajax/jquery to update the overall rating when someone rates or updates their rating in the "my rating" section.

No problem with ajax in getting the rating to save in the back end, but I'm having trouble getting the "overall rating" to update to reflect the new numbers.

Will you consider adding an example where rateit is being set by a json string? I have been experimenting with the way you use the buttons to dynamically set values but I'm not getting anywhere.

Create vanilla-js implementation

We would like to have a none jquery version of rateit.js

This way we can be relevant also in modern platforms that do not include jQuery.

Strange behavior

Hello

first of all it is a very good job

My issue is

                             <select id="packaging">
                                <option value="0">0</option>
                                <option value="2">2</option>
                                <option value="5">5</option>
                            </select>
                            <div class="rateit" data-rateit-backingfld="#packaging" data-rateit-min="0" ></div>
``
Strange behavior
I can select 0,2,4,6 stars the 6th appears when I pass over the 5th star. But I would like to select only 0,2 & 5 stars

Thank you for reading, 

Proposal for enhancement

Hi
I work with ansp.net core 2.2 and have looked for rate controls, investigated some and decided for rateit.js as it is lean an clean - especially to pass the parameters over an input is a good idea.
So.. first... congrats for your good work.
What is missing, is the possibility to show (custom) tool-tips on hoover over the stars and to show a (custom) text, when the user has rated.
I have implemented the texte to rated myself, but this is not so nice and a lot of work (I have various rateit's on my view).
So... proposal:
Add parameters for custom text to the Rating/ the stars, E.g.:
ResetOnHooverText (= "Reset your Rating" / German "Setzen Sie Ihre Bewertung zurück)
Star1OnHooverText (= "Very Poor" / German: "Sehr schlecht")
Star1OnRatedText (= "Very Poor" / German: "Sehr schlecht")
Star2OnHooverText (= "Poor" / German: "Schlecht")
Star2OnRatedText (= "Poor" / German: "Schlecht")
Star3OnHooverText (= "Neutral" / German: "Neutral")
Star3OnRatedText (= "Neutral" / German: "Neutral" )
Star4OnHooverText (= "Good" / German: "Gut")
Star4OnRatedText (= "Good" / German: "Gut"))
Star5OnHooverText (= "Very good" / German: "Sehr gut")
Star5OnRatedText (= "Very good" / German: "Sehr gut"))
.... further Star.. if used (I think. mostly 4 or 5 stars are used...)
NotRatedText (= "Not Rated" / German: "Nicht bewertet")

Show the OnHoover text (as tooltip) if a star or the reset symbol is hoovered.
Show the RatedText on the right of the control
Define a further input for these parameters

valuesrc = index problem

i use custom value. in js, $('#getbacking' + i).rateit('value');

i just got the index not. the value.. why? how to solve it

tabindex on readonly is not good for accessibility

Hi, thank you for this jQuery plugin.
When the star rating is set to readonly, it still adds tabindex="0" to the html. When tabbing through the webpage over links and form elements, this element is being focused as well. It is however not editable, so there is no point in giving it focus on tabbing. This will add confusion for people with disabilities who depend on their keyboard.

I think it is better to only have tabindex="0" when the star rating is editable, but not when readonly.

Can script render in responsive layout?

I'm using this tool to rating on my website, but it does not be responsive layout.. would it be possible to render stars rating in responsive layout for using in mobile devices?

Star.gif

Hi,

It would be great to allow to define the path of star.gif directly in the javascript/jquery declaration.
I use gulp and a lot of tools and I end with the plugin not displaying the stars because it is looking for the star.gif where my final css build is stored...

I work around but it a suggestion you may consider.

:-)

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.