Module: Sinatra::FlashHelper

Defined in:
lib/sinatra/pretty-flash.rb

Instance Method Summary collapse

Instance Method Details

#pretty_flash_cssObject



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/sinatra/pretty-flash.rb', line 14

def pretty_flash_css
  output = ''
  output += '<style>'
  output += '.flash {'
  output += '  position: fixed;'
  output += '  padding: 0;'
  output += '  margin: 0;'
  output += '  bottom: 0;'
  output += '  left: 0;'
  output += '  width: 100%;'
  output += '  height: 60px;'
  output += '  line-height: 60px;'
  output += '  background: rgba(0, 0, 0, 0.85);'
  output += '  color: rgba(255, 255, 255, 1.0);'
  output += '  text-align: center;'
  output += '  font-size: 24px;'
  output += '}'
  output += '</style>'
  output
end

#pretty_flash_htmlObject



35
36
37
38
39
40
41
42
43
44
45
# File 'lib/sinatra/pretty-flash.rb', line 35

def pretty_flash_html
  output = ''
  output += '<% if flash[:notice] %>'
  output += '  <p class="flash notice"><%= flash[:notice] %></p>'
  output += '<% end %>'

  output += '<% if flash[:error] %>'
  output += '  <p class="flash error"><%= flash[:error] %></p>'
  output += '<% end %>'
  output
end

#pretty_flash_jsObject



47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/sinatra/pretty-flash.rb', line 47

def pretty_flash_js
  output = ''
  output += '<script src="//code.jquery.com/jquery-1.11.2.min.js"></script>'
  output += '<script>'
  output += '$(function() {'
  output += '  $(".flash").delay(500).fadeIn("normal", function() {'
  output += '     $(this).delay(1500).fadeOut();'
  output += '   });'
  output += '});'
  output += '</script>'
  output
end