toastr-rails 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,166 @@
1
+ // By: Hans Fj�llemark and John Papa
2
+ // https://github.com/CodeSeven/toastr
3
+ //
4
+ // Modified to support css styling instead of inline styling
5
+ // Inspired by https://github.com/Srirangan/notifer.js/
6
+
7
+ ;(function(window, $) {
8
+ window.toastr = (function() {
9
+ var
10
+ defaults = {
11
+ tapToDismiss: true,
12
+ toastClass: 'toast',
13
+ containerId: 'toast-container',
14
+ debug: false,
15
+ fadeIn: 300,
16
+ fadeOut: 1000,
17
+ extendedTimeOut: 1000,
18
+ iconClasses: {
19
+ error: 'toast-error',
20
+ info: 'toast-info',
21
+ success: 'toast-success',
22
+ warning: 'toast-warning'
23
+ },
24
+ iconClass: 'toast-info',
25
+ positionClass: 'toast-top-right',
26
+ timeOut: 5000, // Set timeOut to 0 to make it sticky
27
+ titleClass: 'toast-title',
28
+ messageClass: 'toast-message'
29
+ },
30
+
31
+
32
+ error = function(message, title) {
33
+ return notify({
34
+ iconClass: getOptions().iconClasses.error,
35
+ message: message,
36
+ title: title
37
+ })
38
+ },
39
+
40
+ getContainer = function(options) {
41
+ var $container = $('#' + options.containerId)
42
+
43
+ if ($container.length)
44
+ return $container
45
+
46
+ $container = $('<div/>')
47
+ .attr('id', options.containerId)
48
+ .addClass(options.positionClass)
49
+
50
+ $container.appendTo($('body'))
51
+
52
+ return $container
53
+ },
54
+
55
+ getOptions = function() {
56
+ return $.extend({}, defaults, toastr.options)
57
+ },
58
+
59
+ info = function(message, title) {
60
+ return notify({
61
+ iconClass: getOptions().iconClasses.info,
62
+ message: message,
63
+ title: title
64
+ })
65
+ },
66
+
67
+ notify = function(map) {
68
+ var
69
+ options = getOptions(),
70
+ iconClass = map.iconClass || options.iconClass,
71
+ intervalId = null,
72
+ $container = getContainer(options),
73
+ $toastElement = $('<div/>'),
74
+ $titleElement = $('<div/>'),
75
+ $messageElement = $('<div/>'),
76
+ response = { options: options, map: map }
77
+
78
+ if (map.iconClass) {
79
+ $toastElement.addClass(options.toastClass).addClass(iconClass)
80
+ }
81
+
82
+ if (map.title) {
83
+ $titleElement.append(map.title).addClass(options.titleClass)
84
+ $toastElement.append($titleElement)
85
+ }
86
+
87
+ if (map.message) {
88
+ $messageElement.append(map.message).addClass(options.messageClass)
89
+ $toastElement.append($messageElement)
90
+ }
91
+
92
+ var fadeAway = function() {
93
+ if ($(':focus', $toastElement).length > 0)
94
+ return
95
+
96
+ var fade = function() {
97
+ return $toastElement.fadeOut(options.fadeOut)
98
+ }
99
+
100
+ $.when(fade()).done(function() {
101
+ if ($toastElement.is(':visible')) {
102
+ return
103
+ }
104
+ $toastElement.remove()
105
+ if ($container.children().length === 0)
106
+ $container.remove()
107
+ })
108
+ }
109
+
110
+ var delayedFadeAway = function() {
111
+ if (options.timeOut > 0 || options.extendedTimeOut > 0) {
112
+ intervalId = setTimeout(fadeAway, options.extendedTimeOut)
113
+ }
114
+ }
115
+
116
+ var stickAround = function() {
117
+ clearTimeout(intervalId)
118
+ $toastElement.stop(true, true)
119
+ .fadeIn(options.fadeIn)
120
+ }
121
+
122
+ $toastElement.hide()
123
+ $container.prepend($toastElement)
124
+ $toastElement.fadeIn(options.fadeIn)
125
+
126
+ if (options.timeOut > 0) {
127
+ intervalId = setTimeout(fadeAway, options.timeOut)
128
+ }
129
+
130
+ $toastElement.hover(stickAround, delayedFadeAway)
131
+
132
+ if (options.tapToDismiss) {
133
+ $toastElement.click(fadeAway)
134
+ }
135
+
136
+ if (options.debug) {
137
+ console.log(response)
138
+ }
139
+ return $toastElement
140
+ },
141
+
142
+ success = function(message, title) {
143
+ return notify({
144
+ iconClass: getOptions().iconClasses.success,
145
+ message: message,
146
+ title: title
147
+ })
148
+ },
149
+
150
+ warning = function(message, title) {
151
+ return notify({
152
+ iconClass: getOptions().iconClasses.warning,
153
+ message: message,
154
+ title: title
155
+ })
156
+ }
157
+
158
+ return {
159
+ error: error,
160
+ info: info,
161
+ options: {},
162
+ success: success,
163
+ warning: warning
164
+ }
165
+ })()
166
+ } (window, jQuery));
@@ -0,0 +1,30 @@
1
+ @media all and (max-width: 240px) {
2
+ #toast-container > div {
3
+ padding: 8px 8px 8px 50px;
4
+ width: 108px;
5
+ }
6
+ }
7
+ @media all and (min-width: 241px) and (max-width: 320px) {
8
+ #toast-container > div {
9
+ padding: 8px 8px 8px 50px;
10
+ width: 128px;
11
+ }
12
+ }
13
+ @media all and (min-width: 321px) and (max-width: 480px) {
14
+ #toast-container > div {
15
+ padding: 8px 8px 8px 50px;
16
+ width: 192px;
17
+ }
18
+ }
19
+ @media all and (min-width: 481px) and (max-width: 768px) {
20
+ #toast-container > div {
21
+ padding: 15px 15px 15px 50px;
22
+ width: 300px;
23
+ }
24
+ }
25
+ @media all and (min-width: 769px) {
26
+ #toast-container > div {
27
+ padding: 15px 15px 15px 50px;
28
+ width: 300px;
29
+ }
30
+ }
@@ -0,0 +1,105 @@
1
+ .toast-title {
2
+ font-weight: bold;
3
+ }
4
+ .toast-message {
5
+ word-wrap: break-word;
6
+ }
7
+
8
+ .toast-message a,
9
+ .toast-message label{
10
+ color: #FFF;
11
+ }
12
+ .toast-message a:hover {
13
+ color: #CCC;
14
+ text-decoration: none;
15
+ }
16
+
17
+ .toast-top-left {
18
+ top: 12px;
19
+ left: 12px;
20
+ }
21
+
22
+ .toast-bottom-right {
23
+ right: 12px;
24
+ bottom: 12px;
25
+ }
26
+
27
+ .toast-bottom-left {
28
+ left: 12px;
29
+ bottom: 12px;
30
+ }
31
+
32
+ #toast-container {
33
+ position: fixed;
34
+ z-index: 9999;
35
+ }
36
+
37
+ #toast-container > div {
38
+ background-position: 15px center;
39
+ background-repeat: no-repeat;
40
+ -moz-border-radius: 3px 3px 3px 3px;
41
+ -webkit-border-radius: 3px 3px 3px 3px;
42
+ border-radius: 3px 3px 3px 3px;
43
+ -moz-box-shadow: 0 0 12px #999999;
44
+ -webkit-box-shadow: 0 0 12px #999999;
45
+ -o-box-shadow: 0 0 12px #999999;
46
+ box-shadow: 0 0 12px #999999;
47
+ color: #FFFFFF;
48
+ margin: 0 0 6px;
49
+ filter: alpha(opacity=80);
50
+ -ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=80)";
51
+ opacity: 0.8;
52
+ padding: 15px 15px 15px 50px;
53
+ width: 300px;
54
+ }
55
+
56
+ .toast {
57
+ background-color: #030303;
58
+ }
59
+
60
+ .toast-success{
61
+ background-color: #51A351;
62
+ }
63
+
64
+ .toast-error{
65
+ background-color: #BD362F;
66
+ }
67
+
68
+ .toast-info{
69
+ background-color: #2F96B4;
70
+ }
71
+
72
+ .toast-warning{
73
+ background-color: #F89406;
74
+ }
75
+ .toast-top-right {
76
+ top: 12px;
77
+ right: 12px;
78
+ }
79
+
80
+ #toast-container > :hover {
81
+ -moz-box-shadow: 0 0 12px #000000;
82
+ -webkit-box-shadow: 0 0 12px #000000;
83
+ -o-box-shadow: 0 0 12px #000000;
84
+ box-shadow: 0 0 12px #000000;
85
+ filter: alpha(opacity=100);
86
+ -ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";
87
+ opacity: 1;
88
+ cursor: pointer;
89
+ }
90
+
91
+ #toast-container > .toast-info {
92
+ background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAGwSURBVEhLtZa9SgNBEMc9sUxxRcoUKSzSWIhXpFMhhYWFhaBg4yPYiWCXZxBLERsLRS3EQkEfwCKdjWJAwSKCgoKCcudv4O5YLrt7EzgXhiU3/4+b2ckmwVjJSpKkQ6wAi4gwhT+z3wRBcEz0yjSseUTrcRyfsHsXmD0AmbHOC9Ii8VImnuXBPglHpQ5wwSVM7sNnTG7Za4JwDdCjxyAiH3nyA2mtaTJufiDZ5dCaqlItILh1NHatfN5skvjx9Z38m69CgzuXmZgVrPIGE763Jx9qKsRozWYw6xOHdER+nn2KkO+Bb+UV5CBN6WC6QtBgbRVozrahAbmm6HtUsgtPC19tFdxXZYBOfkbmFJ1VaHA1VAHjd0pp70oTZzvR+EVrx2Ygfdsq6eu55BHYR8hlcki+n+kERUFG8BrA0BwjeAv2M8WLQBtcy+SD6fNsmnB3AlBLrgTtVW1c2QN4bVWLATaIS60J2Du5y1TiJgjSBvFVZgTmwCU+dAZFoPxGEEs8nyHC9Bwe2GvEJv2WXZb0vjdyFT4Cxk3e/kIqlOGoVLwwPevpYHT+00T+hWwXDf4AJAOUqWcDhbwAAAAASUVORK5CYII=") !important;
93
+ }
94
+
95
+ #toast-container > .toast-error {
96
+ background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAHOSURBVEhLrZa/SgNBEMZzh0WKCClSCKaIYOED+AAKeQQLG8HWztLCImBrYadgIdY+gIKNYkBFSwu7CAoqCgkkoGBI/E28PdbLZmeDLgzZzcx83/zZ2SSXC1j9fr+I1Hq93g2yxH4iwM1vkoBWAdxCmpzTxfkN2RcyZNaHFIkSo10+8kgxkXIURV5HGxTmFuc75B2RfQkpxHG8aAgaAFa0tAHqYFfQ7Iwe2yhODk8+J4C7yAoRTWI3w/4klGRgR4lO7Rpn9+gvMyWp+uxFh8+H+ARlgN1nJuJuQAYvNkEnwGFck18Er4q3egEc/oO+mhLdKgRyhdNFiacC0rlOCbhNVz4H9FnAYgDBvU3QIioZlJFLJtsoHYRDfiZoUyIxqCtRpVlANq0EU4dApjrtgezPFad5S19Wgjkc0hNVnuF4HjVA6C7QrSIbylB+oZe3aHgBsqlNqKYH48jXyJKMuAbiyVJ8KzaB3eRc0pg9VwQ4niFryI68qiOi3AbjwdsfnAtk0bCjTLJKr6mrD9g8iq/S/B81hguOMlQTnVyG40wAcjnmgsCNESDrjme7wfftP4P7SP4N3CJZdvzoNyGq2c/HWOXJGsvVg+RA/k2MC/wN6I2YA2Pt8GkAAAAASUVORK5CYII=") !important;
97
+ }
98
+
99
+ #toast-container > .toast-success {
100
+ background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAADsSURBVEhLY2AYBfQMgf///3P8+/evAIgvA/FsIF+BavYDDWMBGroaSMMBiE8VC7AZDrIFaMFnii3AZTjUgsUUWUDA8OdAH6iQbQEhw4HyGsPEcKBXBIC4ARhex4G4BsjmweU1soIFaGg/WtoFZRIZdEvIMhxkCCjXIVsATV6gFGACs4Rsw0EGgIIH3QJYJgHSARQZDrWAB+jawzgs+Q2UO49D7jnRSRGoEFRILcdmEMWGI0cm0JJ2QpYA1RDvcmzJEWhABhD/pqrL0S0CWuABKgnRki9lLseS7g2AlqwHWQSKH4oKLrILpRGhEQCw2LiRUIa4lwAAAABJRU5ErkJggg==") !important;
101
+ }
102
+
103
+ #toast-container > .toast-warning {
104
+ background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAGYSURBVEhL5ZSvTsNQFMbXZGICMYGYmJhAQIJAICYQPAACiSDB8AiICQQJT4CqQEwgJvYASAQCiZiYmJhAIBATCARJy+9rTsldd8sKu1M0+dLb057v6/lbq/2rK0mS/TRNj9cWNAKPYIJII7gIxCcQ51cvqID+GIEX8ASG4B1bK5gIZFeQfoJdEXOfgX4QAQg7kH2A65yQ87lyxb27sggkAzAuFhbbg1K2kgCkB1bVwyIR9m2L7PRPIhDUIXgGtyKw575yz3lTNs6X4JXnjV+LKM/m3MydnTbtOKIjtz6VhCBq4vSm3ncdrD2lk0VgUXSVKjVDJXJzijW1RQdsU7F77He8u68koNZTz8Oz5yGa6J3H3lZ0xYgXBK2QymlWWA+RWnYhskLBv2vmE+hBMCtbA7KX5drWyRT/2JsqZ2IvfB9Y4bWDNMFbJRFmC9E74SoS0CqulwjkC0+5bpcV1CZ8NMej4pjy0U+doDQsGyo1hzVJttIjhQ7GnBtRFN1UarUlH8F3xict+HY07rEzoUGPlWcjRFRr4/gChZgc3ZL2d8oAAAAASUVORK5CYII=") !important;
105
+ }
metadata ADDED
@@ -0,0 +1,226 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: toastr-rails
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.2
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Tyler Gannon
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-08-10 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: toastr-rails
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: bundler
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ~>
36
+ - !ruby/object:Gem::Version
37
+ version: 1.1.3
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: 1.1.3
46
+ - !ruby/object:Gem::Dependency
47
+ name: jeweler
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ~>
52
+ - !ruby/object:Gem::Version
53
+ version: 1.8.3
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: 1.8.3
62
+ - !ruby/object:Gem::Dependency
63
+ name: bundler
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ~>
68
+ - !ruby/object:Gem::Version
69
+ version: 1.1.3
70
+ type: :development
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ~>
76
+ - !ruby/object:Gem::Version
77
+ version: 1.1.3
78
+ - !ruby/object:Gem::Dependency
79
+ name: jeweler
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ~>
84
+ - !ruby/object:Gem::Version
85
+ version: 1.8.3
86
+ type: :development
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ~>
92
+ - !ruby/object:Gem::Version
93
+ version: 1.8.3
94
+ - !ruby/object:Gem::Dependency
95
+ name: bundler
96
+ requirement: !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ~>
100
+ - !ruby/object:Gem::Version
101
+ version: 1.1.3
102
+ type: :development
103
+ prerelease: false
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ~>
108
+ - !ruby/object:Gem::Version
109
+ version: 1.1.3
110
+ - !ruby/object:Gem::Dependency
111
+ name: jeweler
112
+ requirement: !ruby/object:Gem::Requirement
113
+ none: false
114
+ requirements:
115
+ - - ~>
116
+ - !ruby/object:Gem::Version
117
+ version: 1.8.3
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ none: false
122
+ requirements:
123
+ - - ~>
124
+ - !ruby/object:Gem::Version
125
+ version: 1.8.3
126
+ - !ruby/object:Gem::Dependency
127
+ name: bundler
128
+ requirement: !ruby/object:Gem::Requirement
129
+ none: false
130
+ requirements:
131
+ - - ~>
132
+ - !ruby/object:Gem::Version
133
+ version: 1.1.3
134
+ type: :development
135
+ prerelease: false
136
+ version_requirements: !ruby/object:Gem::Requirement
137
+ none: false
138
+ requirements:
139
+ - - ~>
140
+ - !ruby/object:Gem::Version
141
+ version: 1.1.3
142
+ - !ruby/object:Gem::Dependency
143
+ name: jeweler
144
+ requirement: !ruby/object:Gem::Requirement
145
+ none: false
146
+ requirements:
147
+ - - ~>
148
+ - !ruby/object:Gem::Version
149
+ version: 1.8.3
150
+ type: :development
151
+ prerelease: false
152
+ version_requirements: !ruby/object:Gem::Requirement
153
+ none: false
154
+ requirements:
155
+ - - ~>
156
+ - !ruby/object:Gem::Version
157
+ version: 1.8.3
158
+ - !ruby/object:Gem::Dependency
159
+ name: railties
160
+ requirement: !ruby/object:Gem::Requirement
161
+ none: false
162
+ requirements:
163
+ - - ! '>='
164
+ - !ruby/object:Gem::Version
165
+ version: 3.1.0
166
+ type: :runtime
167
+ prerelease: false
168
+ version_requirements: !ruby/object:Gem::Requirement
169
+ none: false
170
+ requirements:
171
+ - - ! '>='
172
+ - !ruby/object:Gem::Version
173
+ version: 3.1.0
174
+ description: ! 'Toastr: Simple javascript toast notifications, plugged into the rails
175
+ asset pipeline.'
176
+ email:
177
+ - tgannon@gmail.com
178
+ executables: []
179
+ extensions: []
180
+ extra_rdoc_files:
181
+ - README.md
182
+ files:
183
+ - .rvmrc
184
+ - GPL-LICENSE.txt
185
+ - Gemfile
186
+ - Gemfile.lock
187
+ - MIT-LICENSE.txt
188
+ - README.md
189
+ - Rakefile
190
+ - index.html
191
+ - lib/toastr-rails.rb
192
+ - lib/toastr/rails.rb
193
+ - lib/toastr/rails/engine.rb
194
+ - lib/toastr/rails/version.rb
195
+ - toastr-rails.gemspec
196
+ - toastr-responsive.css
197
+ - toastr.css
198
+ - toastr.js
199
+ - vendor/assets/javascripts/toastr.js
200
+ - vendor/assets/stylesheets/toastr-responsive.css
201
+ - vendor/assets/stylesheets/toastr.css
202
+ homepage: https://github.com/CodeSeven/toastr
203
+ licenses: []
204
+ post_install_message:
205
+ rdoc_options: []
206
+ require_paths:
207
+ - lib
208
+ required_ruby_version: !ruby/object:Gem::Requirement
209
+ none: false
210
+ requirements:
211
+ - - ! '>='
212
+ - !ruby/object:Gem::Version
213
+ version: '0'
214
+ required_rubygems_version: !ruby/object:Gem::Requirement
215
+ none: false
216
+ requirements:
217
+ - - ! '>='
218
+ - !ruby/object:Gem::Version
219
+ version: 1.3.6
220
+ requirements: []
221
+ rubyforge_project:
222
+ rubygems_version: 1.8.23
223
+ signing_key:
224
+ specification_version: 3
225
+ summary: ! 'Toastr: Simple javascript toast notifications'
226
+ test_files: []