options.js 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  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 BxDolStudioOptions(oOptions) {
  9. this.sActionsUrl = oOptions.sActionUrl;
  10. this.sObjName = oOptions.sObjName == undefined ? 'oBxDolStudioOptions' : oOptions.sObjName;
  11. this.sParamPrefix = oOptions.sParamPrefix == undefined ? 'opt' : oOptions.sParamPrefix;
  12. this.sType = oOptions.sType == undefined ? '' : oOptions.sType;
  13. this.sCategory = oOptions.sCategory == undefined ? '' : oOptions.sCategory;
  14. this.sMix = oOptions.sMix == undefined ? '' : oOptions.sMix;
  15. this.sAnimationEffect = oOptions.sAnimationEffect == undefined ? 'fade' : oOptions.sAnimationEffect;
  16. this.iAnimationSpeed = oOptions.iAnimationSpeed == undefined ? 'slow' : oOptions.iAnimationSpeed;
  17. this.bBusy = false;
  18. }
  19. BxDolStudioOptions.prototype.onSubmit = function(oForm) {
  20. if(this.bBusy)
  21. return false;
  22. var oSubmit = $(oForm).find('input[type="submit"],button[type="submit"]');
  23. setTimeout(() => bx_std_loading_btn(oSubmit, true), 0);
  24. return (this.bBusy = true);
  25. };
  26. BxDolStudioOptions.prototype.onSubmitted = function(sFormId, sTocken, oData) {
  27. var oForm = $('#' + sFormId);
  28. var oSubmit = oForm.find('input[type="submit"],button[type="submit"]');
  29. oForm.find('input[name="csrf_token"]').val(sTocken);
  30. bx_std_loading_btn(oSubmit, false);
  31. this.bBusy = false;
  32. };
  33. BxDolStudioOptions.prototype.import = function(oButton) {
  34. this.mixAction(oButton, 'import');
  35. };
  36. BxDolStudioOptions.prototype.onImport = function(oData) {
  37. document.location.href = document.location.href;
  38. };
  39. BxDolStudioOptions.prototype.export = function(oButton) {
  40. this.mixAction(oButton, 'export');
  41. };
  42. BxDolStudioOptions.prototype.onExport = function(oData) {
  43. document.location.href = oData.url;
  44. };
  45. BxDolStudioOptions.prototype.mixCreate = function(oButton) {
  46. this.mixActionWithValue(oButton, 'create-mix');
  47. };
  48. BxDolStudioOptions.prototype.onMixCreate = function(oData) {
  49. document.location.href = document.location.href;
  50. };
  51. BxDolStudioOptions.prototype.mixImport = function(oButton) {
  52. this.mixActionWithValue(oButton, 'import-mix');
  53. };
  54. BxDolStudioOptions.prototype.onMixImport = function(oData) {
  55. document.location.href = document.location.href;
  56. };
  57. BxDolStudioOptions.prototype.mixSelect = function(oSelect) {
  58. this.mixActionWithValue(oSelect, 'select-mix', $(oSelect).val());
  59. };
  60. BxDolStudioOptions.prototype.onMixSelect = function(oData) {
  61. document.location.href = document.location.href;
  62. };
  63. BxDolStudioOptions.prototype.mixExport = function(oButton, iId) {
  64. this.mixActionWithValue(oButton, 'export-mix', iId);
  65. };
  66. BxDolStudioOptions.prototype.onMixExport = function(oData) {
  67. document.location.href = oData.url;
  68. };
  69. BxDolStudioOptions.prototype.mixPublish = function(oButton, iId) {
  70. this.mixActionWithValue(oButton, 'publish-mix', iId);
  71. };
  72. BxDolStudioOptions.prototype.onMixPublish = function(oData) {
  73. document.location.href = document.location.href;
  74. };
  75. BxDolStudioOptions.prototype.mixHide = function(oButton, iId) {
  76. this.mixActionWithValue(oButton, 'hide-mix', iId);
  77. };
  78. BxDolStudioOptions.prototype.onMixHide = function(oData) {
  79. document.location.href = document.location.href;
  80. };
  81. BxDolStudioOptions.prototype.mixDelete = function(oButton, iId) {
  82. this.mixActionWithValue(oButton, 'delete-mix', iId, 1);
  83. };
  84. BxDolStudioOptions.prototype.onMixDelete = function(oData) {
  85. document.location.href = document.location.href;
  86. };
  87. BxDolStudioOptions.prototype.mixAction = function(oSource, sAction, bConfirm) {
  88. var $this = this;
  89. var oDate = new Date();
  90. var aParams = {
  91. type: this.sType,
  92. category: this.sCategory,
  93. _t:oDate.getTime()
  94. };
  95. aParams[this.sParamPrefix + '_action'] = sAction;
  96. var oPerform = function() {
  97. $.post(
  98. this.sActionsUrl,
  99. aParams,
  100. function (oData) {
  101. processJsonData(oData);
  102. },
  103. 'json'
  104. );
  105. };
  106. if(bConfirm != undefined && parseInt(bConfirm) == 1)
  107. bx_confirm('', oPerform);
  108. else
  109. oPerform();
  110. };
  111. BxDolStudioOptions.prototype.mixActionWithValue = function(oSource, sAction, mixedValue, bConfirm) {
  112. var $this = this;
  113. var oDate = new Date();
  114. var aParams = {
  115. type: $this.sType,
  116. category: $this.sCategory,
  117. _t:oDate.getTime()
  118. };
  119. aParams[this.sParamPrefix + '_action'] = sAction;
  120. aParams[this.sParamPrefix + '_value'] = mixedValue;
  121. var oPerform = function() {
  122. $.post(
  123. $this.sActionsUrl,
  124. aParams,
  125. function (oData) {
  126. processJsonData(oData)
  127. },
  128. 'json'
  129. );
  130. };
  131. if(bConfirm != undefined && parseInt(bConfirm) == 1)
  132. bx_confirm('', oPerform);
  133. else
  134. oPerform();
  135. };
  136. BxDolStudioOptions.prototype.processResult = function(oData) {
  137. processJsonData(oData);
  138. };
  139. /** @} */