toastrjs-rails 2.1.3.1 → 2.1.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/README.md +32 -12
- data/lib/toastrjs/rails/helper.rb +4 -1
- data/lib/toastrjs/rails/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: bbf89f44bf7ae01b4d712316e1480cd5713c536f7b3abdc3b971e6ed3db3072a
|
4
|
+
data.tar.gz: 636dc900b721286441fe754e6aa2817ebec996d6ba42019880b7e38997138940
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 76d6eb9685b4a391ebc74b935d4ae43b0312e04175b9fdc7509002d1c23d10bcd295bee8deb12fa243a60edab4b03247ed2b1075a2810873800f884c9a9af6fe
|
7
|
+
data.tar.gz: fe14b17f69f2909e8a04c8c4c9ce330ac3471e0f56d4bc624868ebd2d6fc6ae256eb7bf0ea300af4b5f966963aa3207f0429d2656ee2403f9b22ac28ce6fdc89
|
data/README.md
CHANGED
@@ -1,36 +1,56 @@
|
|
1
|
-
#
|
1
|
+
# toastrjs-rails
|
2
|
+
|
2
3
|
**toastr** is a Javascript library for Gnome / Growl type non-blocking notifications. jQuery is required. The goal is to create a simple core library that can be customized and extended.
|
3
4
|
|
5
|
+
This gem is wrapped for Rails asset-pipeline
|
6
|
+
|
4
7
|
## Current Version
|
5
|
-
2.1.3
|
8
|
+
2.1.3.2
|
6
9
|
|
10
|
+
> **Note** : This version is compatible for toastr version 2.1.3
|
7
11
|
|
8
12
|
## Demo
|
9
13
|
Demo can be found at http://CodeSeven.github.com/toastr
|
10
14
|
|
11
|
-
##
|
12
|
-
|
13
|
-
### 3 Easy Steps
|
15
|
+
## 3 Easy Steps
|
14
16
|
For other API calls, see the [demo](http://CodeSeven.github.com/toastr).
|
15
17
|
|
16
18
|
1. update gemfile: gem 'toastrjs-rails'
|
17
19
|
|
18
|
-
2. Add toastr to application.css
|
20
|
+
2. Add toastr.min to application.css:
|
19
21
|
|
20
|
-
|
22
|
+
*= require toastr.min
|
23
|
+
|
24
|
+
or to application.scss:
|
25
|
+
|
26
|
+
@import "toastr.min";
|
21
27
|
|
22
|
-
|
28
|
+
3. Add toastr.min to application.js:
|
23
29
|
|
24
|
-
|
30
|
+
//= require toastr.min
|
25
31
|
|
26
|
-
// Display an info toast with no title
|
27
|
-
toastr.info('Are you the 6 fingered man?')
|
28
32
|
|
29
33
|
4. You can insert the following helper method in the view template where the flash messages are shown:
|
30
34
|
|
31
35
|
<%= flash_toastr %>
|
32
36
|
|
33
|
-
|
37
|
+
and this erb code is rendered as follows:
|
38
|
+
|
39
|
+
<script>
|
40
|
+
if (!(document.documentElement.hasAttribute(\"data-turbolinks-preview\"))) {
|
41
|
+
toastr.#{type}('#{message}', '', { 'closeButton': true });
|
42
|
+
}
|
43
|
+
</script>
|
44
|
+
|
45
|
+
> **Note**: `if` confition is for preventing the twice firing of javascript code in body tag due to Turbolinks 5
|
46
|
+
|
47
|
+
5. Use toastr to display a toast for info, success, warning or error in javascript file:
|
48
|
+
|
49
|
+
// Display an info toast with no title
|
50
|
+
toastr.info('Are you the 6 fingered man?')
|
51
|
+
|
52
|
+
|
53
|
+
### Other Options in javascript file
|
34
54
|
|
35
55
|
// Display a warning toast, with no title
|
36
56
|
toastr.warning('My name is Inigo Montoya. You Killed my father, prepare to die!')
|
@@ -6,7 +6,10 @@ module Toastrjs
|
|
6
6
|
flash.each do |type, message|
|
7
7
|
type = 'success' if type == 'notice'
|
8
8
|
type = 'error' if type == 'alert'
|
9
|
-
text = "<script>
|
9
|
+
text = "<script>"
|
10
|
+
text += "if (!(document.documentElement.hasAttribute(\"data-turbolinks-preview\"))) {"
|
11
|
+
text += "toastr.#{type}('#{message}','',{ 'closeButton': true });"
|
12
|
+
text += "}</script>"
|
10
13
|
flash_messages << text.html_safe if message
|
11
14
|
end
|
12
15
|
flash_messages.join("\n").html_safe
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: toastrjs-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.1.3.
|
4
|
+
version: 2.1.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lucius Choi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-08-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -75,7 +75,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
75
75
|
version: '0'
|
76
76
|
requirements: []
|
77
77
|
rubyforge_project:
|
78
|
-
rubygems_version: 2.
|
78
|
+
rubygems_version: 2.7.6
|
79
79
|
signing_key:
|
80
80
|
specification_version: 4
|
81
81
|
summary: A Javascript library for non-blocking notifications
|