module.js 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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.sActionsPrefix = oOptions.sActionsPrefix;
  11. this.sObjName = oOptions.sObjName == undefined ? 'oBxDolStudioModule' : oOptions.sObjName;
  12. this.sAnimationEffect = oOptions.sAnimationEffect == undefined ? 'fade' : oOptions.sAnimationEffect;
  13. this.iAnimationSpeed = oOptions.iAnimationSpeed == undefined ? 'slow' : oOptions.iAnimationSpeed;
  14. }
  15. BxDolStudioModule.prototype.settings = function(sName, iWidgetId) {
  16. if(!sName)
  17. return false;
  18. var oDate = new Date();
  19. var aParams = {_t:oDate.getTime()};
  20. aParams[this.sActionsPrefix + '_action'] = 'settings';
  21. aParams[this.sActionsPrefix + '_value'] = sName;
  22. aParams[this.sActionsPrefix + '_widget_id'] = iWidgetId;
  23. $.get(
  24. this.sActionsUrl, aParams, function(oData) {
  25. processJsonData(oData);
  26. },
  27. 'json'
  28. );
  29. };
  30. BxDolStudioModule.prototype.activate = function(oCheckbox, sName, iWidgetId) {
  31. var $this = this;
  32. var oDate = new Date();
  33. var aParams = {_t:oDate.getTime()};
  34. aParams[this.sActionsPrefix + '_action'] = 'activate';
  35. aParams[this.sActionsPrefix + '_value'] = sName;
  36. aParams[this.sActionsPrefix + '_widget_id'] = iWidgetId;
  37. $.get(
  38. this.sActionsUrl, aParams, function(oData) {
  39. processJsonData(oData);
  40. $('.bx-popup-applied:visible').dolPopupHide();
  41. if(oData.code != 0) {
  42. $(oCheckbox).attr('checked', 'checked').trigger('enable');
  43. return;
  44. }
  45. if(iWidgetId != 0 && oData.widget.length > 0) {
  46. $('#bx-std-widget-' + iWidgetId).replaceWith(oData.widget);
  47. oBxDolStudioLauncher.enableJitter();
  48. return;
  49. }
  50. var oContent = $('#bx-std-page-columns');
  51. if(oData.content.length > 0)
  52. oContent.bx_anim('hide', $this.sAnimationEffect, $this.iAnimationSpeed, function() {
  53. $(this).html(oData.content).bx_anim('show', $this.sAnimationEffect, 'fast');
  54. });
  55. },
  56. 'json'
  57. );
  58. return true;
  59. };
  60. BxDolStudioModule.prototype.uninstall = function(sName, iWidgetId, iConfirm) {
  61. if(!sName)
  62. return false;
  63. var oDate = new Date();
  64. var aParams = {_t:oDate.getTime()};
  65. aParams[this.sActionsPrefix + '_action'] = 'uninstall';
  66. aParams[this.sActionsPrefix + '_value'] = sName;
  67. aParams[this.sActionsPrefix + '_widget_id'] = iWidgetId;
  68. aParams[this.sActionsPrefix + '_confirmed'] = parseInt(iConfirm);
  69. $('.bx-popup-applied:visible').dolPopupHide();
  70. $.get(
  71. this.sActionsUrl, aParams, function (oData) {
  72. processJsonData(oData);
  73. },
  74. 'json'
  75. );
  76. };
  77. BxDolStudioModule.prototype.onUninstall = function(oData) {
  78. if(oData.code != 0 || oData.page.length == 0 || oData.widget_id.length == 0)
  79. return;
  80. $('#bx-menu-item-' + oData.page).bx_anim('hide', this.sAnimationEffect, this.iAnimationSpeed, function() {
  81. $(this).remove();
  82. });
  83. $('#bx-std-widget-' + oData.widget_id).bx_anim('hide', this.sAnimationEffect, this.iAnimationSpeed, function() {
  84. $(this).remove();
  85. });
  86. };
  87. /** @} */