Нема описа
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.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. /**
  2. * Form Wizard
  3. */
  4. 'use strict';
  5. // star rating
  6. document.addEventListener('DOMContentLoaded', function (e) {
  7. let r = parseInt(window.Helpers.getCssVar('gray-200', true).slice(1, 3), 16);
  8. let g = parseInt(window.Helpers.getCssVar('gray-200', true).slice(3, 5), 16);
  9. let b = parseInt(window.Helpers.getCssVar('gray-200', true).slice(5, 7), 16);
  10. const readOnlyRating = document.querySelectorAll('.read-only-ratings');
  11. const fullStarSVG =
  12. "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' width='16' %3E%3Cpath fill='%23FFD700' d='M21.947 9.179a1 1 0 0 0-.868-.676l-5.701-.453l-2.467-5.461a.998.998 0 0 0-1.822-.001L8.622 8.05l-5.701.453a1 1 0 0 0-.619 1.713l4.213 4.107l-1.49 6.452a1 1 0 0 0 1.53 1.057L12 18.202l5.445 3.63a1.001 1.001 0 0 0 1.517-1.106l-1.829-6.4l4.536-4.082c.297-.268.406-.686.278-1.065'/%3E%3C/svg%3E";
  13. const emptyStarSVG =
  14. "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' width='16' %3E%3Cpath fill='rgb(" +
  15. r +
  16. ',' +
  17. g +
  18. ',' +
  19. b +
  20. ")' d='M21.947 9.179a1 1 0 0 0-.868-.676l-5.701-.453l-2.467-5.461a.998.998 0 0 0-1.822-.001L8.622 8.05l-5.701.453a1 1 0 0 0-.619 1.713l4.213 4.107l-1.49 6.452a1 1 0 0 0 1.53 1.057L12 18.202l5.445 3.63a1.001 1.001 0 0 0 1.517-1.106l-1.829-6.4l4.536-4.082c.297-.268.406-.686.278-1.065'/%3E%3C/svg%3E";
  21. readOnlyRating.forEach(element => {
  22. let ratings = new Raty(element, {
  23. starOn: fullStarSVG,
  24. starOff: emptyStarSVG
  25. });
  26. ratings.init();
  27. });
  28. });
  29. (function () {
  30. // Init custom option check
  31. window.Helpers.initCustomOptionCheck();
  32. // libs
  33. const creditCardMask = document.querySelector('.credit-card-mask'),
  34. expiryDateMask = document.querySelector('.expiry-date-mask'),
  35. cvvMask = document.querySelector('.cvv-code-mask');
  36. // Credit Card
  37. if (creditCardMask) {
  38. creditCardMask.addEventListener('input', event => {
  39. creditCardMask.value = formatCreditCard(event.target.value);
  40. const cleanValue = event.target.value.replace(/\D/g, '');
  41. let cardType = getCreditCardType(cleanValue);
  42. if (cardType && cardType !== 'unknown' && cardType !== 'general') {
  43. document.querySelector('.card-type').innerHTML =
  44. `<img src="${assetsPath}img/icons/payments/${cardType}-cc.png" height="19"/>`;
  45. } else {
  46. document.querySelector('.card-type').innerHTML = '';
  47. }
  48. });
  49. registerCursorTracker({
  50. input: creditCardMask,
  51. delimiter: ' '
  52. });
  53. }
  54. // Expiry Date Mask
  55. if (expiryDateMask) {
  56. expiryDateMask.addEventListener('input', event => {
  57. expiryDateMask.value = formatDate(event.target.value, {
  58. delimiter: '/',
  59. datePattern: ['m', 'y']
  60. });
  61. });
  62. registerCursorTracker({
  63. input: expiryDateMask,
  64. delimiter: '-'
  65. });
  66. }
  67. // CVV
  68. if (cvvMask) {
  69. cvvMask.addEventListener('input', event => {
  70. cvvMask.value = formatNumeral(event.target.value, {
  71. numeralThousandsGroupStyle: 'thousand'
  72. });
  73. });
  74. }
  75. // Wizard Checkout
  76. // --------------------------------------------------------------------
  77. const wizardCheckout = document.querySelector('#wizard-checkout'),
  78. wizardCheckoutBtnNextList = [].slice.call(wizardCheckout.querySelectorAll('.btn-next')),
  79. wizardCheckoutBtnSubmit = wizardCheckout.querySelector('.btn-submit');
  80. if (typeof wizardCheckout !== undefined && wizardCheckout !== null) {
  81. const numberedStepper = new Stepper(wizardCheckout, {
  82. linear: false
  83. });
  84. if (wizardCheckoutBtnNextList) {
  85. wizardCheckoutBtnNextList.forEach(wizardCheckoutBtnNext => {
  86. wizardCheckoutBtnNext.addEventListener('click', event => {
  87. numberedStepper.next();
  88. });
  89. });
  90. }
  91. if (wizardCheckoutBtnSubmit) {
  92. wizardCheckoutBtnSubmit.addEventListener('click', event => {
  93. alert('Submitted..!!');
  94. });
  95. }
  96. }
  97. })();