BxDolView.js 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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 BxDolView(options)
  9. {
  10. this._sObjName = undefined == options.sObjName ? 'oView' : options.sObjName; // javascript object name, to run current object instance from onTimer
  11. this._sSystem = options.sSystem; // current comment system
  12. this._iAuthorId = options.iAuthorId; // this comment's author ID.
  13. this._iObjId = options.iObjId; // this object id comments
  14. this._sActionsUri = 'view.php';
  15. this._sActionsUrl = options.sRootUrl + this._sActionsUri; // actions url address
  16. this._sAnimationEffect = 'fade';
  17. this._iAnimationSpeed = 'slow';
  18. this._sSP = undefined == options.sStylePrefix ? 'bx-view' : options.sStylePrefix;
  19. this._aHtmlIds = options.aHtmlIds;
  20. }
  21. BxDolView.prototype.toggleByPopup = function(oLink) {
  22. var $this = this;
  23. var oData = this._getDefaultParams();
  24. oData['action'] = 'GetViewedBy';
  25. $(oLink).dolPopupAjax({
  26. id: this._aHtmlIds['by_popup'],
  27. url: bx_append_url_params(this._sActionsUri, oData)
  28. });
  29. };
  30. BxDolView.prototype.getUsers = function(oLink, iStart, iPerPage) {
  31. var $this = this;
  32. var oData = this._getDefaultParams();
  33. oData['action'] = 'GetUsers';
  34. oData['start'] = iStart;
  35. oData['per_page'] = iPerPage;
  36. this._loadingInPopup(oLink, true);
  37. $.get(
  38. this._sActionsUri,
  39. oData,
  40. function(oData) {
  41. $this._loadingInPopup(oLink, false);
  42. oData.source = oLink;
  43. processJsonData(oData);
  44. },
  45. 'json'
  46. );
  47. };
  48. BxDolView.prototype.onGetUsers = function(oData) {
  49. if(!oData.content)
  50. return;
  51. $(oData.source).parents('.bx-popup-content-wrapped:first').html(oData.content);
  52. };
  53. BxDolView.prototype._loadingInButton = function(e, bShow) {
  54. if($(e).length)
  55. bx_loading_btn($(e), bShow);
  56. else
  57. bx_loading($('body'), bShow);
  58. };
  59. BxDolView.prototype._loadingInPopup = function(e, bShow) {
  60. var oParent = $(e).length ? $(e).parents('.bx-popup-content:first') : $('body');
  61. bx_loading(oParent, bShow);
  62. };
  63. BxDolView.prototype._getDefaultParams = function() {
  64. var oDate = new Date();
  65. return {
  66. sys: this._sSystem,
  67. id: this._iObjId,
  68. _t: oDate.getTime()
  69. };
  70. };
  71. /** @} */