module Sinatra::FlashHelper

Public Instance Methods

pretty_flash_css() click to toggle source
# 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_html() click to toggle source
# 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_js() click to toggle source
# 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