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.
- data/History.txt +8 -0
- data/README.rdoc +20 -6
- data/VERSION +1 -1
- data/g_flash_growler.gemspec +1 -1
- data/lib/g_flash_growler.rb +1 -1
- data/lib/g_flash_growler/view_helpers.rb +8 -7
- metadata +2 -2
data/History.txt
CHANGED
data/README.rdoc
CHANGED
|
@@ -22,27 +22,41 @@ slide out of view if JavaScript is enabled.
|
|
|
22
22
|
|
|
23
23
|
== INSTALL:
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
Configure the Gem for use:
|
|
26
26
|
|
|
27
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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.
|
|
1
|
+
1.0.9
|
data/g_flash_growler.gemspec
CHANGED
data/lib/g_flash_growler.rb
CHANGED
|
@@ -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
|
-
|
|
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]
|