Guest User

Untitled

a guest
May 21st, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. Newt.components.Rating = new Class({
  2. Extends: Newt.Widget,
  3.  
  4. Binds: [
  5. 'click'
  6. ],
  7.  
  8. options: {
  9. rating: 0
  10. },
  11.  
  12. initialize: function Rating_initialize (options) {
  13. this.here();
  14. this.parent(options);
  15. $(this).addClass('Rating');
  16. this.build();
  17. this.draw();
  18.  
  19. $(this).addEvent('click', this.click);
  20. },
  21.  
  22. build: function Rating_build () {
  23. this.here();
  24. $(this).set('html', '<i><b><b><b><b><b>&nbsp;</b></b></b></b></b></i>');
  25. },
  26.  
  27. draw: function Rating_draw () {
  28. this.here();
  29. $(this).className = $(this).className.replace(/stars-\d/, '');
  30. $(this).addClass('stars-' + this.options.rating);
  31. },
  32.  
  33. update: function Rating_update (v) {
  34. this.here();
  35. this.options.rating = v;
  36. this.draw();
  37. this.fireEvent('update', this.options.rating);
  38. },
  39.  
  40. click: function Rating_click (evt) {
  41. this.here();
  42. var t = $(evt.target);
  43. var p = t.getParent('.Rating');
  44.  
  45. this.update(5 - t.getElementsByTagName('b').length);
  46. }
  47. });
Add Comment
Please, Sign In to add comment