Sha256: a9dedb683e6a48e3efc016881471b9b972c94d0c4e512da518815f3ef706793e

Contents?: true

Size: 1.46 KB

Versions: 3

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')
    }, 250)
    $('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

3 entries across 3 versions & 1 rubygems

Version Path
lato_core-2.2.2 app/assets/javascripts/lato_core/modules/CoreModal.js
lato_core-2.2.0 app/assets/javascripts/lato_core/modules/CoreModal.js
lato_core-2.1.4 app/assets/javascripts/lato_core/modules/CoreModal.js