Sha256: fd247c8dac98761134f849d64b3a1fb186fbca8f55bfa28ea01fc749bef65616

Contents?: true

Size: 859 Bytes

Versions: 26

Compression:

Stored size: 859 Bytes

Contents

class App.Views.Shared.Flash extends App.Views.Base
  constructor: (opts = {}) ->
    super opts
    @notice = opts.notice ? null
    @alert = opts.alert ? null
    @warning = opts.warning ? null
    @hide = opts.hide ? true

  setNotice: (text) -> @notice = text
  setAlert: (text) -> @alert = text
  setWarning: (text) -> @warning = text

  render: ->
    node = $('.flash')
    node.removeClass('notice').removeClass('alert').removeClass('warning')
    if @notice?
      node.addClass 'notice'
      node.find('p').text @notice
    else if @alert?
      node.addClass 'alert'
      node.find('p').text @alert
    else if @warning?
      node.addClass 'warning'
      node.find('p').text @warning
    node.slideDown 'normal'
    this.hideAfterTime() if @hide

  hideAfterTime: (time = 4000) ->
    setTimeout ->
      $('.flash').slideUp 'normal'
    , time

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
loco-rails-3.0.3 test/dummy/app/assets/javascripts/views/shared/flash.coffee
loco-rails-2.5.3 test/dummy/app/assets/javascripts/views/shared/flash.coffee
loco-rails-2.5.2 test/dummy/app/assets/javascripts/views/shared/flash.coffee
loco-rails-3.0.2 test/dummy/app/assets/javascripts/views/shared/flash.coffee
loco-rails-3.0.1 test/dummy/app/assets/javascripts/views/shared/flash.coffee
loco-rails-2.5.1 test/dummy/app/assets/javascripts/views/shared/flash.coffee
loco-rails-2.5.0 test/dummy/app/assets/javascripts/views/shared/flash.coffee
loco-rails-2.4.0 test/dummy/app/assets/javascripts/views/shared/flash.coffee
loco-rails-2.3.0 test/dummy/app/assets/javascripts/views/shared/flash.coffee
loco-rails-3.0.0 test/dummy/app/assets/javascripts/views/shared/flash.coffee
loco-rails-2.2.2 test/dummy/app/assets/javascripts/views/shared/flash.coffee
loco-rails-2.2.1 test/dummy/app/assets/javascripts/views/shared/flash.coffee
loco-rails-2.2.0 test/dummy/app/assets/javascripts/views/shared/flash.coffee
loco-rails-2.1.0 test/dummy/app/assets/javascripts/views/shared/flash.coffee
loco-rails-2.0.0 test/dummy/app/assets/javascripts/views/shared/flash.coffee
loco-rails-1.5.2 test/dummy/app/assets/javascripts/views/shared/flash.coffee
loco-rails-1.5.1 test/dummy/app/assets/javascripts/views/shared/flash.coffee
loco-rails-1.5.0 test/dummy/app/assets/javascripts/views/shared/flash.coffee
loco-rails-1.4.0 test/dummy/app/assets/javascripts/views/shared/flash.coffee
loco-rails-1.3.3 test/dummy/app/assets/javascripts/views/shared/flash.coffee