Sha256: 6e598b73e1b68bd74dd6436167fbdf75c38f135fd2790957eae4e46b4639e94c

Contents?: true

Size: 659 Bytes

Versions: 1

Compression:

Stored size: 659 Bytes

Contents

Sprangular.factory 'Flash', ($timeout, $translate) ->
  messages: []

  add: (type, translate_key) ->
    self = this

    $translate(translate_key).then (translated) ->
      flash = type: type, text: translated

      self.messages.push(flash)
      self.timeout(flash)

  timeout: (flash) ->
    self = this
    $timeout((-> self.remove(flash)), 2500)

  success: (translate_key) -> @add('success', translate_key)
  info:    (translate_key) -> @add('info',    translate_key)
  error:   (translate_key) -> @add('danger',  translate_key)

  remove: (flash) ->
    @messages = @messages.filter (x) -> x != flash

  hasMessages: () ->
    @messages.length > 0

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
sprangular-0.1.0 app/assets/javascripts/sprangular/services/flash.coffee