Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Newt.components.Rating = new Class({
- Extends: Newt.Widget,
- Binds: [
- 'click'
- ],
- options: {
- rating: 0
- },
- initialize: function Rating_initialize (options) {
- this.here();
- this.parent(options);
- $(this).addClass('Rating');
- this.build();
- this.draw();
- $(this).addEvent('click', this.click);
- },
- build: function Rating_build () {
- this.here();
- $(this).set('html', '<i><b><b><b><b><b> </b></b></b></b></b></i>');
- },
- draw: function Rating_draw () {
- this.here();
- $(this).className = $(this).className.replace(/stars-\d/, '');
- $(this).addClass('stars-' + this.options.rating);
- },
- update: function Rating_update (v) {
- this.here();
- this.options.rating = v;
- this.draw();
- this.fireEvent('update', this.options.rating);
- },
- click: function Rating_click (evt) {
- this.here();
- var t = $(evt.target);
- var p = t.getParent('.Rating');
- this.update(5 - t.getElementsByTagName('b').length);
- }
- });
Add Comment
Please, Sign In to add comment