module.js 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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. if(oData.code != 0) {
  41. $('.bx-popup-applied:visible').dolPopupHide();
  42. $(oCheckbox).attr('checked', 'checked').trigger('enable');
  43. return;
  44. }
  45. if(iWidgetId != 0 && oData.widget.length > 0) {
  46. $('.bx-popup-applied:visible').dolPopupHide();
  47. $('#bx-std-widget-' + iWidgetId).replaceWith(oData.widget);
  48. oBxDolStudioLauncher.enableJitter();
  49. return;
  50. }
  51. var oContent = $('#bx-std-page-columns');
  52. if(oData.content.length > 0)
  53. oContent.html(oData.content).bx_anim('show', $this.sAnimationEffect, $this.iAnimationSpeed);
  54. else
  55. oContent.bx_anim('hide', $this.sAnimationEffect, $this.iAnimationSpeed, function() {
  56. $(this).html(oData.content);
  57. });
  58. },
  59. 'json'
  60. );
  61. return true;
  62. };
  63. BxDolStudioModule.prototype.uninstall = function(sName, iWidgetId, iConfirm) {
  64. if(!sName)
  65. return false;
  66. var oDate = new Date();
  67. var aParams = {_t:oDate.getTime()};
  68. aParams[this.sActionsPrefix + '_action'] = 'uninstall';
  69. aParams[this.sActionsPrefix + '_value'] = sName;
  70. aParams[this.sActionsPrefix + '_widget_id'] = iWidgetId;
  71. aParams[this.sActionsPrefix + '_confirmed'] = parseInt(iConfirm);
  72. $('.bx-popup-applied:visible').dolPopupHide();
  73. $.get(
  74. this.sActionsUrl, aParams, function (oData) {
  75. processJsonData(oData);
  76. },
  77. 'json'
  78. );
  79. };
  80. BxDolStudioModule.prototype.onUninstall = function(oData) {
  81. if(oData.code != 0 || oData.page.length == 0 || oData.widget_id.length == 0)
  82. return;
  83. $('#bx-menu-item-' + oData.page).bx_anim('hide', this.sAnimationEffect, this.iAnimationSpeed, function() {
  84. $(this).remove();
  85. });
  86. $('#bx-std-widget-' + oData.widget_id).bx_anim('hide', this.sAnimationEffect, this.iAnimationSpeed, function() {
  87. $(this).remove();
  88. });
  89. };
  90. /** @} */