module.js 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /**
  2. * Copyright (c) UNA, Inc - https://una.io
  3. * MIT License - https://opensource.org/licenses/MIT
  4. *
  5. * @defgroup UnaStudio UNA Studio
  6. * @{
  7. */
  8. function BxDolStudioModule(oOptions) {
  9. this.sActionsUrl = oOptions.sActionUrl;
  10. this.sObjName = oOptions.sObjName == undefined ? 'oBxDolStudioModule' : oOptions.sObjName;
  11. this.sAnimationEffect = oOptions.sAnimationEffect == undefined ? 'fade' : oOptions.sAnimationEffect;
  12. this.iAnimationSpeed = oOptions.iAnimationSpeed == undefined ? 'slow' : oOptions.iAnimationSpeed;
  13. }
  14. BxDolStudioModule.prototype.activate = function(sName, oChecbox) {
  15. var $this = this;
  16. var oDate = new Date();
  17. var sAction = 'activate';
  18. $.get(
  19. this.sActionsUrl,
  20. {
  21. mod_action: sAction,
  22. mod_value: sName,
  23. _t:oDate.getTime()
  24. },
  25. function(oData) {
  26. if(oData.code != 0) {
  27. $('.bx-popup-applied:visible').dolPopupHide();
  28. $this.popup(sAction, oData.message);
  29. $(oChecbox).attr('checked', 'checked').trigger('enable');
  30. return;
  31. }
  32. var oBg = $('.bx-std-page-bg');
  33. var oContent = $('#bx-std-page-columns');
  34. if(oData.content.length > 0) {
  35. oBg.removeClass('bx-std-page-bg-empty');
  36. oContent.html(oData.content).bx_anim('show', $this.sAnimationEffect, $this.iAnimationSpeed);
  37. }
  38. else
  39. oContent.bx_anim('hide', $this.sAnimationEffect, $this.iAnimationSpeed, function() {
  40. $(this).html(oData.content);
  41. oBg.addClass('bx-std-page-bg-empty');
  42. });
  43. },
  44. 'json'
  45. );
  46. return true;
  47. };
  48. BxDolStudioModule.prototype.popup = function(sType, sValue) {
  49. var sId = 'bx-std-mod-popup-' + sType;
  50. $('#' + sId).remove();
  51. $('<div id="' + sId + '" style="display: none;"></div>').prependTo('body').html(sValue);
  52. $('#' + sId).dolPopup({});
  53. };
  54. /** @} */