BxDolVoteLikes.js 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /**
  2. * Copyright (c) UNA, Inc - https://una.io
  3. * MIT License - https://opensource.org/licenses/MIT
  4. *
  5. * @defgroup UnaCore UNA Core
  6. * @{
  7. */
  8. function BxDolVoteLikes(oOptions)
  9. {
  10. BxDolVote.call(this, oOptions);
  11. }
  12. BxDolVoteLikes.prototype = Object.create(BxDolVote.prototype);
  13. BxDolVoteLikes.prototype.constructor = BxDolVoteLikes;
  14. BxDolVoteLikes.prototype.onVote = function (oLink, oData, onComplete)
  15. {
  16. if(oData && oData.code != 0)
  17. return;
  18. if(oData && oData.label_use)
  19. switch(oData.label_use) {
  20. case 'icon':
  21. $(oLink).find('.sys-action-do-icon .sys-icon').attr('class', 'sys-icon ' + oData.label_icon);
  22. break;
  23. case 'emoji':
  24. $(oLink).find('.sys-action-do-icon .sys-icon').html(oData.label_emoji);
  25. break;
  26. case 'image':
  27. $(oLink).find('.sys-action-do-icon').html(oData.label_image);
  28. break;
  29. }
  30. if(oData && oData.label_title) {
  31. $(oLink).attr('title', oData.label_title);
  32. $(oLink).find('.sys-action-do-text').html(oData.label_title);
  33. }
  34. if(oData && oData.disabled)
  35. $(oLink).removeAttr('onclick').addClass($(oLink).hasClass('bx-btn') ? 'bx-btn-disabled' : 'bx-vote-disabled');
  36. BxDolVote.prototype.onVote.call(this, oLink, oData, onComplete);
  37. };
  38. BxDolVoteLikes.prototype._getCounter = function(oElement)
  39. {
  40. var oCounter = BxDolVote.prototype._getCounter.call(this, oElement);
  41. if(oCounter && oCounter.length > 0)
  42. return oCounter;
  43. return $('#' + this._aHtmlIds['counter'] + '.' + this._sSP + '-counter');
  44. };
  45. /** @} */