settings.js 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  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 BxDolStudioSettings(oOptions) {
  9. this.sActionsUrl = oOptions.sActionUrl;
  10. this.sObjName = oOptions.sObjName == undefined ? 'oBxDolStudioSettings' : oOptions.sObjName;
  11. this.sType = oOptions.sType == undefined ? '' : oOptions.sType;
  12. this.sCategory = oOptions.sCategory == undefined ? '' : oOptions.sCategory;
  13. this.sMix = oOptions.sMix == undefined ? '' : oOptions.sMix;
  14. this.sAnimationEffect = oOptions.sAnimationEffect == undefined ? 'fade' : oOptions.sAnimationEffect;
  15. this.iAnimationSpeed = oOptions.iAnimationSpeed == undefined ? 'slow' : oOptions.iAnimationSpeed;
  16. }
  17. BxDolStudioSettings.prototype.mixCreate = function(oButton) {
  18. this.mixActionWithValue(oButton, 'create-mix');
  19. };
  20. BxDolStudioSettings.prototype.onMixCreate = function(oData) {
  21. document.location.href = document.location.href;
  22. };
  23. BxDolStudioSettings.prototype.mixImport = function(oButton) {
  24. this.mixActionWithValue(oButton, 'import-mix');
  25. };
  26. BxDolStudioSettings.prototype.onMixImport = function(oData) {
  27. document.location.href = document.location.href;
  28. };
  29. BxDolStudioSettings.prototype.mixSelect = function(oSelect) {
  30. this.mixActionWithValue(oSelect, 'select-mix', $(oSelect).val());
  31. };
  32. BxDolStudioSettings.prototype.onMixSelect = function(oData) {
  33. document.location.href = document.location.href;
  34. };
  35. BxDolStudioSettings.prototype.mixExport = function(oButton, iId) {
  36. this.mixActionWithValue(oButton, 'export-mix', iId);
  37. };
  38. BxDolStudioSettings.prototype.onMixExport = function(oData) {
  39. document.location.href = oData.url;
  40. };
  41. BxDolStudioSettings.prototype.mixPublish = function(oButton, iId) {
  42. this.mixActionWithValue(oButton, 'publish-mix', iId);
  43. };
  44. BxDolStudioSettings.prototype.onMixPublish = function(oData) {
  45. document.location.href = document.location.href;
  46. };
  47. BxDolStudioSettings.prototype.mixHide = function(oButton, iId) {
  48. this.mixActionWithValue(oButton, 'hide-mix', iId);
  49. };
  50. BxDolStudioSettings.prototype.onMixHide = function(oData) {
  51. document.location.href = document.location.href;
  52. };
  53. BxDolStudioSettings.prototype.mixDelete = function(oButton, iId) {
  54. this.mixActionWithValue(oButton, 'delete-mix', iId, 1);
  55. };
  56. BxDolStudioSettings.prototype.onMixDelete = function(oData) {
  57. document.location.href = document.location.href;
  58. };
  59. BxDolStudioSettings.prototype.mixAction = function(oSource, sAction) {
  60. var $this = this;
  61. var oDate = new Date();
  62. $.post(
  63. sUrlStudio + 'settings.php',
  64. {
  65. page: this.sType,
  66. category: this.sCategory,
  67. stg_action: sAction,
  68. _t:oDate.getTime()
  69. },
  70. function (oData) {
  71. $this.processResult(oData);
  72. },
  73. 'json'
  74. );
  75. };
  76. BxDolStudioSettings.prototype.mixActionWithValue = function(oSource, sAction, mixedValue, bConfirm) {
  77. var $this = this;
  78. var oDate = new Date();
  79. var oPerform = function() {
  80. $.post(
  81. sUrlStudio + 'settings.php',
  82. {
  83. page: $this.sType,
  84. category: $this.sCategory,
  85. stg_action: sAction,
  86. stg_value: mixedValue,
  87. _t:oDate.getTime()
  88. },
  89. function (oData) {
  90. $this.processResult(oData);
  91. },
  92. 'json'
  93. );
  94. };
  95. if(bConfirm != undefined && parseInt(bConfirm) == 1)
  96. bx_confirm('', oPerform);
  97. else
  98. oPerform();
  99. };
  100. /**
  101. * Is needed if AJAX is used to change (reload) pages.
  102. */
  103. BxDolStudioSettings.prototype.changePage = function(sType) {
  104. var oDate = new Date();
  105. var $this = this;
  106. $.get(
  107. this.sActionsUrl,
  108. {
  109. stg_action: 'get-page-by-type',
  110. stg_value: sType,
  111. _t:oDate.getTime()
  112. },
  113. function(oData) {
  114. if(oData.code != 0) {
  115. bx_alert(oData.message);
  116. return;
  117. }
  118. $('#bx-std-pc-menu > .bx-std-pmi-active').removeClass('bx-std-pmi-active');
  119. $('#bx-std-pmi-' + sType).addClass('bx-std-pmi-active');
  120. $('#bx-std-pc-content').bx_anim('hide', $this.sAnimationEffect, $this.iAnimationSpeed, function() {
  121. $(this).html(oData.content).bx_anim('show', $this.sAnimationEffect, $this.iAnimationSpeed);
  122. });
  123. },
  124. 'json'
  125. );
  126. return true;
  127. };
  128. BxDolStudioSettings.prototype.processResult = function(oData) {
  129. var $this = this;
  130. if(oData && oData.message != undefined && oData.message.length != 0)
  131. $(document).dolPopupAlert({
  132. message: oData.message
  133. });
  134. if(oData && oData.reload != undefined && parseInt(oData.reload) == 1)
  135. document.location = document.location;
  136. if(oData && oData.popup != undefined) {
  137. var oPopup = $(oData.popup).hide();
  138. $('#' + oPopup.attr('id')).remove();
  139. oPopup.prependTo('body').dolPopup({
  140. fog: {
  141. color: '#fff',
  142. opacity: .7
  143. },
  144. closeOnOuterClick: false
  145. });
  146. }
  147. if (oData && oData.eval != undefined)
  148. eval(oData.eval);
  149. };
  150. /** @} */