Sha256: 8c9c437d259f89515a9dc2a5e6838c16ef4e7ae11381ce0d370f70ee5bd20354

Contents?: true

Size: 1.92 KB

Versions: 3

Compression:

Stored size: 1.92 KB

Contents

var ElementsInitializer = (function () {

  function modalCloseButton () {
    $('.elements-modal__close-button').click(function (e) {
      var modal = $(this).parent()
      var modalContent = modal.parent()
      var modalContainer = modalContent.parent()
      modalContainer.removeClass('elements-modal--active')
      modalContainer.find('.elements-modal__modal').removeClass('elements-modal__modal--active')
      $('body').removeClass('stop-scrolling')
      e.preventDefault()
    })
  }

  function flashCloseButton () {
    $('.elements-flash__close-button').click(function (e) {
      var flash = $(this).parent()
      flash.addClass('elements-flash--hidden')
      e.preventDefault()
    })
  }

  function tableHeadFixed () {
    var table = $('.elements-table--fixed .elements-table__table')
    table.floatThead({
      scrollContainer: function (table) {
        return table.closest('.elements-table--fixed')
      }
    })
  }

  function buttonConfirmation () {
    var button = $('.elements-button__element')
    button.click(function (e) {
      if ($(this).attr('data-confirmation') && $(this).attr('data-confirmation') === 'true') {
        var confirmation = $(this).parent().find('.elements-button__confirmation')

        // remove old confirmations popup
        $('.elements-button__element').parent().find('.elements-button__confirmation').removeClass('elements-button__confirmation--active')
        // open confirmation popup
        $(confirmation).addClass('elements-button__confirmation--active')
        // manage delete click
        $(confirmation).find('.button.popup.false').click(function(e) {
          $(confirmation).removeClass('elements-button__confirmation--active')
          e.preventDefault()
        })

        e.preventDefault()
      }
    })
  }

  // Init:

  function init () {
    modalCloseButton()
    flashCloseButton()
    tableHeadFixed()
    buttonConfirmation()
  }

  return {
    init: init
  }

})()

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
lato_core-2.1.2 app/assets/javascripts/lato_core/initializers/Elements.js
lato_core-2.1.1 app/assets/javascripts/lato_core/initializers/Elements.js
lato_core-2.1 app/assets/javascripts/lato_core/initializers/Elements.js