summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/flash.js.coffee
blob: 5a493041538c82750b9981388bc5c42bdc1fe19b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
class @Flash
  hideFlash = -> $(@).fadeOut()

  constructor: (message, type = 'alert', parent = null)->
    if parent
      @flashContainer = parent.find('.flash-container')
    else
      @flashContainer = $('.flash-container-page')

    @flashContainer.html('')

    flash = $('<div/>',
      class: "flash-#{type}"
    )
    flash.on 'click', hideFlash

    textDiv = $('<div/>',
      class: 'flash-text',
      text: message
    )
    textDiv.appendTo(flash)

    if @flashContainer.parent().hasClass('content-wrapper')
      textDiv.addClass('container-fluid container-limited')

    flash.appendTo(@flashContainer)
    @flashContainer.show()