Geen omschrijving
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

modal-edit-user.js 1.5KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /**
  2. * Edit User
  3. */
  4. 'use strict';
  5. // Select2 (jquery)
  6. $(function () {
  7. const select2 = $('.select2');
  8. // Select2 Country
  9. if (select2.length) {
  10. select2.each(function () {
  11. var $this = $(this);
  12. $this.wrap('<div class="position-relative"></div>').select2({
  13. placeholder: 'Select value',
  14. dropdownParent: $this.parent()
  15. });
  16. });
  17. }
  18. });
  19. document.addEventListener('DOMContentLoaded', function (e) {
  20. (function () {
  21. // variables
  22. const modalEditUserTaxID = document.querySelector('.modal-edit-tax-id');
  23. const modalEditUserPhone = document.querySelector('.phone-number-mask');
  24. // Prefix
  25. if (modalEditUserTaxID) {
  26. const prefixOption = {
  27. prefix: 'TIN',
  28. blocks: [3, 3, 3, 4],
  29. delimiter: ' '
  30. };
  31. registerCursorTracker({
  32. input: modalEditUserTaxID,
  33. delimiter: ' '
  34. });
  35. modalEditUserTaxID.value = formatGeneral('', prefixOption);
  36. modalEditUserTaxID.addEventListener('input', event => {
  37. modalEditUserTaxID.value = formatGeneral(event.target.value, prefixOption);
  38. });
  39. }
  40. // Phone Number Input Mask
  41. if (modalEditUserPhone) {
  42. modalEditUserPhone.addEventListener('input', event => {
  43. const cleanValue = event.target.value.replace(/\D/g, '');
  44. modalEditUserPhone.value = formatGeneral(cleanValue, {
  45. blocks: [3, 3, 4],
  46. delimiters: [' ', ' ']
  47. });
  48. });
  49. registerCursorTracker({
  50. input: modalEditUserPhone,
  51. delimiter: ' '
  52. });
  53. }
  54. })();
  55. });