JAVASCRIPT   100

showLoading.js

Guest on 29th July 2021 03:21:29 PM

  1. import * as dom from '../utils/dom/index'
  2. import sweetAlert from '../sweetalert2'
  3. import { swalClasses } from '../utils/classes'
  4.  
  5. /**
  6.  * Show spinner instead of Confirm button and disable Cancel button
  7.  */
  8. const showLoading = () => {
  9.   let popup = dom.getPopup()
  10.   if (!popup) {
  11.     sweetAlert('')
  12.   }
  13.   popup = dom.getPopup()
  14.   const actions = dom.getActions()
  15.   const confirmButton = dom.getConfirmButton()
  16.   const cancelButton = dom.getCancelButton()
  17.  
  18.   dom.show(actions)
  19.   dom.show(confirmButton)
  20.   dom.addClass([popup, actions], swalClasses.loading)
  21.   confirmButton.disabled = true
  22.   cancelButton.disabled = true
  23.  
  24.   popup.setAttribute('data-loading', true)
  25.   popup.setAttribute('aria-busy', true)
  26.   popup.focus()
  27. }
  28.  
  29. export {
  30.   showLoading,
  31.   showLoading as enableLoading
  32. }

Raw Paste


Login or Register to edit or fork this paste. It's free.