bootstrap_flash_messages 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # bootstrap_flash_messages
2
2
 
3
- version 0.0.6
3
+ version 0.0.7
4
4
  Robin Brouwer
5
5
  45north
6
6
 
@@ -22,6 +22,10 @@ And that's it!
22
22
 
23
23
  ## Changes
24
24
 
25
+ Version 0.0.7 changes (26/01/2013):
26
+
27
+ - Added alert_class_mapping (documentation below).
28
+
25
29
  Version 0.0.6 changes (27/09/2012):
26
30
 
27
31
  - Added pull request #5 by protolif. This adds the :fade option.
@@ -160,6 +164,36 @@ Inside `flash.en.yml` you can do the following:
160
164
  success: "Welcome, %{name}."
161
165
  info: "Your e-mail address has been changed to: %{email}."
162
166
 
167
+ ## alert_class_mapping
168
+
169
+ You can map the keys used inside the flash messages to a different alert class. There are 4 different classes for the alert messages inside bootstrap:
170
+
171
+ alert-success
172
+ alert-info
173
+ alert-warning
174
+ alert-error
175
+
176
+ When you use `:notice` the alert class is mapped (by default) to `alert-success`. So it looks like this:
177
+
178
+ :notice maps to "alert-success"
179
+ :success maps to "alert-success"
180
+ :info maps to "alert-info"
181
+ :warning maps to "alert-warning"
182
+ :error maps to "alert-error"
183
+
184
+ Changing the mapping is quite easy. Create an initializer (config/initializers/bootstrap_flash_messages.rb) and add the following:
185
+
186
+ module BootstrapFlashMessages
187
+ @alert_class_mapping = {
188
+ :notice => :error,
189
+ :success => :success,
190
+ :info => :info,
191
+ :warning => :warning,
192
+ :error => :error
193
+ }
194
+ end
195
+
196
+ Now you can map whatever alert class you want to the different keys.
163
197
 
164
198
  ## Why I created this gem
165
199
 
@@ -23,7 +23,7 @@ module BootstrapFlashMessages
23
23
 
24
24
  value.gsub!("\n", "<br/>") if convert_newlines
25
25
 
26
- messages << content_tag(:div, :class => "alert alert-#{key}#{" alert-block" if block}#{" fade in" if fade}") do
26
+ messages << content_tag(:div, :class => "alert alert-#{BootstrapFlashMessages.alert_class_mapping(key)}#{" alert-block" if block}#{" fade in" if fade}") do
27
27
  close + heading + " " + (unescape_html || convert_newlines ? raw(value) : value)
28
28
  end
29
29
  end
@@ -1,3 +1,3 @@
1
1
  module BootstrapFlashMessages
2
- VERSION = "0.0.6"
2
+ VERSION = "0.0.7"
3
3
  end
@@ -2,6 +2,12 @@ require 'bootstrap_flash_messages/helpers'
2
2
  require 'bootstrap_flash_messages/flash_messages'
3
3
 
4
4
  module BootstrapFlashMessages
5
+ @alert_class_mapping = { :notice => :success, :success => :success, :info => :info, :warning => :warning, :error => :error }
6
+
7
+ def self.alert_class_mapping(key)
8
+ @alert_class_mapping[key.to_sym]
9
+ end
10
+
5
11
  def self.initialize
6
12
  return if @initialized
7
13
  raise "ActionController is not available yet." unless defined?(ActionController)
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bootstrap_flash_messages
3
3
  version: !ruby/object:Gem::Version
4
- hash: 19
4
+ hash: 17
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 6
10
- version: 0.0.6
9
+ - 7
10
+ version: 0.0.7
11
11
  platform: ruby
12
12
  authors:
13
13
  - Robin Brouwer
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-09-27 00:00:00 +02:00
18
+ date: 2013-01-26 00:00:00 +01:00
19
19
  default_executable:
20
20
  dependencies: []
21
21