main.js 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. /**
  2. * Copyright (c) UNA, Inc - https://una.io
  3. * MIT License - https://opensource.org/licenses/MIT
  4. *
  5. * @defgroup PaidLevels Paid Levels
  6. * @ingroup UnaModules
  7. *
  8. * @{
  9. */
  10. function BxAclMain(oOptions) {
  11. this._sActionsUri = oOptions.sActionUri;
  12. this._sActionsUrl = oOptions.sActionUrl;
  13. this._sObjName = oOptions.sObjName == undefined ? 'oAclMain' : oOptions.sObjName;
  14. this._aHtmlIds = oOptions.aHtmlIds == undefined ? {} : oOptions.aHtmlIds;
  15. this._oRequestParams = oOptions.oRequestParams == undefined ? {} : oOptions.oRequestParams;
  16. }
  17. BxAclMain.prototype.viewActions = function(oElement, iLevelId) {
  18. var $this = this;
  19. var oData = this._getDefaultData();
  20. if(oElement)
  21. this.loadingInBlock(oElement, true);
  22. jQuery.get(
  23. this._sActionsUrl + 'get_actions_in_popup/' + iLevelId + '/',
  24. oData,
  25. function(oData) {
  26. if(oElement)
  27. $this.loadingInBlock(oElement, false);
  28. processJsonData(oData);
  29. },
  30. 'json'
  31. );
  32. };
  33. BxAclMain.prototype.getActions = function(oElement, iLevelId, iStart, iPerPage) {
  34. var $this = this;
  35. var oData = this._getData({
  36. start: iStart,
  37. per_page: iPerPage
  38. });
  39. if(oElement)
  40. this.loadingInList(oElement, true);
  41. jQuery.get(
  42. this._sActionsUrl + 'get_actions/' + iLevelId + '/',
  43. oData,
  44. function(oData) {
  45. if(oElement)
  46. $this.loadingInList(oElement, false);
  47. processJsonData(oData);
  48. },
  49. 'json'
  50. );
  51. };
  52. BxAclMain.prototype.onGetActions = function(oData)
  53. {
  54. if(oData && oData.level_id != undefined && oData.content != undefined)
  55. $('#' + this._aHtmlIds['actions_list'] + oData.level_id).replaceWith(oData.content);
  56. };
  57. BxAclMain.prototype.loadingInBlock = function(e, bShow) {
  58. var oParent = $(e).length ? $(e).parents('.bx-db-container:first') : $('body');
  59. bx_loading(oParent, bShow);
  60. };
  61. BxAclMain.prototype.loadingInList = function(e, bShow) {
  62. var oParent = $(e).length ? $(e).parents('.bx-acl-actions:first') : $('body');
  63. bx_loading(oParent, bShow);
  64. };
  65. BxAclMain.prototype.loadingInButton = function(e, bShow) {
  66. if($(e).length)
  67. bx_loading_btn($(e), bShow);
  68. else
  69. bx_loading($('body'), bShow);
  70. };
  71. BxAclMain.prototype._getData = function (aData) {
  72. return jQuery.extend({}, this._getDefaultData(), aData);
  73. };
  74. BxAclMain.prototype._getDefaultData = function () {
  75. var oDate = new Date();
  76. return jQuery.extend({}, this._oRequestParams, {_t:oDate.getTime()});
  77. };
  78. /** @} */