Sha256: 73f66bd8e753167b26b3ea9665da22afde367a543423be65023ce2442a1ec0ae

Contents?: true

Size: 1.18 KB

Versions: 15

Compression:

Stored size: 1.18 KB

Contents

# jQuery plugin
$.hideModal = ->
  hideModal()

$.fn.modal = ->
  showModal($(this))

$(document).on 'click', 'a[data-toggle="modal"]', ->
  link = $(this)
  modal = $(link.attr('href'))
  showModal(modal)

$(document).on 'click', 'body.overlay', ->
  hideModal()

$(document).on 'click', '[data-dismiss="modal"]', ->
  hideModal()

$(document).on 'keyup', 'body.overlay', (e) ->
  hideModal() if e.keyCode == 27

$(document).on 'click', '.modal', (e) ->
  e.stopPropagation()

hideModal = ->
  $('body').removeClass('overlay')
  $('#overlay .modal').addClass('flyOut')
  $('#overlay').fadeOut 300, ->
    $(this).remove()
  return false

showModal = (element) ->
  modal = element.clone()
  modal.addClass('animated flyIn')

  if $('#overlay').length < 1
    $('body').append('<div id="overlay"></div>')
  else
    $('#overlay').html('')

  maxheight = window.innerHeight - (window.innerHeight / 8) - 150

  modal.css({"margin-top": window.innerHeight / 8})
  modal.find('section').css({"max-height": maxheight})

  modal.appendTo('#overlay')
  $('#overlay').fadeIn(400)
  modal.show()

  modal.find('input[type="file"][data-customfileinput]').customFileInput()

  $('body').addClass('overlay')
  return false

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
spina-2.0.2 app/assets/javascripts/spina/admin/modal.coffee
spina-2.0.1 app/assets/javascripts/spina/admin/modal.coffee
spina-2.0.0 app/assets/javascripts/spina/admin/modal.coffee
spina-2.0.0.beta app/assets/javascripts/spina/admin/modal.coffee
spina-2.0.0.alpha app/assets/javascripts/spina/admin/modal.coffee
spina-1.2.0 app/assets/javascripts/spina/admin/modal.coffee
spina-1.1.4 app/assets/javascripts/spina/admin/modal.coffee
spina-1.1.3 app/assets/javascripts/spina/admin/modal.coffee
spina-1.1.2 app/assets/javascripts/spina/admin/modal.coffee
spina-1.1.1 app/assets/javascripts/spina/admin/modal.coffee
spina-1.1.0 app/assets/javascripts/spina/admin/modal.coffee
spina-1.0.3 app/assets/javascripts/spina/admin/modal.coffee
spina-1.0.2 app/assets/javascripts/spina/admin/modal.coffee
spina-1.0.1 app/assets/javascripts/spina/admin/modal.coffee
spina-1.0.0 app/assets/javascripts/spina/admin/modal.coffee