index.js 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. //replace url wrapper
  2. var mgUrlParser = {
  3. oldMgUrlParser: mgUrlParser,
  4. getCurrentUrl: function(){
  5. var url = this.oldMgUrlParser.getCurrentUrl();
  6. return url.replace("action=edit", "action=module-settings").replace("&success=true", "");
  7. }
  8. };
  9. function redirectToPage(tabNumber)
  10. {
  11. var windowAddress = String(window.location);
  12. var hashTab = windowAddress.indexOf('#tab=');
  13. var andTab = windowAddress.indexOf('&tab=');
  14. if (hashTab > 0 && andTab > 0) {
  15. var count = Math.min(hashTab, andTab);
  16. } else {
  17. var count = Math.max(hashTab, andTab);
  18. }
  19. var redirectTo = (count > 0) ? windowAddress.substring(0, count) : windowAddress;
  20. window.location = redirectTo + '&tab=' + tabNumber;
  21. }
  22. function redirectToConfigurableOptionsTab()
  23. {
  24. redirectToPage(5);
  25. }
  26. function redirectToCustomFieldsTab()
  27. {
  28. redirectToPage(4);
  29. }
  30. function productConfigurationSelect(event)
  31. {
  32. productConfigurationSettings(event, event.target.value);
  33. }
  34. function productConfigurationSettings(event, packageName)
  35. {
  36. // const formFields = $(event.target).parents().find('.lu-form-group , .lu-form-check');
  37. // const protectedFields = ['mgpci[package]','mgpci[dedicated_ip]','mgpci[reseller_ip]','mgpci[suspend_at_limit]'];
  38. // formFields.each(function(key, item){
  39. // let name = $(item).find('input')[0].name;
  40. // if (!name)
  41. // {
  42. // name = $(item).find('select')[0].name;
  43. // }
  44. // if (protectedFields.indexOf(name) === -1)
  45. // {
  46. // if (packageName === 'custom'){
  47. // $(item).show();
  48. // }
  49. // else{
  50. // $(item).hide();
  51. // }
  52. // }
  53. // });
  54. }
  55. function hiddeSections(event)
  56. {
  57. /**
  58. * all sections name
  59. * @type {string[]}
  60. */
  61. var sections = [
  62. 'calendarFeatures',
  63. 'classOfServiceFeatures',
  64. 'contactFeatures',
  65. 'essentialFeatures',
  66. 'generalFeatures',
  67. 'mailServiceFeatures',
  68. 'mimeFeatures',
  69. 'searchFeatures',
  70. ];
  71. var availableSections = [];
  72. /**
  73. * set which section should be displayed
  74. */
  75. if(event.target.value == 'customMGkerio')
  76. {
  77. availableSections = [
  78. 'calendarFeatures',
  79. 'contactFeatures',
  80. 'essentialFeatures',
  81. 'generalFeatures',
  82. 'mailServiceFeatures',
  83. 'mimeFeatures',
  84. 'searchFeatures',
  85. ];
  86. }else if(event.target.value == 'kerioConfigurableOptions'){
  87. availableSections = [];
  88. }else if(event.target.value == 'cosQuota'){
  89. availableSections = [
  90. 'classOfServiceFeatures'
  91. ];
  92. }
  93. /**
  94. * hide or show sections
  95. */
  96. hideSecction(sections, availableSections);
  97. }
  98. /**
  99. * hide or display section
  100. * @param sections
  101. * @param availableSections
  102. */
  103. function hideSecction(sections, availableSections)
  104. {
  105. sections.forEach(function(entry, key, each){
  106. if(availableSections.includes(entry) === true)
  107. {
  108. document.getElementById(entry).style.display="";
  109. }else{
  110. document.getElementById(entry).style.display="none";
  111. }
  112. })
  113. }
  114. $(document).ready(function(){
  115. })
  116. $('#ProductConfigurationPage').ready(function()
  117. {
  118. /**
  119. * trigg change select
  120. */
  121. $("[name=cos_name]").trigger("change");
  122. // var packageName = $('select[name="mgpci[package]"]').val()
  123. //
  124. // if(packageName !== "custom")
  125. // {
  126. //
  127. // var protectedArrayFields = ['mgpci[package]','mgpci[dedicated_ip]','mgpci[reseller_ip]','mgpci[suspend_at_limit]'];
  128. // var fields = $('#layers').find('.lu-form-group , .lu-form-check')
  129. //
  130. // fields.each(function(){
  131. // var fieldName = $(this).find('input').attr('name')
  132. //
  133. // if(typeof fieldName === "undefined"){
  134. // fieldName = $(this).find('select').attr('name')
  135. // }
  136. // if (protectedArrayFields.indexOf(fieldName) === -1)
  137. // {
  138. // $(this).hide();
  139. // }
  140. // })
  141. //
  142. //
  143. // }
  144. })