view.js 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. function BxNtfsView(oOptions) {
  2. BxNtfsMain.call(this, oOptions);
  3. this._sObjName = oOptions.sObjName == undefined ? 'oNtfsView' : oOptions.sObjName;
  4. this._iOwnerId = oOptions.iOwnerId == undefined ? 0 : oOptions.iOwnerId;
  5. }
  6. BxNtfsView.prototype = Object.create(BxNtfsMain.prototype);
  7. BxNtfsView.prototype.constructor = BxNtfsView;
  8. /**
  9. * Is needed to switch between different browsing types dynamically.
  10. * NOTE. The function isn't used for now.
  11. */
  12. BxNtfsView.prototype.changeType = function(oElement, sType) {
  13. this._oRequestParams.start = 0;
  14. this._oRequestParams.type = sType;
  15. this._getPosts(oElement);
  16. };
  17. BxNtfsView.prototype.changePage = function(oElement, iStart, iPerPage) {
  18. this._oRequestParams.start = iStart;
  19. this._oRequestParams.per_page = iPerPage;
  20. this._getPosts(oElement);
  21. };
  22. BxNtfsView.prototype.markAsClicked = function(oElement, iId) {
  23. var oData = this._getDefaultData();
  24. oData['id'] = iId;
  25. jQuery.get(
  26. this._sActionsUrl + 'mark_as_clicked/',
  27. oData,
  28. function(oData) {
  29. if(!oData || parseInt(oData.code) !== 0)
  30. return;
  31. var sLink = $(oElement).attr('href');
  32. if(sLink)
  33. document.location = sLink;
  34. },
  35. 'json'
  36. );
  37. return false;
  38. };
  39. BxNtfsView.prototype._getPosts = function(oElement) {
  40. var $this = this;
  41. this.loadingInBlock(oElement, true);
  42. jQuery.get(
  43. this._sActionsUrl + 'get_posts/',
  44. this._getDefaultData(),
  45. function(oData) {
  46. if(oData && oData.events != undefined) {
  47. var sEvents = $.trim(oData.events);
  48. $this.loadingInBlock(oElement, false);
  49. $('#' + $this._aHtmlIds['events']).bx_anim('hide', $this._sAnimationEffect, $this._iAnimationSpeed, function() {
  50. $(this).html(sEvents).show().bxProcessHtml();
  51. });
  52. }
  53. },
  54. 'json'
  55. );
  56. };