settings.js 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  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.mixSelect = function(oSelect) {
  18. var $this = this;
  19. var oDate = new Date();
  20. $.post(
  21. sUrlStudio + 'settings.php',
  22. {
  23. page: this.sType,
  24. category: this.sCategory,
  25. stg_action: 'select-mix',
  26. stg_value: $(oSelect).val(),
  27. _t:oDate.getTime()
  28. },
  29. function (oData) {
  30. $this.processResult(oData);
  31. },
  32. 'json'
  33. );
  34. };
  35. BxDolStudioSettings.prototype.onMixSelect = function(oData) {
  36. document.location.href = document.location.href;
  37. };
  38. BxDolStudioSettings.prototype.mixCreate = function(oButton) {
  39. var $this = this;
  40. var oDate = new Date();
  41. $('.bx-popup-applied:visible').dolPopupHide();
  42. $.post(
  43. sUrlStudio + 'settings.php',
  44. {
  45. page: this.sType,
  46. category: this.sCategory,
  47. stg_action: 'create-mix',
  48. _t:oDate.getTime()
  49. },
  50. function (oData) {
  51. $this.processResult(oData);
  52. },
  53. 'json'
  54. );
  55. };
  56. BxDolStudioSettings.prototype.onMixCreate = function(oData) {
  57. document.location.href = document.location.href;
  58. };
  59. BxDolStudioSettings.prototype.mixImport = function(oButton) {
  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: 'import-mix',
  68. _t:oDate.getTime()
  69. },
  70. function (oData) {
  71. $this.processResult(oData);
  72. },
  73. 'json'
  74. );
  75. };
  76. BxDolStudioSettings.prototype.onMixImport = function(oData) {
  77. document.location.href = document.location.href;
  78. };
  79. BxDolStudioSettings.prototype.mixExport = function(oButton, iId) {
  80. var $this = this;
  81. var oDate = new Date();
  82. $.post(
  83. sUrlStudio + 'settings.php',
  84. {
  85. page: this.sType,
  86. category: this.sCategory,
  87. stg_action: 'export-mix',
  88. stg_value: iId,
  89. _t:oDate.getTime()
  90. },
  91. function (oData) {
  92. $this.processResult(oData);
  93. },
  94. 'json'
  95. );
  96. };
  97. BxDolStudioSettings.prototype.onMixExport = function(oData) {
  98. document.location.href = oData.url;
  99. };
  100. BxDolStudioSettings.prototype.mixDelete = function(oButton, iId) {
  101. var $this = this;
  102. var oDate = new Date();
  103. $.post(
  104. sUrlStudio + 'settings.php',
  105. {
  106. page: this.sType,
  107. category: this.sCategory,
  108. stg_action: 'delete-mix',
  109. stg_value: iId,
  110. _t:oDate.getTime()
  111. },
  112. function (oData) {
  113. $this.processResult(oData);
  114. },
  115. 'json'
  116. );
  117. };
  118. BxDolStudioSettings.prototype.onMixDelete = function(oData) {
  119. document.location.href = document.location.href;
  120. };
  121. /**
  122. * Is needed if AJAX is used to change (reload) pages.
  123. */
  124. BxDolStudioSettings.prototype.changePage = function(sType) {
  125. var oDate = new Date();
  126. var $this = this;
  127. $.get(
  128. this.sActionsUrl,
  129. {
  130. stg_action: 'get-page-by-type',
  131. stg_value: sType,
  132. _t:oDate.getTime()
  133. },
  134. function(oData) {
  135. if(oData.code != 0) {
  136. bx_alert(oData.message);
  137. return;
  138. }
  139. $('#bx-std-pc-menu > .bx-std-pmi-active').removeClass('bx-std-pmi-active');
  140. $('#bx-std-pmi-' + sType).addClass('bx-std-pmi-active');
  141. $('#bx-std-pc-content').bx_anim('hide', $this.sAnimationEffect, $this.iAnimationSpeed, function() {
  142. $(this).html(oData.content).bx_anim('show', $this.sAnimationEffect, $this.iAnimationSpeed);
  143. });
  144. },
  145. 'json'
  146. );
  147. return true;
  148. };
  149. BxDolStudioSettings.prototype.processResult = function(oData) {
  150. var $this = this;
  151. if(oData && oData.message != undefined && oData.message.length != 0)
  152. $(document).dolPopupAlert({
  153. message: oData.message
  154. });
  155. if(oData && oData.reload != undefined && parseInt(oData.reload) == 1)
  156. document.location = document.location;
  157. if(oData && oData.popup != undefined) {
  158. var oPopup = $(oData.popup).hide();
  159. $('#' + oPopup.attr('id')).remove();
  160. oPopup.prependTo('body').dolPopup({
  161. fog: {
  162. color: '#fff',
  163. opacity: .7
  164. },
  165. closeOnOuterClick: false
  166. });
  167. }
  168. if (oData && oData.eval != undefined)
  169. eval(oData.eval);
  170. };
  171. /** @} */