Sha256: 044a5be36f615a738816d9eadb70b04abbd7e2d1c4e11aec51bafa05ee883dbb

Contents?: true

Size: 1.46 KB

Versions: 1

Compression:

Stored size: 1.46 KB

Contents

var CoreModal = (function () {

  function open (modalId, event) {
    $('#' + modalId + '.elements-modal').addClass('elements-modal--active')
    setTimeout(function () {
      $('#' + modalId + '.elements-modal').find('.elements-modal__modal').addClass('elements-modal__modal--active')
    }, 500)
    $('body').addClass('stop-scrolling')
    if (event) {
      event.preventDefault()
    }
  }

  function close (modalId, event) {
    $('#' + modalId + '.elements-modal').removeClass('elements-modal--active')
    $('#' + modalId + '.elements-modal').find('.elements-modal__modal').removeClass('elements-modal__modal--active')
    $('body').removeClass('stop-scrolling')
    if (event) {
      event.preventDefault()
    }
  }

  function initializeModalCloseButton (modal) {
    var closeButton = $(modal).find('.elements-modal__close-button')
    $(closeButton).click(function (e) {
      e.preventDefault()
      // close modal
      $(modal).removeClass('elements-modal--active')
      $(modal).find('.elements-modal__modal').removeClass('elements-modal__modal--active')
      // active body scrolling
      $('body').removeClass('stop-scrolling')
    })
  }

  function _initModalCloseButton () {
    $('.elements-modal').each(function () {
      initializeModalCloseButton(this)
    })
  }

  // Init:
  function init () {
    _initModalCloseButton()
  }

  return {
    init: init,
    initializeModalCloseButton: initializeModalCloseButton,
    open: open,
    close: close
  }

})()

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
lato_core-2.1.3 app/assets/javascripts/lato_core/modules/CoreModal.js