Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/digineo/rating_widget
https://github.com/digineo/rating_widget
Last synced: 6 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/digineo/rating_widget
- Owner: digineo
- License: mit
- Created: 2012-04-25T10:35:27.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2013-04-08T16:21:35.000Z (over 11 years ago)
- Last Synced: 2023-04-10T15:07:36.846Z (over 1 year ago)
- Language: Ruby
- Size: 113 KB
- Stars: 1
- Watchers: 5
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: MIT-LICENSE
Awesome Lists containing this project
README
Rating-Widget
============Ruby On Rails helpers and assets for Ratings
Installation
------------Gemfile:
gem 'rating_widget', :git => 'git://github.com/digineo/rating_widget.git'
Add the supplied javascript to your asset pipeline (e. g. `/app/assets/javascripts/application.js`)
//= require rating_widget
Please ensure the `rating_widget.js` is inserted at the bottom of your `` element and jQuery is loaded before.
Usage for input
---------------Just call the `rating_input` helper in any view to include a rating widget tag:
rating_input(tag_id, value, max_rating=5)
Parameters:
* tag_id = The html-container-id for the rating-widget
* value = the saved actual value of the rating-attribute in the model
* max_rating (optional) = default is 5, can be overwritten by a number of stars
Example:
rating_input("rating_#{mailing.id}", mailing.rating)
Javascript:
----------Just use the rating-method on the select-tag which you have rendered with the above mentioned helper-method
Example:
var rater = $(element).find('select');
rater.rating({
uri: document.location.pathname + '/' + mailingId,
param: 'mailing[rating]'
});You have to pass two parameters for the rating-method:
* uri = The PUT uri of the model to update the rating-attribute
* param = The qualified rating-attribute
Locales:
--------The option values and texts for the stars are generated with the definition in the application locales as the named context 'rating'
Example:
de
rating
"1": sehr schlecht
"2": schlecht
"3": mittelmäßig
"4": gut
"5": sehr gutUsage for displaying stars only
-------------------------------Just call the `rating_display` helper in any view to include a rating widget tag to display the stars:
rating_display(value, max_rating=5)
Parameters:
* value = the saved actual value of the rating-attribute in the model
* max_rating (optional) = default is 5, can be overwritten by a number of stars
Example:
rating_display(mailing.rating)
Copyright
---------Copyright © 2012 [Digineo GmbH](http://www.digineo.de/), released under the MIT license.