Comments (10)
Ok...
Line 259 reads:
score = parseInt(this.score.val(), 10),
This rounds the score value the same way as Math.floor... I've changed this to
score = parseInt(Math.ceil(this.score.val()), 10),
...and now it shows the correct message.
from raty.
Hi shadowfax,
The hints are alt
tag, then it is one per star.
We can't change the sequence, because Raty use it to calculate a lot of things.
I want to do a feature to show real hint like a pop up and let alt
do it job: 1 2 3 4 5.
If you have some ideia of how to take off this dependency of the alt
attribute let me know.
from raty.
That simple patch doesn't seem to mess up the calculations just fixes the tiny issue I talked about. For example, if you have a rating of 0.5 the actual code at GitHub will show "No ratings yet" but half a star is shown. This makes the user think there is an error with the rating system. With that small code change it will show "Terrible". Same thing happens for other half stars.
This doesn't affect the alt tag but the title tag.
For the other issue about half stars with hints I guess it could be as simple as creating an array for hints that is the double of the size (if we got 5 stars enter 10 hints)... Then, instead of converting it to an Int just round it up to the nearest half and multiply the value by 2... then substract one as always...
0.5 * 2 = 1 --> 1 -1 = 0
1 * 2 = 2 --> 2 - 1 = 1
1.5 * 2 = 3 --> 3-1 = 2
...
5*2 = 10 --> 10-1 = 9
And there you go, hints for half stars
Edit: Just make sure the length of the hints is equal to the number of stars * 2 and half stars are enabled before aplying this formulas. Rounding to the nearest half:
nearestHalf = Math.Round(score/0.5) * 0.5;
Maybe it's not a clean hack but certainlly works :)
If you wish to include a js tooltip I would go for an already existing JS library... if the library is there, then show the tooltip, if it's not there then do it as it has been done up until now. The tooltip code could be large and embedding it in raty code would make it useless from other code (ie. Form validation), however using an external library allows the developer to use the tooltips in other places... There could even be a callback for a mouseover event that way the developper may chose what tooltip he wants to use.
The callback method could make a cleaner solution for the hints issue.
If bandwidth is an issue it would also be nice to get sprites for the stars :)
from raty.
Good idea shadowfax,
Could you add some specs for that feature and do a pull request?
For minified use http://refresh-sf.com/yui and please, check the option: "Preserve unnecessary semicolons"
And remember that you cant change the original score, you must keep the score/title value into other variable, because the hidden field must keep the original value not the ceil.
from raty.
I am also in the need of displaying ratings for half stars. I use 5 stars but on a 1-10 scale. I multiply the score behind the scenes. It would be nice to display the number when a user is hovering over 2 1/2 stars. (5) on my scale.
Thanks for a great plugin!
from raty.
I implemented tooltips/hints for half ratings on my site by added the following lines.
fillStar function:
$star.attr({src: opt.path + icon, title: score*2});
showHalf function:
this.children('img').not('.raty-cancel').eq(Math.ceil(score) - 1).attr({src: opt.path + opt.starHalf, title: score*2});
I simply added the title tag and multiplied the score by 2 to fit my 1-10 scale. Thx!
from raty.
I also have a need for half-star ratings.. I guess I'll just grab a hack out of this thread though.
from raty.
Hi seiyria,
This issue still opend because will code it, but I'm kind busy for now with my startup.
But it will be out soon.
from raty.
The version 2.7.0, now supports it.
from raty.
It's good that it supports it, but it is good to be documented how it is used as well.
from raty.
Related Issues (20)
- Pull Request #217 fails due to issues with travis.ci HOT 1
- couldn't open the link HOT 1
- raty stars not showing in RoR application HOT 1
- a total of 5 stars, but can score 0.5 points HOT 1
- Accessibility issue with using ALT attribute for numeric value HOT 1
- Create Github tag for 2.9.0 release HOT 1
- stars do not showing on redirect HOT 5
- Raty not working on Rails 6 HOT 4
- How to create stars at runtime HOT 2
- Are there any workable examples for Raty with Bootstrap's popover? HOT 1
- Incorrect json (comma at the end) HOT 1
- Separate Features as Optional Modules HOT 3
- Removes Karma and Jasmine In Favor of Jest HOT 10
- Drop jQuery dependency HOT 3
- Proposal: introduce modular plugin system HOT 2
- Drops jQuery from Test Helper
- Add Webpack Setup on README HOT 2
- JQuery defer or reduced javascript? HOT 1
- Raty is not defined HOT 4
- No effect HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from raty.