gritter 0.6.0 → 0.6.1
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/{README.markdown → README.md} +22 -18
- data/lib/gritter/helpers.rb +1 -1
- data/lib/gritter/version.rb +1 -1
- metadata +4 -4
@@ -75,21 +75,21 @@ There are several helpers you can use with gritter. All of them print out Javasc
|
|
75
75
|
remove_gritter
|
76
76
|
extend_gritter
|
77
77
|
|
78
|
-
To add the script-tags we added another function called
|
78
|
+
To add the script-tags we added another function called `js`. It allows you to easily add script-tags around your javascript.
|
79
79
|
It can be used in combination with gritter, but also other Javascript you want to run.
|
80
80
|
|
81
|
-
Since version 0.3 we also added a gflash helper. This helper supports locales since version 0.6. You can read more about this helper below.
|
81
|
+
Since version 0.3 we also added a `gflash` helper. This helper supports locales since version 0.6. You can read more about this helper below.
|
82
82
|
|
83
83
|
|
84
84
|
### add_gritter
|
85
85
|
|
86
|
-
The add_gritter helper allows you to add a gritter notification to your application.
|
87
|
-
It outputs Javascript directly into your template. It works like this inside a js.erb file:
|
86
|
+
The `add_gritter` helper allows you to add a gritter notification to your application.
|
87
|
+
It outputs Javascript directly into your template. It works like this inside a `js.erb` file:
|
88
88
|
|
89
89
|
<%= add_gritter("This is a notification just for you!") %>
|
90
90
|
|
91
|
-
The add_gritter helper allows you to easily set the text for the notification.
|
92
|
-
When you want to change the title, just pass the
|
91
|
+
The `add_gritter` helper allows you to easily set the text for the notification.
|
92
|
+
When you want to change the title, just pass the `:title` argument to the helper:
|
93
93
|
|
94
94
|
<%= add_gritter("This is a notification just for you!", :title => "Please pay attention!") %>
|
95
95
|
|
@@ -105,7 +105,7 @@ There are many more arguments you can pass to the helper:
|
|
105
105
|
:before_close => "alert('Closing!');" # => Execute javascript before closing.
|
106
106
|
:after_close => "alert('Closed!');" # => Execute javascript after closing.
|
107
107
|
|
108
|
-
The
|
108
|
+
The `:image` argument also allows you to easily set five different images:
|
109
109
|
|
110
110
|
:success
|
111
111
|
:warning
|
@@ -113,7 +113,7 @@ The :image argument also allows you to easily set five different images:
|
|
113
113
|
:error
|
114
114
|
:progress
|
115
115
|
|
116
|
-
It works like this in combination with flash[:notice] and the
|
116
|
+
It works like this in combination with flash[:notice] and the `js` helper:
|
117
117
|
|
118
118
|
<%= js add_gritter(flash[:notice], :image => :notice, :title => "Pay attention!", :sticky => true) %>
|
119
119
|
|
@@ -130,7 +130,7 @@ It's great for all kinds of notifications, including the flash notifications you
|
|
130
130
|
|
131
131
|
### remove_gritter
|
132
132
|
|
133
|
-
The remove_gritter helper removes all gritter notifications from the screen. You can use it inside a js.erb file:
|
133
|
+
The `remove_gritter` helper removes all gritter notifications from the screen. You can use it inside a `js.erb` file:
|
134
134
|
|
135
135
|
<%= remove_gritter %>
|
136
136
|
|
@@ -139,20 +139,20 @@ You can pass two extra arguments to this helper.
|
|
139
139
|
:before_close => "alert('Closing!');" # => Execute javascript before closing.
|
140
140
|
:after_close => "alert('Closed!');" # => Execute javascript after closing.
|
141
141
|
|
142
|
-
You can also use the
|
142
|
+
You can also use the `js` helper to add script-tags around this helper.
|
143
143
|
|
144
144
|
|
145
145
|
### extend_gritter
|
146
146
|
|
147
|
-
The extend_gritter helper allows you to set the default gritter options, just like you can do with the include_gritter helpers.
|
148
|
-
To see what arguments you can pass to this helper just check the include_gritter helper.
|
147
|
+
The `extend_gritter` helper allows you to set the default gritter options, just like you can do with the `include_gritter` helpers.
|
148
|
+
To see what arguments you can pass to this helper just check the `include_gritter` helper.
|
149
149
|
|
150
|
-
You can also use the
|
150
|
+
You can also use the `js` helper to add script-tags around this helper.
|
151
151
|
|
152
152
|
|
153
153
|
### gflash
|
154
154
|
|
155
|
-
The gflash helper is a different kind of flash[:notice] message. It uses the add_gritter helper and the default images used in this plugin.
|
155
|
+
The `gflash` helper is a different kind of `flash[:notice]` message. It uses the `add_gritter` helper and the default images used in this plugin.
|
156
156
|
It uses a session to remember the flash messages. Add the following inside your controller action:
|
157
157
|
|
158
158
|
def create
|
@@ -164,7 +164,7 @@ Now you can add the following to your layout view inside the body-tag:
|
|
164
164
|
<%= gflash %>
|
165
165
|
|
166
166
|
The flash-message will be shown with 'success.png' as the image and 'Success' as the title.
|
167
|
-
To change the title you can add the following to the gflash helper inside the layout:
|
167
|
+
To change the title you can add the following to the `gflash` helper inside the layout:
|
168
168
|
|
169
169
|
<%= gflash :success => "It has been successful!" %>
|
170
170
|
|
@@ -183,7 +183,7 @@ Each uses the corresponding image and title. You can also add multiple gritter n
|
|
183
183
|
end
|
184
184
|
|
185
185
|
Besides passing the exact text inside the controller, gflash also supports locales (both for messages and titles).
|
186
|
-
When you start your server a new locale file will be added to /config/locales called
|
186
|
+
When you start your server a new locale file will be added to /config/locales called `gflash.en.yml`.
|
187
187
|
Here you can set the locales for all your gflash messages and the titles. It works like this:
|
188
188
|
|
189
189
|
en:
|
@@ -200,11 +200,15 @@ Here you can set the locales for all your gflash messages and the titles. It wor
|
|
200
200
|
|
201
201
|
Now you can do the following inside your Controller:
|
202
202
|
|
203
|
-
|
203
|
+
def create
|
204
204
|
gflash :notice => true
|
205
205
|
end
|
206
206
|
|
207
|
-
The locales for the
|
207
|
+
The locales for the `:notice` title and message will now be used. You can still pass a `String` to overwrite a locale.
|
208
|
+
|
209
|
+
You can also use gflash inside `js.erb` files:
|
210
|
+
|
211
|
+
<%= gflash :js => true %>
|
208
212
|
|
209
213
|
And that's how you add gflash to your Rails application.
|
210
214
|
Just remember that you can only set which gflash message you want shown inside the controller.
|
data/lib/gritter/helpers.rb
CHANGED
@@ -58,7 +58,7 @@ module Gritter
|
|
58
58
|
titles = gflash_titles(options)
|
59
59
|
flashes = session[:gflash].map { |key, value| add_gritter(value, :image => key, :title => titles[key]) }
|
60
60
|
session[:gflash] = nil
|
61
|
-
js(flashes).html_safe
|
61
|
+
options[:js] ? flashes : js(flashes).html_safe
|
62
62
|
end
|
63
63
|
end
|
64
64
|
|
data/lib/gritter/version.rb
CHANGED
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 6
|
8
|
-
-
|
9
|
-
version: 0.6.
|
8
|
+
- 1
|
9
|
+
version: 0.6.1
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Robin Brouwer
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-
|
18
|
+
date: 2011-05-01 00:00:00 +02:00
|
19
19
|
default_executable:
|
20
20
|
dependencies: []
|
21
21
|
|
@@ -31,7 +31,7 @@ extra_rdoc_files: []
|
|
31
31
|
files:
|
32
32
|
- .gitignore
|
33
33
|
- Gemfile
|
34
|
-
- README.
|
34
|
+
- README.md
|
35
35
|
- Rakefile
|
36
36
|
- gritter.gemspec
|
37
37
|
- init.rb
|