debian-mirror-gitlab/app/assets/javascripts/flash.js.coffee
2016-08-24 12:49:21 +05:30

28 lines
650 B
CoffeeScript

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()