ohsnap-rails 0.2.0 → 0.3.0
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.
- checksums.yaml +4 -4
- data/README.md +32 -1
- data/lib/ohsnap/rails/version.rb +1 -1
- data/vendor/assets/{javasccripts → javascripts}/ohsnap.js +0 -0
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 9a74e03400da2d89b6efd8bbaf6cc83fe13e74fe
|
|
4
|
+
data.tar.gz: 298d7c9277385c7bf60805e3546978203e2de0a2
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: cc6bad1c6f3e4fbf9bf0aa5d1867978f05708cd74e9cd901907e1d447886627750c09a41c3ea2e41a53fe457451d0e6dc62e2147d0020985edc4ed54f42d2566
|
|
7
|
+
data.tar.gz: 65d835846ec7cf39e97f784c6a17f66bcba1cac088fdfeb88dae7807b7bc301c87e447d2dbe6f5a1e55e193a15e19c7412a33ab45646a8cc73d88af069e4f48e
|
data/README.md
CHANGED
|
@@ -32,11 +32,42 @@ To your ```application.js``` file, add:
|
|
|
32
32
|
//= require ohsnap
|
|
33
33
|
```
|
|
34
34
|
|
|
35
|
-
In your
|
|
35
|
+
In your application helper app/helpers/application_helper.rb add:
|
|
36
|
+
|
|
37
|
+
```Ruby
|
|
38
|
+
module ApplicationHelper
|
|
39
|
+
ALERT_TYPES = [:blue, :green, :orange, :red] unless const_defined?(:ALERT_TYPES)
|
|
40
|
+
def snap_flash(options = {})
|
|
41
|
+
flash_messages = []
|
|
42
|
+
flash.each do |type, message|
|
|
43
|
+
next if message.blank?
|
|
44
|
+
|
|
45
|
+
type = type.to_sym
|
|
46
|
+
type = :blue if type == :info
|
|
47
|
+
type = :green if type == :notice
|
|
48
|
+
type = :orange if type == :alert
|
|
49
|
+
type = :red if type == :error
|
|
50
|
+
|
|
51
|
+
next unless ALERT_TYPES.include?(type)
|
|
52
|
+
Array(message).each do |msg|
|
|
53
|
+
flash_messages << "ohSnap('#{msg}', {color: '#{type.to_s}', duration: '7000'});" if msg
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
javascript_tag flash_messages.join("\n").html_safe
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
In your application.html file here app/views/layout/application.html.erb add:
|
|
62
|
+
|
|
36
63
|
```HTML
|
|
37
64
|
<div id="ohsnap"></div>
|
|
65
|
+
<%= snap_flash %>
|
|
38
66
|
```
|
|
39
67
|
|
|
68
|
+
Credits to [Dmytro Koval](https://github.com/dawidof) for making pointing out a typo and for the application_helper.
|
|
69
|
+
|
|
70
|
+
|
|
40
71
|
Ohsnap created div with classes .alert .alert-color .So you would need to have:
|
|
41
72
|
|
|
42
73
|
```CSS
|
data/lib/ohsnap/rails/version.rb
CHANGED
|
File without changes
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: ohsnap-rails
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.3.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Rahul Lakhaney
|
|
@@ -59,7 +59,7 @@ files:
|
|
|
59
59
|
- lib/ohsnap/rails/version.rb
|
|
60
60
|
- ohsnap-rails.gemspec
|
|
61
61
|
- ohsnap.png
|
|
62
|
-
- vendor/assets/
|
|
62
|
+
- vendor/assets/javascripts/ohsnap.js
|
|
63
63
|
homepage: https://github.com/rahullakhaney/ohsnap-rails
|
|
64
64
|
licenses:
|
|
65
65
|
- MIT
|