g_flash_growler 1.0.7 → 1.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,3 +1,11 @@
1
+ == 1.0.8 2010-04-22
2
+
3
+ * Removed a debugger statement.
4
+
5
+ == 1.0.8 2010-04-22
6
+
7
+ * Added a mapping mechanism for differently keyed flash messages.
8
+
1
9
  == 1.0.7 2010-04-22
2
10
 
3
11
  * Added Rails 3 compliant generator.
@@ -22,27 +22,41 @@ slide out of view if JavaScript is enabled.
22
22
 
23
23
  == INSTALL:
24
24
 
25
- sudo gem install g_flash_growler
25
+ Configure the Gem for use:
26
26
 
27
- In Rails environment.rb file:
27
+ gem 'g_flash_growler', '1.0.7' # Rails 3
28
+ config.gem 'g_flash_growler', :version => '1.0.7' # Rails 2
28
29
 
29
- config.gem 'g_flash_growler', :version => '1.0.7'
30
+ Install the Gem:
31
+
32
+ bundle install # Rails 3
33
+ rake gems:install # Rails 2
34
+ gem install g_flash_growler # Manual
30
35
 
31
36
  Run the assets generator:
32
37
 
33
- script/generate flash_growler_assets_generator
38
+ rails generate flash_growler # Rails 3
39
+ script/generate flash_growler_assets_generator # Rails 2
34
40
 
35
41
 
36
42
  == USE:
37
43
 
38
44
  Call the flash growler helper somewhere in your view(s). I usually call it in the application layout (or another layout):
39
45
 
40
- <%= g_flash_growler :id => 'growler', :position => 'bottom' %>
46
+ <%= raw( g_flash_growler( :id => 'growler', :position => 'bottom' ) ) %> # Rails 3
47
+ <%= g_flash_growler( :id => 'growler', :position => 'bottom' ) %> # Rails 2
41
48
 
42
49
  Also, as with all Guilded components, a call to the apply behavior helper. It also makes the most sense to do this
43
50
  in your layout(s):
44
51
 
45
- <%= g_apply_behavior %>
52
+ <%= raw g_apply_behavior %> # Rails 3
53
+ <%= g_apply_behavior %> # Rails 2
54
+
55
+ To map differently keyed flash messages into one of the flash growler's:
56
+
57
+ <%= g_flash_growler( :id => 'growler', :position => 'bottom', :mappings => { :alert => :warning } ) %>
58
+
59
+ This will map flash[:alert] to flash[:warning] so that flash growler will react to the message.
46
60
 
47
61
 
48
62
  == OPTIONS:
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.7
1
+ 1.0.9
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{g_flash_growler}
8
- s.version = "1.0.7"
8
+ s.version = "1.0.9"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["C. Jason Harrelson (midas)"]
@@ -4,7 +4,7 @@ $:.unshift(File.dirname(__FILE__)) unless
4
4
  require 'g_flash_growler/view_helpers'
5
5
 
6
6
  module GFlashGrowler
7
- VERSION = '1.0.7'
7
+ VERSION = '1.0.9'
8
8
  end
9
9
 
10
10
  if defined?( ActionView )
@@ -4,17 +4,18 @@ module GFlashGrowler
4
4
  def g_flash_growler( *args )
5
5
  return '' if flash.nil? || flash.empty?
6
6
  options = args.extract_options!
7
- #raise ArgumentError, "'cols' option required" unless options.include?( :cols )
7
+ mappings = options[:mappings] || {}
8
8
 
9
- position_cls = ''
10
- if options[:position] == 'top'
11
- position_cls = 'growl-top'
12
- else
13
- position_cls = 'growl-bottom'
14
- end
9
+ position_cls = options[:position] == 'top' ? 'growl-top' : 'growl-bottom'
15
10
 
16
11
  Guilded::Guilder.instance.add( :flash_growler, options, [ 'jquery/jquery-growler-0.1.min.js' ] )
17
12
 
13
+ flash_key = flash.keys.first
14
+ unless [:error, :warning, :notice].include?( flash_key )
15
+ mapped_key = mappings[flash_key.to_sym]
16
+ flash[mapped_key.to_sym] = flash[flash_key]
17
+ end
18
+
18
19
  if flash[:error]
19
20
  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>"
20
21
  elsif flash[:warning]
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 1
7
7
  - 0
8
- - 7
9
- version: 1.0.7
8
+ - 9
9
+ version: 1.0.9
10
10
  platform: ruby
11
11
  authors:
12
12
  - C. Jason Harrelson (midas)