growlyflash 0.9.2 → 0.10.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +10 -0
- data/app/assets/javascripts/growlyflash/listener.coffee +8 -4
- data/lib/growlyflash/controller_additions.rb +11 -1
- data/lib/growlyflash/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 31ac0731d739e0bf94072acae27ec1e8a284eb9c
|
4
|
+
data.tar.gz: fb39aca149ec6badd0ae036d63243aedd9b4a414
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 666ae9b2d564eb68b4b862ae49e530325197cea43847ab0c02b9e601a37553f98cd01fba471d79d9d9db02ee1d8c87570e54956b52e9e295d9bab99451507a05
|
7
|
+
data.tar.gz: 0a0972863b3488223eec14afa49acfe546524ea3d118acb8f073a0eb24dc0b5dac1d392160132fca7e32dd9d24ea7c34f7ee2391a4978cfda450ab6edfb00879
|
data/README.md
CHANGED
@@ -53,6 +53,16 @@ To make notifications also available with non-XHR requests, insert the following
|
|
53
53
|
<%= growlyflash_static_notices %>
|
54
54
|
```
|
55
55
|
|
56
|
+
If you want your website to be compliant with Content-Security-Policy, and
|
57
|
+
especially avoid `script-src: 'unsafe-inline'`, you can use another helper to
|
58
|
+
render an html tag with data attributes instead of injecting javascript code
|
59
|
+
into your page:
|
60
|
+
|
61
|
+
```erb
|
62
|
+
<%= growlyflash_tag %>
|
63
|
+
```
|
64
|
+
|
65
|
+
|
56
66
|
## Customize
|
57
67
|
|
58
68
|
If you want to change default options, you can override them somewhere in your coffee/js:
|
@@ -31,16 +31,20 @@ class Listener
|
|
31
31
|
|
32
32
|
constructor: (context) ->
|
33
33
|
@stack ?= new Stack()
|
34
|
-
@process_static()
|
34
|
+
@process_static(context)
|
35
35
|
($ context).on Growlyflash.Listener.EVENTS, (event, xhr) =>
|
36
36
|
if xhr ?= event.data?.xhr
|
37
37
|
source = process_from_header(xhr.getResponseHeader(Growlyflash.Listener.HEADER))
|
38
38
|
@stack.push_only_fresh source
|
39
39
|
return
|
40
40
|
|
41
|
-
process_static: ->
|
42
|
-
|
43
|
-
|
41
|
+
process_static: (context)->
|
42
|
+
if tag = context.getElementById('growlyflash-tag')
|
43
|
+
tag_flashes = JSON.parse(tag.getAttribute('data-flashes'))
|
44
|
+
@stack.push alert for alert in process(tag_flashes)
|
45
|
+
else if window.flashes?
|
46
|
+
@stack.push alert for alert in process(window.flashes)
|
47
|
+
delete window.flashes
|
44
48
|
|
45
49
|
@Growlyflash.Listener = Listener
|
46
50
|
@Growlyflash.listen_on = (context) ->
|
@@ -4,7 +4,7 @@ module Growlyflash
|
|
4
4
|
base.module_eval do
|
5
5
|
extend ClassMethods
|
6
6
|
if respond_to?(:helper_method)
|
7
|
-
helper_method :growlyflash_static_notices, :growlyhash
|
7
|
+
helper_method :growlyflash_static_notices, :growlyhash, :growlyflash_tag
|
8
8
|
end
|
9
9
|
end
|
10
10
|
end
|
@@ -38,6 +38,16 @@ module Growlyflash
|
|
38
38
|
view_context.javascript_tag(script, defer: 'defer')
|
39
39
|
end
|
40
40
|
|
41
|
+
# View helper which render a tag with flashes messages in data attribute.
|
42
|
+
def growlyflash_tag
|
43
|
+
return if flash.empty?
|
44
|
+
view_context.tag(
|
45
|
+
:div,
|
46
|
+
id: 'growlyflash-tag',
|
47
|
+
'data-flashes': growlyhash.to_json.html_safe
|
48
|
+
)
|
49
|
+
end
|
50
|
+
|
41
51
|
# Hash with available growl flash messages which contains a string object.
|
42
52
|
def growlyhash(force = false)
|
43
53
|
@growlyhash = nil if force
|
data/lib/growlyflash/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: growlyflash
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.10.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tõnis Simo
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-09-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: railties
|
@@ -117,7 +117,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
117
117
|
version: '0'
|
118
118
|
requirements: []
|
119
119
|
rubyforge_project:
|
120
|
-
rubygems_version: 2.6.
|
120
|
+
rubygems_version: 2.6.13
|
121
121
|
signing_key:
|
122
122
|
specification_version: 4
|
123
123
|
summary: Popup ActionDispatch::Flash within Bootstrap alert in Rails app like a growl
|