Без опису
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. /**
  2. * Account Settings - Security
  3. */
  4. 'use strict';
  5. document.addEventListener('DOMContentLoaded', function (e) {
  6. (function () {
  7. const formChangePass = document.querySelector('#formAccountSettings'),
  8. formApiKey = document.querySelector('#formAccountSettingsApiKey');
  9. // Form validation for Change password
  10. if (formChangePass) {
  11. const fv = FormValidation.formValidation(formChangePass, {
  12. fields: {
  13. currentPassword: {
  14. validators: {
  15. notEmpty: {
  16. message: 'Please current password'
  17. },
  18. stringLength: {
  19. min: 8,
  20. message: 'Password must be more than 8 characters'
  21. }
  22. }
  23. },
  24. newPassword: {
  25. validators: {
  26. notEmpty: {
  27. message: 'Please enter new password'
  28. },
  29. stringLength: {
  30. min: 8,
  31. message: 'Password must be more than 8 characters'
  32. }
  33. }
  34. },
  35. confirmPassword: {
  36. validators: {
  37. notEmpty: {
  38. message: 'Please confirm new password'
  39. },
  40. identical: {
  41. compare: function () {
  42. return formChangePass.querySelector('[name="newPassword"]').value;
  43. },
  44. message: 'The password and its confirm are not the same'
  45. },
  46. stringLength: {
  47. min: 8,
  48. message: 'Password must be more than 8 characters'
  49. }
  50. }
  51. }
  52. },
  53. plugins: {
  54. trigger: new FormValidation.plugins.Trigger(),
  55. bootstrap5: new FormValidation.plugins.Bootstrap5({
  56. eleValidClass: '',
  57. rowSelector: '.form-control-validation'
  58. }),
  59. submitButton: new FormValidation.plugins.SubmitButton(),
  60. // Submit the form when all fields are valid
  61. // defaultSubmit: new FormValidation.plugins.DefaultSubmit(),
  62. autoFocus: new FormValidation.plugins.AutoFocus()
  63. },
  64. init: instance => {
  65. instance.on('plugins.message.placed', function (e) {
  66. if (e.element.parentElement.classList.contains('input-group')) {
  67. e.element.parentElement.insertAdjacentElement('afterend', e.messageElement);
  68. }
  69. });
  70. }
  71. });
  72. }
  73. // Form validation for API key
  74. if (formApiKey) {
  75. const fvApi = FormValidation.formValidation(formApiKey, {
  76. fields: {
  77. apiKey: {
  78. validators: {
  79. notEmpty: {
  80. message: 'Please enter API key name'
  81. }
  82. }
  83. }
  84. },
  85. plugins: {
  86. trigger: new FormValidation.plugins.Trigger(),
  87. bootstrap5: new FormValidation.plugins.Bootstrap5({
  88. eleValidClass: ''
  89. }),
  90. submitButton: new FormValidation.plugins.SubmitButton(),
  91. // Submit the form when all fields are valid
  92. // defaultSubmit: new FormValidation.plugins.DefaultSubmit(),
  93. autoFocus: new FormValidation.plugins.AutoFocus()
  94. },
  95. init: instance => {
  96. instance.on('plugins.message.placed', function (e) {
  97. if (e.element.parentElement.classList.contains('input-group')) {
  98. e.element.parentElement.insertAdjacentElement('afterend', e.messageElement);
  99. }
  100. });
  101. }
  102. });
  103. }
  104. })();
  105. });
  106. // Select2 (jquery)
  107. $(function () {
  108. var select2 = $('.select2');
  109. // Select2 API Key
  110. if (select2.length) {
  111. select2.each(function () {
  112. var $this = $(this);
  113. $this.wrap('<div class="position-relative"></div>');
  114. $this.select2({
  115. dropdownParent: $this.parent()
  116. });
  117. });
  118. }
  119. });