Sha256: 9df26af5b839a7ea5d008701b148025d175be8da50a9ee9c75e6da9229f1085d

Contents?: true

Size: 1.22 KB

Versions: 25

Compression:

Stored size: 1.22 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()
  modal.find('.new_photo').uploadPhoto()

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

Version data entries

25 entries across 25 versions & 2 rubygems

Version Path
spina-0.12.0 app/assets/javascripts/spina/admin/modal.coffee
spina-0.11.1 app/assets/javascripts/spina/admin/modal.coffee
spina-0.11.0 app/assets/javascripts/spina/admin/modal.coffee
spina-template-0.4.2 app/assets/javascripts/spina/modal.coffee
spina-template-0.4.1 app/assets/javascripts/spina/modal.coffee
spina-template-0.4.0 app/assets/javascripts/spina/modal.coffee
spina-template-0.3.3 app/assets/javascripts/spina/modal.coffee
spina-template-0.3.2 app/assets/javascripts/spina/modal.coffee
spina-template-0.3.1 app/assets/javascripts/spina/modal.coffee
spina-template-0.3.0 app/assets/javascripts/spina/modal.coffee
spina-template-0.2.18 app/assets/javascripts/spina/modal.js.coffee
spina-template-0.2.17 app/assets/javascripts/spina/modal.js.coffee
spina-template-0.2.16 app/assets/javascripts/spina/modal.js.coffee
spina-template-0.2.15 app/assets/javascripts/spina/modal.js.coffee
spina-template-0.2.14 app/assets/javascripts/spina/modal.js.coffee
spina-template-0.2.13 app/assets/javascripts/spina/modal.js.coffee
spina-template-0.2.12 app/assets/javascripts/spina/modal.js.coffee
spina-template-0.2.11 app/assets/javascripts/spina/modal.js.coffee
spina-template-0.2.10 app/assets/javascripts/spina/modal.js.coffee
spina-template-0.2.9 app/assets/javascripts/spina/modal.js.coffee