main.js 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /**
  2. * Copyright (c) UNA, Inc - https://una.io
  3. * MIT License - https://opensource.org/licenses/MIT
  4. *
  5. * @defgroup Attendant Attendant
  6. * @ingroup UnaModules
  7. *
  8. * @{
  9. */
  10. function BxAttendant(oOptions) {
  11. this._sContainerId = oOptions.sContainerId == undefined ? 'oBxAttendant' : oOptions.sContainerId;
  12. this._sUrlAfterShow = oOptions.sUrlAfterShow == undefined ? '' : oOptions.sUrlAfterShow;
  13. this._sActionsUri = oOptions.sActionUri;
  14. var $this = this;
  15. }
  16. BxAttendant.prototype.showPopup = function (bManual = 0, sModule = 'default', sEvent = 'default', sObject = 0) {
  17. var $this = this;
  18. $.get($this._sActionsUri + 'RecomendedPopup/' + sModule + '/' + sEvent + '/' + sObject + '/' + bManual + '/', function (sData) {
  19. if (sData != ''){
  20. oData = null;
  21. try {
  22. oData = $.parseJSON(sData);
  23. } catch (e) {
  24. }
  25. if (oData && oData.redirect){
  26. window.location = oData.redirect;
  27. }
  28. else{
  29. $(window).dolPopupAjax({
  30. url: $this._sActionsUri + 'RecomendedPopup/' + sModule + '/' + sEvent + '/' + sObject + '/' + bManual + '/',
  31. closeOnOuterClick: true,
  32. removeOnClose: true,
  33. onLoad: function(sPopupSelector){
  34. $(sPopupSelector + ' .bx-pwropa-item-container').hide().first().show();
  35. $this.reInitFlickity(sPopupSelector);
  36. $(sPopupSelector + ' .bx-pwropa-button').click(function () {
  37. $oCurr = $(sPopupSelector + ' .bx-pwropa-item-container:visible').hide();
  38. $oNext = $oCurr.next();
  39. $oNext.show();
  40. $this.reInitFlickity(sPopupSelector);
  41. if ($oNext.length == 0) {
  42. $(sPopupSelector).dolPopupHide();
  43. if ($this._sUrlAfterShow != '') {
  44. location.href = $this._sUrlAfterShow;
  45. }
  46. }
  47. });
  48. }
  49. });
  50. }
  51. }
  52. });
  53. }
  54. BxAttendant.prototype.reInitFlickity = function (sPopupSelector) {
  55. var $this = this;
  56. $(sPopupSelector + ' .bx-pwropa-item-container:visible .bx-base-unit-showcase-wrapper').flickity({
  57. cellSelector: '.bx-base-unit-showcase',
  58. cellAlign: 'left',
  59. pageDots: false,
  60. imagesLoaded: true
  61. });
  62. $('#' + $this._sContainerId)._dolPopupSetPosition();
  63. }
  64. BxAttendant.prototype.onActionComplete = function (data, e) {
  65. if (data.err == false) {
  66. var $e = $(e);
  67. $e.hide();
  68. }
  69. }
  70. function bx_attendant_conn_action(e, sObj, sAction, iContentId, bConfirm, fOnComplete) {
  71. return bx_conn_action(e, sObj, sAction, iContentId, bConfirm, oBxAttendant.onActionComplete)
  72. }