custom/plugins/ShopWithMeUI/src/Resources/views/storefront/component/toastNoti.html.twig line 1

Open in your IDE?
  1. <div class="swm-toast-notify">
  2.     <div class="toast-notify__icon">
  3.         <img class="width-full toast-notify__icon-success" src="{{ asset('bundles/shopwithmeui/assets/icons/toastNoti/success.svg') }}"/>
  4.         <img class="width-full toast-notify__icon-error" src="{{ asset('bundles/shopwithmeui/assets/icons/toastNoti/error.svg') }}"/>
  5.     </div>
  6.     <div class="toast-notify__content">
  7.     
  8.     </div>
  9.     <div class="toast-notify__close">
  10.         <img src="{{ asset('bundles/shopwithmeui/assets/icons/toastNoti-close.svg') }}"/>
  11.     </div>
  12. </div>
  13. <script>
  14.    function showToastNotify(message, options = {}) {
  15.         const { type } = options || {};
  16.         const notify = document.querySelector('.swm-toast-notify');
  17.         const notiClose = document.querySelector('.toast-notify__close');
  18.         const notiCloseIcon = document.querySelector('.toast-notify__close img');
  19.         const notiSuccess = document.querySelector('.toast-notify__icon-success');
  20.         const notiError = document.querySelector('.toast-notify__icon-error');
  21.         if (notify) {
  22.             notify.classList.add('show');
  23.             notify.classList.add(type);
  24.             if (type == 'success') {
  25.                 if (notiError) {
  26.                     notiError.classList.add('d-none-important');
  27.                 }
  28.                 if (notiSuccess) {
  29.                     notiSuccess.classList.remove('d-none-important');
  30.                 }
  31.             }
  32.             else {
  33.                 console.log('check error')
  34.                 if (notiError) {
  35.                     notiError.classList.remove('d-none-important');
  36.                 }
  37.                 if (notiSuccess) {
  38.                     notiSuccess.classList.add('d-none-important');
  39.                 }
  40.             }
  41.             notiCloseIcon.classList.add(type);
  42.             const content = notify.querySelector('.toast-notify__content');
  43.             content.innerHTML = message;
  44.             setTimeout(() => {
  45.                 notify.classList.remove('show');
  46.                 notify.classList.remove(type);
  47.                 notiCloseIcon.classList.remove(type);
  48.             }, 4000);
  49.         }
  50.         notiClose.addEventListener('click', () => {
  51.             notify.classList.remove('show');
  52.             notify.classList.remove(type);
  53.             notiCloseIcon.classList.remove(type);
  54.         })
  55.     }
  56. </script>