unobtrusive_flash 3.1.0 → 3.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (39) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +2 -1
  3. data/.travis.yml +15 -4
  4. data/Appraisals +25 -0
  5. data/CHANGELOG.md +10 -1
  6. data/README.markdown +56 -22
  7. data/Rakefile +6 -0
  8. data/gemfiles/rails_3.2.gemfile +8 -0
  9. data/gemfiles/rails_3.2.gemfile.lock +155 -0
  10. data/gemfiles/rails_4.0.gemfile +10 -0
  11. data/gemfiles/rails_4.0.gemfile.lock +153 -0
  12. data/gemfiles/rails_4.1.gemfile +10 -0
  13. data/gemfiles/rails_4.1.gemfile.lock +159 -0
  14. data/gemfiles/rails_4.2.gemfile +10 -0
  15. data/gemfiles/rails_4.2.gemfile.lock +181 -0
  16. data/lib/assets/javascripts/unobtrusive_flash.js +16 -10
  17. data/lib/assets/javascripts/unobtrusive_flash_bootstrap.js +6 -4
  18. data/lib/assets/javascripts/unobtrusive_flash_ui.js +8 -5
  19. data/lib/unobtrusive_flash/version.rb +1 -1
  20. data/spec/integration/api_spec.rb +12 -0
  21. data/spec/integration/bootstrap_spec.rb +23 -0
  22. data/spec/integration/turbolinks_spec.rb +23 -0
  23. data/spec/integration/ui_spec.rb +10 -0
  24. data/spec/spec_helper.rb +18 -1
  25. data/spec/support/assets/javascripts/ajax_caller.js +4 -0
  26. data/spec/support/assets/javascripts/api.js +12 -0
  27. data/spec/support/assets/javascripts/bootstrap.js +4 -0
  28. data/spec/support/assets/javascripts/jquery_turbolinks_application.js +5 -0
  29. data/spec/support/assets/javascripts/turbolinks_application.js +11 -0
  30. data/spec/support/assets/javascripts/ui.js +4 -0
  31. data/spec/support/rails_app.rb +57 -0
  32. data/spec/support/views/test/api.html.erb +8 -0
  33. data/spec/support/views/test/bootstrap.html.erb +9 -0
  34. data/spec/support/views/test/jquery_turbolinks.html.erb +10 -0
  35. data/spec/support/views/test/turbolinks.html.erb +9 -0
  36. data/spec/support/views/test/turbolinks_target.html.erb +3 -0
  37. data/spec/support/views/test/ui.html.erb +8 -0
  38. data/unobtrusive_flash.gemspec +8 -2
  39. metadata +106 -7
@@ -0,0 +1,10 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "rails", "~>4.1.13"
6
+ gem "jquery-rails", "~> 2.1"
7
+ gem "turbolinks"
8
+ gem "jquery-turbolinks", ">2"
9
+
10
+ gemspec :path => "../"
@@ -0,0 +1,159 @@
1
+ PATH
2
+ remote: ../
3
+ specs:
4
+ unobtrusive_flash (3.1.1)
5
+ railties
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ actionmailer (4.1.13)
11
+ actionpack (= 4.1.13)
12
+ actionview (= 4.1.13)
13
+ mail (~> 2.5, >= 2.5.4)
14
+ actionpack (4.1.13)
15
+ actionview (= 4.1.13)
16
+ activesupport (= 4.1.13)
17
+ rack (~> 1.5.2)
18
+ rack-test (~> 0.6.2)
19
+ actionview (4.1.13)
20
+ activesupport (= 4.1.13)
21
+ builder (~> 3.1)
22
+ erubis (~> 2.7.0)
23
+ activemodel (4.1.13)
24
+ activesupport (= 4.1.13)
25
+ builder (~> 3.1)
26
+ activerecord (4.1.13)
27
+ activemodel (= 4.1.13)
28
+ activesupport (= 4.1.13)
29
+ arel (~> 5.0.0)
30
+ activesupport (4.1.13)
31
+ i18n (~> 0.6, >= 0.6.9)
32
+ json (~> 1.7, >= 1.7.7)
33
+ minitest (~> 5.1)
34
+ thread_safe (~> 0.1)
35
+ tzinfo (~> 1.1)
36
+ appraisal (2.1.0)
37
+ bundler
38
+ rake
39
+ thor (>= 0.14.0)
40
+ arel (5.0.1.20140414130214)
41
+ builder (3.2.2)
42
+ capybara (2.5.0)
43
+ mime-types (>= 1.16)
44
+ nokogiri (>= 1.3.3)
45
+ rack (>= 1.0.0)
46
+ rack-test (>= 0.5.4)
47
+ xpath (~> 2.0)
48
+ childprocess (0.5.6)
49
+ ffi (~> 1.0, >= 1.0.11)
50
+ cliver (0.3.2)
51
+ coffee-rails (4.1.0)
52
+ coffee-script (>= 2.2.0)
53
+ railties (>= 4.0.0, < 5.0)
54
+ coffee-script (2.4.1)
55
+ coffee-script-source
56
+ execjs
57
+ coffee-script-source (1.9.1.1)
58
+ diff-lcs (1.2.5)
59
+ erubis (2.7.0)
60
+ execjs (2.6.0)
61
+ ffi (1.9.10)
62
+ i18n (0.7.0)
63
+ jquery-rails (2.3.0)
64
+ railties (>= 3.0, < 5.0)
65
+ thor (>= 0.14, < 2.0)
66
+ jquery-turbolinks (2.1.0)
67
+ railties (>= 3.1.0)
68
+ turbolinks
69
+ json (1.8.3)
70
+ mail (2.6.3)
71
+ mime-types (>= 1.16, < 3)
72
+ mime-types (2.6.2)
73
+ mini_portile (0.6.2)
74
+ minitest (5.8.2)
75
+ multi_json (1.11.2)
76
+ nokogiri (1.6.6.2)
77
+ mini_portile (~> 0.6.0)
78
+ poltergeist (1.7.0)
79
+ capybara (~> 2.1)
80
+ cliver (~> 0.3.1)
81
+ multi_json (~> 1.0)
82
+ websocket-driver (>= 0.2.0)
83
+ rack (1.5.5)
84
+ rack-test (0.6.3)
85
+ rack (>= 1.0)
86
+ rails (4.1.13)
87
+ actionmailer (= 4.1.13)
88
+ actionpack (= 4.1.13)
89
+ actionview (= 4.1.13)
90
+ activemodel (= 4.1.13)
91
+ activerecord (= 4.1.13)
92
+ activesupport (= 4.1.13)
93
+ bundler (>= 1.3.0, < 2.0)
94
+ railties (= 4.1.13)
95
+ sprockets-rails (~> 2.0)
96
+ railties (4.1.13)
97
+ actionpack (= 4.1.13)
98
+ activesupport (= 4.1.13)
99
+ rake (>= 0.8.7)
100
+ thor (>= 0.18.1, < 2.0)
101
+ rake (10.4.2)
102
+ rspec (3.3.0)
103
+ rspec-core (~> 3.3.0)
104
+ rspec-expectations (~> 3.3.0)
105
+ rspec-mocks (~> 3.3.0)
106
+ rspec-core (3.3.2)
107
+ rspec-support (~> 3.3.0)
108
+ rspec-expectations (3.3.1)
109
+ diff-lcs (>= 1.2.0, < 2.0)
110
+ rspec-support (~> 3.3.0)
111
+ rspec-mocks (3.3.2)
112
+ diff-lcs (>= 1.2.0, < 2.0)
113
+ rspec-support (~> 3.3.0)
114
+ rspec-support (3.3.0)
115
+ rubyzip (1.1.7)
116
+ selenium-webdriver (2.48.1)
117
+ childprocess (~> 0.5)
118
+ multi_json (~> 1.0)
119
+ rubyzip (~> 1.0)
120
+ websocket (~> 1.0)
121
+ sprockets (3.4.0)
122
+ rack (> 1, < 3)
123
+ sprockets-rails (2.3.3)
124
+ actionpack (>= 3.0)
125
+ activesupport (>= 3.0)
126
+ sprockets (>= 2.8, < 4.0)
127
+ thor (0.19.1)
128
+ thread_safe (0.3.5)
129
+ turbolinks (2.5.3)
130
+ coffee-rails
131
+ tzinfo (1.2.2)
132
+ thread_safe (~> 0.1)
133
+ websocket (1.2.2)
134
+ websocket-driver (0.6.2)
135
+ websocket-extensions (>= 0.1.0)
136
+ websocket-extensions (0.1.2)
137
+ xpath (2.0.0)
138
+ nokogiri (~> 1.3)
139
+
140
+ PLATFORMS
141
+ ruby
142
+
143
+ DEPENDENCIES
144
+ appraisal
145
+ bundler (~> 1.3)
146
+ capybara (>= 2.5)
147
+ jquery-rails (~> 2.1)
148
+ jquery-turbolinks (> 2)
149
+ poltergeist
150
+ rails (~> 4.1.13)
151
+ rake
152
+ rspec (~> 3)
153
+ rspec-mocks (~> 3)
154
+ selenium-webdriver
155
+ turbolinks
156
+ unobtrusive_flash!
157
+
158
+ BUNDLED WITH
159
+ 1.10.6
@@ -0,0 +1,10 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "rails", "~>4.2.4"
6
+ gem "jquery-rails", "~> 2.1"
7
+ gem "turbolinks"
8
+ gem "jquery-turbolinks", ">2"
9
+
10
+ gemspec :path => "../"
@@ -0,0 +1,181 @@
1
+ PATH
2
+ remote: ../
3
+ specs:
4
+ unobtrusive_flash (3.1.1)
5
+ railties
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ actionmailer (4.2.4)
11
+ actionpack (= 4.2.4)
12
+ actionview (= 4.2.4)
13
+ activejob (= 4.2.4)
14
+ mail (~> 2.5, >= 2.5.4)
15
+ rails-dom-testing (~> 1.0, >= 1.0.5)
16
+ actionpack (4.2.4)
17
+ actionview (= 4.2.4)
18
+ activesupport (= 4.2.4)
19
+ rack (~> 1.6)
20
+ rack-test (~> 0.6.2)
21
+ rails-dom-testing (~> 1.0, >= 1.0.5)
22
+ rails-html-sanitizer (~> 1.0, >= 1.0.2)
23
+ actionview (4.2.4)
24
+ activesupport (= 4.2.4)
25
+ builder (~> 3.1)
26
+ erubis (~> 2.7.0)
27
+ rails-dom-testing (~> 1.0, >= 1.0.5)
28
+ rails-html-sanitizer (~> 1.0, >= 1.0.2)
29
+ activejob (4.2.4)
30
+ activesupport (= 4.2.4)
31
+ globalid (>= 0.3.0)
32
+ activemodel (4.2.4)
33
+ activesupport (= 4.2.4)
34
+ builder (~> 3.1)
35
+ activerecord (4.2.4)
36
+ activemodel (= 4.2.4)
37
+ activesupport (= 4.2.4)
38
+ arel (~> 6.0)
39
+ activesupport (4.2.4)
40
+ i18n (~> 0.7)
41
+ json (~> 1.7, >= 1.7.7)
42
+ minitest (~> 5.1)
43
+ thread_safe (~> 0.3, >= 0.3.4)
44
+ tzinfo (~> 1.1)
45
+ appraisal (2.1.0)
46
+ bundler
47
+ rake
48
+ thor (>= 0.14.0)
49
+ arel (6.0.3)
50
+ builder (3.2.2)
51
+ capybara (2.5.0)
52
+ mime-types (>= 1.16)
53
+ nokogiri (>= 1.3.3)
54
+ rack (>= 1.0.0)
55
+ rack-test (>= 0.5.4)
56
+ xpath (~> 2.0)
57
+ childprocess (0.5.6)
58
+ ffi (~> 1.0, >= 1.0.11)
59
+ cliver (0.3.2)
60
+ coffee-rails (4.1.0)
61
+ coffee-script (>= 2.2.0)
62
+ railties (>= 4.0.0, < 5.0)
63
+ coffee-script (2.4.1)
64
+ coffee-script-source
65
+ execjs
66
+ coffee-script-source (1.9.1.1)
67
+ diff-lcs (1.2.5)
68
+ erubis (2.7.0)
69
+ execjs (2.6.0)
70
+ ffi (1.9.10)
71
+ globalid (0.3.6)
72
+ activesupport (>= 4.1.0)
73
+ i18n (0.7.0)
74
+ jquery-rails (2.3.0)
75
+ railties (>= 3.0, < 5.0)
76
+ thor (>= 0.14, < 2.0)
77
+ jquery-turbolinks (2.1.0)
78
+ railties (>= 3.1.0)
79
+ turbolinks
80
+ json (1.8.3)
81
+ loofah (2.0.3)
82
+ nokogiri (>= 1.5.9)
83
+ mail (2.6.3)
84
+ mime-types (>= 1.16, < 3)
85
+ mime-types (2.6.2)
86
+ mini_portile (0.6.2)
87
+ minitest (5.8.2)
88
+ multi_json (1.11.2)
89
+ nokogiri (1.6.6.2)
90
+ mini_portile (~> 0.6.0)
91
+ poltergeist (1.7.0)
92
+ capybara (~> 2.1)
93
+ cliver (~> 0.3.1)
94
+ multi_json (~> 1.0)
95
+ websocket-driver (>= 0.2.0)
96
+ rack (1.6.4)
97
+ rack-test (0.6.3)
98
+ rack (>= 1.0)
99
+ rails (4.2.4)
100
+ actionmailer (= 4.2.4)
101
+ actionpack (= 4.2.4)
102
+ actionview (= 4.2.4)
103
+ activejob (= 4.2.4)
104
+ activemodel (= 4.2.4)
105
+ activerecord (= 4.2.4)
106
+ activesupport (= 4.2.4)
107
+ bundler (>= 1.3.0, < 2.0)
108
+ railties (= 4.2.4)
109
+ sprockets-rails
110
+ rails-deprecated_sanitizer (1.0.3)
111
+ activesupport (>= 4.2.0.alpha)
112
+ rails-dom-testing (1.0.7)
113
+ activesupport (>= 4.2.0.beta, < 5.0)
114
+ nokogiri (~> 1.6.0)
115
+ rails-deprecated_sanitizer (>= 1.0.1)
116
+ rails-html-sanitizer (1.0.2)
117
+ loofah (~> 2.0)
118
+ railties (4.2.4)
119
+ actionpack (= 4.2.4)
120
+ activesupport (= 4.2.4)
121
+ rake (>= 0.8.7)
122
+ thor (>= 0.18.1, < 2.0)
123
+ rake (10.4.2)
124
+ rspec (3.3.0)
125
+ rspec-core (~> 3.3.0)
126
+ rspec-expectations (~> 3.3.0)
127
+ rspec-mocks (~> 3.3.0)
128
+ rspec-core (3.3.2)
129
+ rspec-support (~> 3.3.0)
130
+ rspec-expectations (3.3.1)
131
+ diff-lcs (>= 1.2.0, < 2.0)
132
+ rspec-support (~> 3.3.0)
133
+ rspec-mocks (3.3.2)
134
+ diff-lcs (>= 1.2.0, < 2.0)
135
+ rspec-support (~> 3.3.0)
136
+ rspec-support (3.3.0)
137
+ rubyzip (1.1.7)
138
+ selenium-webdriver (2.48.1)
139
+ childprocess (~> 0.5)
140
+ multi_json (~> 1.0)
141
+ rubyzip (~> 1.0)
142
+ websocket (~> 1.0)
143
+ sprockets (3.4.0)
144
+ rack (> 1, < 3)
145
+ sprockets-rails (2.3.3)
146
+ actionpack (>= 3.0)
147
+ activesupport (>= 3.0)
148
+ sprockets (>= 2.8, < 4.0)
149
+ thor (0.19.1)
150
+ thread_safe (0.3.5)
151
+ turbolinks (2.5.3)
152
+ coffee-rails
153
+ tzinfo (1.2.2)
154
+ thread_safe (~> 0.1)
155
+ websocket (1.2.2)
156
+ websocket-driver (0.6.2)
157
+ websocket-extensions (>= 0.1.0)
158
+ websocket-extensions (0.1.2)
159
+ xpath (2.0.0)
160
+ nokogiri (~> 1.3)
161
+
162
+ PLATFORMS
163
+ ruby
164
+
165
+ DEPENDENCIES
166
+ appraisal
167
+ bundler (~> 1.3)
168
+ capybara (>= 2.5)
169
+ jquery-rails (~> 2.1)
170
+ jquery-turbolinks (> 2)
171
+ poltergeist
172
+ rails (~> 4.2.4)
173
+ rake
174
+ rspec (~> 3)
175
+ rspec-mocks (~> 3)
176
+ selenium-webdriver
177
+ turbolinks
178
+ unobtrusive_flash!
179
+
180
+ BUNDLED WITH
181
+ 1.10.6
@@ -1,6 +1,6 @@
1
- window.UnobtrusiveFlash = {}
1
+ window.UnobtrusiveFlash = {};
2
2
 
3
- $(function() {
3
+ (function() {
4
4
  // Delete the cookie regardless of the domain it was set from
5
5
  // Partial credit to http://stackoverflow.com/a/2959110/6678
6
6
  function nukeCookie(cookieName) {
@@ -12,7 +12,7 @@ $(function() {
12
12
  expireHost = part + '.' + expireHost;
13
13
  document.cookie = cookieName+'=; path=/;expires='+yesterday+'; domain='+expireHost;
14
14
  });
15
- document.cookie = cookieName+'=; path=/';expires=+yesterday+'; domain=';
15
+ document.cookie = cookieName+'=; path=/;expires='+yesterday+'; domain=';
16
16
  }
17
17
 
18
18
  // Extracts flash array stored in cookie and clears the cookie
@@ -43,23 +43,29 @@ $(function() {
43
43
  return data;
44
44
  }
45
45
 
46
- // Reads flash messages from cookies and fires corresponding events
47
- window.UnobtrusiveFlash['showFlashFromCookies'] = function() {
48
- var flashMessages = extractFlashFromCookies();
46
+ window.UnobtrusiveFlash.showFlash = function(flashMessages) {
49
47
  if (flashMessages !== null) {
50
48
  $.each(flashMessages, function(_, flashMessage) {
51
49
  $(window).trigger('rails:flash', {type: flashMessage[0], message: flashMessage[1]});
52
50
  });
53
51
  }
54
- }
52
+ };
55
53
 
54
+ // Reads flash messages from cookies and fires corresponding events
55
+ window.UnobtrusiveFlash.showFlashFromCookies = function() {
56
+ UnobtrusiveFlash.showFlash(extractFlashFromCookies());
57
+ };
58
+
59
+ // We want to remove cookies from the flash as soon as possible, but we only want to show then after all the scripts have loaded,
60
+ // including any flash handlers
61
+ var pageCookies = extractFlashFromCookies();
56
62
  $(window).load(function() {
57
- UnobtrusiveFlash.showFlashFromCookies();
63
+ UnobtrusiveFlash.showFlash(pageCookies);
58
64
  });
59
65
 
60
66
  $(document).on('page:change page:load', UnobtrusiveFlash.showFlashFromCookies);
61
67
 
62
- $(document).ajaxSuccess(function(event,request,options) {
68
+ $(document).ajaxComplete(function(event,request,options) {
63
69
  UnobtrusiveFlash.showFlashFromCookies();
64
70
  });
65
- });
71
+ })();
@@ -6,7 +6,8 @@
6
6
 
7
7
  window.UnobtrusiveFlash.flashOptions = {type: 'notice', timeout: 0};
8
8
 
9
- $(function() {
9
+ (function() {
10
+
10
11
  UnobtrusiveFlash.showFlashMessage = function(message, options) {
11
12
  options = $.extend(UnobtrusiveFlash.flashOptions, options);
12
13
 
@@ -19,7 +20,7 @@ $(function() {
19
20
  options.type = 'danger';
20
21
  }
21
22
 
22
- var $flash = $('<div class="alert alert-'+options.type+'"><button type="button" class="close" data-dismiss="alert">&times;</button>'+message+'</div>');
23
+ var $flash = $('<div class="alert alert-'+options.type+' fade in"><button type="button" class="close" data-dismiss="alert">&times;</button>'+message+'</div>');
23
24
 
24
25
  var $flashContainer = $($('.unobtrusive-flash-container')[0] || $('.container')[0] || $('.container-fluid')[0] || $('body')[0]);
25
26
  $flashContainer.prepend($flash);
@@ -35,9 +36,10 @@ $(function() {
35
36
  }
36
37
  };
37
38
 
38
- flashHandler = function(e, params) {
39
+ var flashHandler = function(e, params) {
39
40
  UnobtrusiveFlash.showFlashMessage(params.message, {type: params.type});
40
41
  };
41
42
 
42
43
  $(window).bind('rails:flash', flashHandler);
43
- });
44
+
45
+ })();