You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

44 lines
1.4 KiB

3 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. // jQuery Raty, for more examples you can check out https://github.com/wbotelhos/raty
  2. class pageCompRating {
  3. /*
  4. * Init demo rating functionality
  5. *
  6. */
  7. static initRating() {
  8. // Init Raty on .js-rating class
  9. jQuery('.js-rating').each((index, element) => {
  10. let el = jQuery(element);
  11. el.raty({
  12. score: el.data('score') || 0,
  13. number: el.data('number') || 5,
  14. cancel: el.data('cancel') || false,
  15. target: el.data('target') || false,
  16. targetScore: el.data('target-score') || false,
  17. precision: el.data('precision') || false,
  18. cancelOff: el.data('cancel-off') || 'fa fa-fw fa-times-circle text-danger',
  19. cancelOn: el.data('cancel-on') || 'fa fa-fw fa-times-circle',
  20. starHalf: el.data('star-half') || 'fa fa-fw fa-star-half text-warning',
  21. starOff: el.data('star-off') || 'fa fa-fw fa-star text-muted',
  22. starOn: el.data('star-on') || 'fa fa-fw fa-star text-warning',
  23. starType: 'i',
  24. hints: ['Just Bad!', 'Almost There!', 'It’s ok!', 'That’s nice!', 'Incredible!'],
  25. click: function (score, evt) {
  26. // Here you could add your logic on rating click
  27. // console.log('ID: ' + this.id + "\nscore: " + score + "\nevent: " + evt);
  28. }
  29. });
  30. });
  31. }
  32. /*
  33. * Init functionality
  34. *
  35. */
  36. static init() {
  37. this.initRating();
  38. }
  39. }
  40. // Initialize when page loads
  41. Dashmix.onLoad(() => pageCompRating.init());