Module: FlashGrowler::ViewHelpers

Defined in:
lib/flash_growler/view_helpers.rb

Instance Method Summary collapse

Instance Method Details

#g_flash_growler(*args) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/flash_growler/view_helpers.rb', line 4

def g_flash_growler( *args )
  return '' if flash.nil? || flash.empty?
  options = args.extract_options!
  #raise ArgumentError, "'cols' option required" unless options.include?( :cols )
  
  position_cls = ''
  if options[:position] == 'top'
    position_cls = 'growl-top'
  else
    position_cls = 'growl-bottom'
  end
  
  Guilded::Guilder.instance.add( :flash_growler, options, [ 'jquery/jquery-growler-0.1.js' ] )
  
  if flash[:error]
    return "<div class=\"growl flash error #{position_cls}\" id=\"#{options[:id]}\"><div id=\"growl-icon-error\"></div><h3>Error</h3><p>#{flash[:error]}</p></div>"
  elsif flash[:warning]
    return "<div class=\"growl flash warning #{position_cls}\" id=\"#{options[:id]}\"><div id=\"growl-icon-alert\"></div><h3>Warning</h3><p>#{flash[:warning]}</p></div>"
  elsif flash[:notice]
    return "<div class=\"growl flash notice #{position_cls}\" id=\"#{options[:id]}\"><div id=\"growl-icon-msg\"></div><h3>Info</h3><p>#{flash[:notice]}</p></div>"
  end
end