gritter 0.6.2 → 0.6.3

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
  # gritter
2
2
 
3
- version 0.6.2
3
+ version 0.6.3
4
4
  Robin Brouwer
5
5
  Daniël Zwijnenburg
6
6
  45north
@@ -23,14 +23,14 @@ This is a Rails 3 gem. When you're using Rails 2 you should use version 0.3 (thi
23
23
 
24
24
  ## Rails 3.1 installation
25
25
 
26
- Gritter now also supports Rails 3.1, thanks to [finist](https://github.com/finist]).
27
- Adding the JavaScript en CSS files is accomplished in a different way, because of the new 'assets' folder inside /app.
26
+ Gritter now also supports Rails 3.1, thanks to [finist](https://github.com/finist).
27
+ Adding the JavaScript and CSS files is accomplished in a different way, because of the new 'assets' folder inside /app.
28
28
 
29
- Add the following to /app/assets/javascripts/application.js:
29
+ Add the following to `/app/assets/javascripts/application.js`:
30
30
 
31
31
  //= require gritter
32
32
 
33
- And the following to /app/assets/stylesheets/application.css:
33
+ And the following to `/app/assets/stylesheets/application.css`:
34
34
 
35
35
  *= require gritter
36
36
 
@@ -67,6 +67,11 @@ You should really check out the gflash helper. It's really handy!
67
67
 
68
68
  ## Changes
69
69
 
70
+ Version 0.6.3 changes:
71
+
72
+ - Calling gflash multiple times won't override older messages.
73
+ - You can set the time, sticky and class_name per gflash message.
74
+
70
75
  Version 0.6.2 changes:
71
76
 
72
77
  - Reduced the size of all images;
@@ -237,6 +242,12 @@ Just remember that you can only set which gflash message you want shown inside t
237
242
  The gflash helper inside the views will show the notification and change the title when you pass extra arguments.
238
243
  It will not change the message.
239
244
 
245
+ Since 0.6.3 you can change the default time, sticky and class_name options for each gflash message.
246
+ This is done inside the Controller and works like this:
247
+
248
+ gflash :success => { :value => true, :time => 2000, :class_name => "my_class", :sticky => true }
249
+ gflash :error => { :value => "Custom error", :time => 3000, :class_name => "my_error_class", :sticky => false }
250
+
240
251
 
241
252
  ## Special Thanks
242
253
 
@@ -4,8 +4,25 @@ module Gritter
4
4
  session[:gflash] ||= {}
5
5
  options = args.extract_options!
6
6
  options.each do |key, value|
7
- session[:gflash][key] = value == true ? I18n.t("gflash.#{params[:controller]}.#{params[:action]}.#{key}") : value
7
+ if value.is_a?(Hash)
8
+ gflash_value = value
9
+ gflash_value[:value] = gflash_text(key, gflash_value[:value]) if gflash_value.has_key?(:value)
10
+ else
11
+ gflash_value = gflash_text(key, value)
12
+ end
13
+
14
+ if session[:gflash].has_key?(key)
15
+ session[:gflash][key].push(gflash_value)
16
+ else
17
+ session[:gflash][key] = [gflash_value]
18
+ end
8
19
  end
9
20
  end
21
+
22
+ private
23
+
24
+ def gflash_text(key, value)
25
+ value == true ? I18n.t("gflash.#{params[:controller]}.#{params[:action]}.#{key}") : value
26
+ end
10
27
  end
11
28
  end
@@ -16,7 +16,7 @@ module Gritter
16
16
  options = args.extract_options!
17
17
  options[:title] = "Notification" if options[:title].blank?
18
18
  options[:image] = ::Rails.version < "3.1" ? "/images/gritter/#{options[:image]}.png" : asset_path("#{options[:image]}.png") if %w(success warning error notice progress).include?(options[:image].to_s)
19
- notification = ["$.gritter.add({"]
19
+ notification = ["jQuery.gritter.add({"]
20
20
  notification.push("image:'#{options[:image]}',") if options[:image].present?
21
21
  notification.push("sticky:#{options[:sticky]},") if options[:sticky].present?
22
22
  notification.push("time:#{options[:time]},") if options[:time].present?
@@ -33,7 +33,7 @@ module Gritter
33
33
 
34
34
  def remove_gritter *args
35
35
  options = args.extract_options!
36
- removed = ["$.gritter.removeAll({"]
36
+ removed = ["jQuery.gritter.removeAll({"]
37
37
  removed.push("before_close:function(e){#{options[:before_close]}},") if options[:before_close].present?
38
38
  removed.push("after_close:function(e){#{options[:after_close]}},") if options[:after_close].present?
39
39
  removed.push("});")
@@ -44,7 +44,7 @@ module Gritter
44
44
  options = args.extract_options!
45
45
  options[:fade_in_speed] = "'#{options[:fade_in_speed]}'" if options[:fade_in_speed].is_a?(String)
46
46
  options[:fade_out_speed] = "'#{options[:fade_out_speed]}'" if options[:fade_out_speed].is_a?(String)
47
- extended = ["$.extend($.gritter.options,{"]
47
+ extended = ["jQuery.extend($.gritter.options,{"]
48
48
  extended.push("fade_in_speed:#{options[:fade_in_speed]},") if options[:fade_in_speed].present?
49
49
  extended.push("fade_out_speed:#{options[:fade_out_speed]},") if options[:fade_out_speed].present?
50
50
  extended.push("time:#{options[:time]}") if options[:time].present?
@@ -56,7 +56,20 @@ module Gritter
56
56
  if session[:gflash].present?
57
57
  options = args.extract_options!
58
58
  titles = gflash_titles(options)
59
- flashes = session[:gflash].map { |key, value| add_gritter(value, :image => key, :title => titles[key]) }
59
+ flashes = []
60
+ session[:gflash].each do |key, value|
61
+ value.each do |gflash_value|
62
+ gritter_options = { :image => key, :title => titles[key] }
63
+ if gflash_value.is_a?(Hash)
64
+ text = gflash_value.has_key?(:value) ? (gflash_value[:value] and gflash_value.delete(:value)) : nil
65
+ gritter_options.merge!(gflash_value)
66
+ else
67
+ text = gflash_value
68
+ end
69
+
70
+ flashes.push(add_gritter(text, gritter_options))
71
+ end
72
+ end
60
73
  session[:gflash] = nil
61
74
  options[:js] ? flashes : js(flashes).html_safe
62
75
  end
@@ -68,6 +81,10 @@ module Gritter
68
81
 
69
82
  private
70
83
 
84
+ def gflash_text(value)
85
+ value == true ? I18n.t("gflash.#{params[:controller]}.#{params[:action]}.#{key}") : value
86
+ end
87
+
71
88
  def gflash_titles *args
72
89
  options = args.extract_options!
73
90
  titles = { :success => get_translation(:success), :warning => get_translation(:warning), :error => get_translation(:error), :notice => get_translation(:notice), :progress => get_translation(:progress) }
@@ -81,4 +98,4 @@ module Gritter
81
98
  I18n.t(translation, :scope => [:gflash, :titles])
82
99
  end
83
100
  end
84
- end
101
+ end
@@ -1,3 +1,3 @@
1
1
  module Gritter
2
- VERSION = "0.6.2"
2
+ VERSION = "0.6.3"
3
3
  end
metadata CHANGED
@@ -1,12 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gritter
3
3
  version: !ruby/object:Gem::Version
4
+ hash: 1
4
5
  prerelease: false
5
6
  segments:
6
7
  - 0
7
8
  - 6
8
- - 2
9
- version: 0.6.2
9
+ - 3
10
+ version: 0.6.3
10
11
  platform: ruby
11
12
  authors:
12
13
  - Robin Brouwer
@@ -15,7 +16,7 @@ autorequire:
15
16
  bindir: bin
16
17
  cert_chain: []
17
18
 
18
- date: 2011-08-30 00:00:00 +02:00
19
+ date: 2011-11-16 00:00:00 +01:00
19
20
  default_executable:
20
21
  dependencies: []
21
22
 
@@ -73,23 +74,27 @@ rdoc_options: []
73
74
  require_paths:
74
75
  - lib
75
76
  required_ruby_version: !ruby/object:Gem::Requirement
77
+ none: false
76
78
  requirements:
77
79
  - - ">="
78
80
  - !ruby/object:Gem::Version
81
+ hash: 3
79
82
  segments:
80
83
  - 0
81
84
  version: "0"
82
85
  required_rubygems_version: !ruby/object:Gem::Requirement
86
+ none: false
83
87
  requirements:
84
88
  - - ">="
85
89
  - !ruby/object:Gem::Version
90
+ hash: 3
86
91
  segments:
87
92
  - 0
88
93
  version: "0"
89
94
  requirements: []
90
95
 
91
96
  rubyforge_project: nowarning
92
- rubygems_version: 1.3.6
97
+ rubygems_version: 1.3.7
93
98
  signing_key:
94
99
  specification_version: 3
95
100
  summary: Growl notifications for your Rails application.