flash.js.coffee 556 Bytes
Newer Older
1
class @Flash
Alfredo Sumaran's avatar
Alfredo Sumaran committed
2
  constructor: (message, type = 'alert')->
3
4
    @flash = $(".flash-container")
    @flash.html("")
5

6
    innerDiv = $('<div/>',
7
      class: "flash-#{type}"
8
9
    )
    innerDiv.appendTo(".flash-container")
10

11
12
13
14
15
16
17
18
19
    textDiv = $("<div/>",
      class: "flash-text",
      text: message
    )
    textDiv.appendTo(innerDiv)

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

20
21
22
    @flash.click -> $(@).fadeOut()
    @flash.show()

23
24
  pinTo: (selector) ->
    @flash.detach().appendTo(selector)