toastr_rails 2.1.1 → 2.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/javascript/toastr.js +78 -17
- data/app/assets/javascript/toastr_rails.js +7 -1
- data/app/assets/styleseets/toastr.scss +7 -3
- data/lib/toastr_rails/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: f3b18e586db609d1bb88964b1df62b9414d923e6
|
4
|
+
data.tar.gz: 261dc93a7dd65babdd4a9abf18acf5fe96ebf3ce
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cdede1eb8b76b8f8c109823cb3705ae6548975bb0c8c2a5708a0cca0b9c8ed5ce22bd0a1cb7a91cbcca13fbeaf076fbc037b9e456fb2deac7e60a308941da0ad
|
7
|
+
data.tar.gz: 0371ba767262b8b66afb41395fdcfc720cb326f7e2aad1134c5ae03b5a7adcecc209dedb516383110ff7fd9b12d5cace4b76f62537a8b764e16900eaf757dab4
|
@@ -11,7 +11,7 @@
|
|
11
11
|
* Project: https://github.com/CodeSeven/toastr
|
12
12
|
*/
|
13
13
|
/* global define */
|
14
|
-
|
14
|
+
(function (define) {
|
15
15
|
define(['jquery'], function ($) {
|
16
16
|
return (function () {
|
17
17
|
var $container;
|
@@ -33,7 +33,7 @@
|
|
33
33
|
options: {},
|
34
34
|
subscribe: subscribe,
|
35
35
|
success: success,
|
36
|
-
version: '2.1.
|
36
|
+
version: '2.1.3',
|
37
37
|
warning: warning
|
38
38
|
};
|
39
39
|
|
@@ -144,9 +144,7 @@
|
|
144
144
|
function createContainer(options) {
|
145
145
|
$container = $('<div/>')
|
146
146
|
.attr('id', options.containerId)
|
147
|
-
.addClass(options.positionClass)
|
148
|
-
.attr('aria-live', 'polite')
|
149
|
-
.attr('role', 'alert');
|
147
|
+
.addClass(options.positionClass);
|
150
148
|
|
151
149
|
$container.appendTo($(options.target));
|
152
150
|
return $container;
|
@@ -167,6 +165,10 @@
|
|
167
165
|
hideDuration: 1000,
|
168
166
|
hideEasing: 'swing',
|
169
167
|
onHidden: undefined,
|
168
|
+
closeMethod: false,
|
169
|
+
closeDuration: false,
|
170
|
+
closeEasing: false,
|
171
|
+
closeOnHover: true,
|
170
172
|
|
171
173
|
extendedTimeOut: 1000,
|
172
174
|
iconClasses: {
|
@@ -180,11 +182,15 @@
|
|
180
182
|
timeOut: 5000, // Set timeOut and extendedTimeOut to 0 to make it sticky
|
181
183
|
titleClass: 'toast-title',
|
182
184
|
messageClass: 'toast-message',
|
185
|
+
escapeHtml: false,
|
183
186
|
target: 'body',
|
184
187
|
closeHtml: '<button type="button">×</button>',
|
188
|
+
closeClass: 'toast-close-button',
|
185
189
|
newestOnTop: true,
|
186
190
|
preventDuplicates: false,
|
187
|
-
progressBar: false
|
191
|
+
progressBar: false,
|
192
|
+
progressClass: 'toast-progress',
|
193
|
+
rtl: false
|
188
194
|
};
|
189
195
|
}
|
190
196
|
|
@@ -241,17 +247,48 @@
|
|
241
247
|
|
242
248
|
return $toastElement;
|
243
249
|
|
250
|
+
function escapeHtml(source) {
|
251
|
+
if (source == null) {
|
252
|
+
source = '';
|
253
|
+
}
|
254
|
+
|
255
|
+
return source
|
256
|
+
.replace(/&/g, '&')
|
257
|
+
.replace(/"/g, '"')
|
258
|
+
.replace(/'/g, ''')
|
259
|
+
.replace(/</g, '<')
|
260
|
+
.replace(/>/g, '>');
|
261
|
+
}
|
262
|
+
|
244
263
|
function personalizeToast() {
|
245
264
|
setIcon();
|
246
265
|
setTitle();
|
247
266
|
setMessage();
|
248
267
|
setCloseButton();
|
249
268
|
setProgressBar();
|
269
|
+
setRTL();
|
250
270
|
setSequence();
|
271
|
+
setAria();
|
272
|
+
}
|
273
|
+
|
274
|
+
function setAria() {
|
275
|
+
var ariaValue = '';
|
276
|
+
switch (map.iconClass) {
|
277
|
+
case 'toast-success':
|
278
|
+
case 'toast-info':
|
279
|
+
ariaValue = 'polite';
|
280
|
+
break;
|
281
|
+
default:
|
282
|
+
ariaValue = 'assertive';
|
283
|
+
}
|
284
|
+
$toastElement.attr('aria-live', ariaValue);
|
251
285
|
}
|
252
286
|
|
253
287
|
function handleEvents() {
|
254
|
-
|
288
|
+
if (options.closeOnHover) {
|
289
|
+
$toastElement.hover(stickAround, delayedHideToast);
|
290
|
+
}
|
291
|
+
|
255
292
|
if (!options.onclick && options.tapToDismiss) {
|
256
293
|
$toastElement.click(hideToast);
|
257
294
|
}
|
@@ -263,13 +300,18 @@
|
|
263
300
|
} else if (event.cancelBubble !== undefined && event.cancelBubble !== true) {
|
264
301
|
event.cancelBubble = true;
|
265
302
|
}
|
303
|
+
|
304
|
+
if (options.onCloseClick) {
|
305
|
+
options.onCloseClick(event);
|
306
|
+
}
|
307
|
+
|
266
308
|
hideToast(true);
|
267
309
|
});
|
268
310
|
}
|
269
311
|
|
270
312
|
if (options.onclick) {
|
271
|
-
$toastElement.click(function () {
|
272
|
-
options.onclick();
|
313
|
+
$toastElement.click(function (event) {
|
314
|
+
options.onclick(event);
|
273
315
|
hideToast();
|
274
316
|
});
|
275
317
|
}
|
@@ -308,32 +350,46 @@
|
|
308
350
|
|
309
351
|
function setTitle() {
|
310
352
|
if (map.title) {
|
311
|
-
|
353
|
+
var suffix = map.title;
|
354
|
+
if (options.escapeHtml) {
|
355
|
+
suffix = escapeHtml(map.title);
|
356
|
+
}
|
357
|
+
$titleElement.append(suffix).addClass(options.titleClass);
|
312
358
|
$toastElement.append($titleElement);
|
313
359
|
}
|
314
360
|
}
|
315
361
|
|
316
362
|
function setMessage() {
|
317
363
|
if (map.message) {
|
318
|
-
|
364
|
+
var suffix = map.message;
|
365
|
+
if (options.escapeHtml) {
|
366
|
+
suffix = escapeHtml(map.message);
|
367
|
+
}
|
368
|
+
$messageElement.append(suffix).addClass(options.messageClass);
|
319
369
|
$toastElement.append($messageElement);
|
320
370
|
}
|
321
371
|
}
|
322
372
|
|
323
373
|
function setCloseButton() {
|
324
374
|
if (options.closeButton) {
|
325
|
-
$closeElement.addClass(
|
375
|
+
$closeElement.addClass(options.closeClass).attr('role', 'button');
|
326
376
|
$toastElement.prepend($closeElement);
|
327
377
|
}
|
328
378
|
}
|
329
379
|
|
330
380
|
function setProgressBar() {
|
331
381
|
if (options.progressBar) {
|
332
|
-
$progressElement.addClass(
|
382
|
+
$progressElement.addClass(options.progressClass);
|
333
383
|
$toastElement.prepend($progressElement);
|
334
384
|
}
|
335
385
|
}
|
336
386
|
|
387
|
+
function setRTL() {
|
388
|
+
if (options.rtl) {
|
389
|
+
$toastElement.addClass('rtl');
|
390
|
+
}
|
391
|
+
}
|
392
|
+
|
337
393
|
function shouldExit(options, map) {
|
338
394
|
if (options.preventDuplicates) {
|
339
395
|
if (map.message === previousToast) {
|
@@ -346,15 +402,20 @@
|
|
346
402
|
}
|
347
403
|
|
348
404
|
function hideToast(override) {
|
405
|
+
var method = override && options.closeMethod !== false ? options.closeMethod : options.hideMethod;
|
406
|
+
var duration = override && options.closeDuration !== false ?
|
407
|
+
options.closeDuration : options.hideDuration;
|
408
|
+
var easing = override && options.closeEasing !== false ? options.closeEasing : options.hideEasing;
|
349
409
|
if ($(':focus', $toastElement).length && !override) {
|
350
410
|
return;
|
351
411
|
}
|
352
412
|
clearTimeout(progressBar.intervalId);
|
353
|
-
return $toastElement[
|
354
|
-
duration:
|
355
|
-
easing:
|
413
|
+
return $toastElement[method]({
|
414
|
+
duration: duration,
|
415
|
+
easing: easing,
|
356
416
|
complete: function () {
|
357
417
|
removeToast($toastElement);
|
418
|
+
clearTimeout(intervalId);
|
358
419
|
if (options.onHidden && response.state !== 'hidden') {
|
359
420
|
options.onHidden();
|
360
421
|
}
|
@@ -410,6 +471,6 @@
|
|
410
471
|
if (typeof module !== 'undefined' && module.exports) { //Node
|
411
472
|
module.exports = factory(require('jquery'));
|
412
473
|
} else {
|
413
|
-
window
|
474
|
+
window.toastr = factory(window.jQuery);
|
414
475
|
}
|
415
476
|
}));
|
@@ -21,7 +21,9 @@ var showToast = function(flash){
|
|
21
21
|
var msg = flash[i];
|
22
22
|
var type = {
|
23
23
|
notice: 'success',
|
24
|
+
success: 'success',
|
24
25
|
alert: 'error',
|
26
|
+
error: 'error',
|
25
27
|
warning: 'warning',
|
26
28
|
info: 'info'
|
27
29
|
};
|
@@ -31,6 +33,10 @@ var showToast = function(flash){
|
|
31
33
|
warning: { "timeOut": "0", "extendedTimeOut": "0" },
|
32
34
|
info: {}
|
33
35
|
};
|
34
|
-
|
36
|
+
try {
|
37
|
+
toastr[type[msg[0]]](msg[1], '', options[msg[0]]);
|
38
|
+
} catch(err) {
|
39
|
+
toastr.info(msg[1], '', options[msg[0]]);
|
40
|
+
}
|
35
41
|
}
|
36
42
|
};
|
@@ -112,7 +112,7 @@ button.toast-close-button {
|
|
112
112
|
-ms-filter: progid:DXImageTransform.Microsoft.Alpha(Opacity=80);
|
113
113
|
filter: alpha(opacity=80);
|
114
114
|
}
|
115
|
-
#toast-container > :hover {
|
115
|
+
#toast-container > div:hover {
|
116
116
|
-moz-box-shadow: 0 0 12px #000000;
|
117
117
|
-webkit-box-shadow: 0 0 12px #000000;
|
118
118
|
box-shadow: 0 0 12px #000000;
|
@@ -136,12 +136,14 @@ button.toast-close-button {
|
|
136
136
|
#toast-container.toast-top-center > div,
|
137
137
|
#toast-container.toast-bottom-center > div {
|
138
138
|
width: 300px;
|
139
|
-
margin: auto;
|
139
|
+
margin-left: auto;
|
140
|
+
margin-right: auto;
|
140
141
|
}
|
141
142
|
#toast-container.toast-top-full-width > div,
|
142
143
|
#toast-container.toast-bottom-full-width > div {
|
143
144
|
width: 96%;
|
144
|
-
margin: auto;
|
145
|
+
margin-left: auto;
|
146
|
+
margin-right: auto;
|
145
147
|
}
|
146
148
|
.toast {
|
147
149
|
background-color: #030303;
|
@@ -158,6 +160,7 @@ button.toast-close-button {
|
|
158
160
|
.toast-warning {
|
159
161
|
background-color: #f89406;
|
160
162
|
}
|
163
|
+
|
161
164
|
.toast-progress {
|
162
165
|
position: absolute;
|
163
166
|
left: 0;
|
@@ -168,6 +171,7 @@ button.toast-close-button {
|
|
168
171
|
-ms-filter: progid:DXImageTransform.Microsoft.Alpha(Opacity=40);
|
169
172
|
filter: alpha(opacity=40);
|
170
173
|
}
|
174
|
+
|
171
175
|
/*Responsive Design*/
|
172
176
|
@media all and (max-width: 240px) {
|
173
177
|
#toast-container > div {
|
data/lib/toastr_rails/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: toastr_rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.1.
|
4
|
+
version: 2.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stjepan Hadjic
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-12-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -80,7 +80,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
80
80
|
version: '0'
|
81
81
|
requirements: []
|
82
82
|
rubyforge_project:
|
83
|
-
rubygems_version: 2.
|
83
|
+
rubygems_version: 2.5.1
|
84
84
|
signing_key:
|
85
85
|
specification_version: 4
|
86
86
|
summary: Opinionated toastr js asset gem.
|