toastr_rails 2.1.0.2 → 2.1.1
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/app/assets/javascript/toastr.js +131 -91
- data/app/assets/javascript/toastr_rails.js +7 -1
- data/app/assets/styleseets/toastr.scss +0 -2
- 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: 1bf8f3a01444cf5214e3656292a96fbbba87997f
|
4
|
+
data.tar.gz: df7297b743446c4e66575a5bbe04be1e9625ecec
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0f7e33ed01201f093a098bc49d657fc954ed443420e4a76a16210e5a2ab36699d8859ca8048306343aaa79fa572b15a13d4d20c645d9f6b47abd5eaf7b727699
|
7
|
+
data.tar.gz: 84d5f7edbac6a9db494fea6a964373619b6190e74d6019074cb1f7ac616b23ba472e3bfd6806239487008314ac6d75f41f8c9b55bd86c96b9955656e8f4f4581
|
@@ -1,6 +1,6 @@
|
|
1
1
|
/*
|
2
2
|
* Toastr
|
3
|
-
* Copyright 2012-
|
3
|
+
* Copyright 2012-2015
|
4
4
|
* Authors: John Papa, Hans Fjällemark, and Tim Ferrell.
|
5
5
|
* All Rights Reserved.
|
6
6
|
* Use, reproduction, distribution, and modification of this code is subject to the terms and
|
@@ -10,6 +10,7 @@
|
|
10
10
|
*
|
11
11
|
* Project: https://github.com/CodeSeven/toastr
|
12
12
|
*/
|
13
|
+
/* global define */
|
13
14
|
; (function (define) {
|
14
15
|
define(['jquery'], function ($) {
|
15
16
|
return (function () {
|
@@ -32,7 +33,7 @@
|
|
32
33
|
options: {},
|
33
34
|
subscribe: subscribe,
|
34
35
|
success: success,
|
35
|
-
version: '2.1.
|
36
|
+
version: '2.1.1',
|
36
37
|
warning: warning
|
37
38
|
};
|
38
39
|
|
@@ -40,7 +41,8 @@
|
|
40
41
|
|
41
42
|
return toastr;
|
42
43
|
|
43
|
-
|
44
|
+
////////////////
|
45
|
+
|
44
46
|
function error(message, title, optionsOverride) {
|
45
47
|
return notify({
|
46
48
|
type: toastType.error,
|
@@ -97,10 +99,10 @@
|
|
97
99
|
});
|
98
100
|
}
|
99
101
|
|
100
|
-
function clear($toastElement) {
|
102
|
+
function clear($toastElement, clearOptions) {
|
101
103
|
var options = getOptions();
|
102
104
|
if (!$container) { getContainer(options); }
|
103
|
-
if (!clearToast($toastElement, options)) {
|
105
|
+
if (!clearToast($toastElement, options, clearOptions)) {
|
104
106
|
clearContainer(options);
|
105
107
|
}
|
106
108
|
}
|
@@ -116,9 +118,8 @@
|
|
116
118
|
$container.remove();
|
117
119
|
}
|
118
120
|
}
|
119
|
-
//#endregion
|
120
121
|
|
121
|
-
|
122
|
+
// internal functions
|
122
123
|
|
123
124
|
function clearContainer (options) {
|
124
125
|
var toastsToClear = $container.children();
|
@@ -127,8 +128,9 @@
|
|
127
128
|
}
|
128
129
|
}
|
129
130
|
|
130
|
-
function clearToast ($toastElement, options) {
|
131
|
-
|
131
|
+
function clearToast ($toastElement, options, clearOptions) {
|
132
|
+
var force = clearOptions && clearOptions.force ? clearOptions.force : false;
|
133
|
+
if ($toastElement && (force || $(':focus', $toastElement).length === 0)) {
|
132
134
|
$toastElement[options.hideMethod]({
|
133
135
|
duration: options.hideDuration,
|
134
136
|
easing: options.hideEasing,
|
@@ -192,117 +194,156 @@
|
|
192
194
|
}
|
193
195
|
|
194
196
|
function notify(map) {
|
195
|
-
var options = getOptions()
|
196
|
-
|
197
|
+
var options = getOptions();
|
198
|
+
var iconClass = map.iconClass || options.iconClass;
|
197
199
|
|
198
200
|
if (typeof (map.optionsOverride) !== 'undefined') {
|
199
201
|
options = $.extend(options, map.optionsOverride);
|
200
202
|
iconClass = map.optionsOverride.iconClass || iconClass;
|
201
203
|
}
|
202
|
-
|
203
|
-
if (options
|
204
|
-
if (map.message === previousToast) {
|
205
|
-
return;
|
206
|
-
} else {
|
207
|
-
previousToast = map.message;
|
208
|
-
}
|
209
|
-
}
|
204
|
+
|
205
|
+
if (shouldExit(options, map)) { return; }
|
210
206
|
|
211
207
|
toastId++;
|
212
208
|
|
213
209
|
$container = getContainer(options, true);
|
214
|
-
var intervalId = null,
|
215
|
-
$toastElement = $('<div/>'),
|
216
|
-
$titleElement = $('<div/>'),
|
217
|
-
$messageElement = $('<div/>'),
|
218
|
-
$progressElement = $('<div/>'),
|
219
|
-
$closeElement = $(options.closeHtml),
|
220
|
-
progressBar = {
|
221
|
-
intervalId: null,
|
222
|
-
hideEta: null,
|
223
|
-
maxHideTime: null
|
224
|
-
},
|
225
|
-
response = {
|
226
|
-
toastId: toastId,
|
227
|
-
state: 'visible',
|
228
|
-
startTime: new Date(),
|
229
|
-
options: options,
|
230
|
-
map: map
|
231
|
-
};
|
232
|
-
|
233
|
-
if (map.iconClass) {
|
234
|
-
$toastElement.addClass(options.toastClass).addClass(iconClass);
|
235
|
-
}
|
236
210
|
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
211
|
+
var intervalId = null;
|
212
|
+
var $toastElement = $('<div/>');
|
213
|
+
var $titleElement = $('<div/>');
|
214
|
+
var $messageElement = $('<div/>');
|
215
|
+
var $progressElement = $('<div/>');
|
216
|
+
var $closeElement = $(options.closeHtml);
|
217
|
+
var progressBar = {
|
218
|
+
intervalId: null,
|
219
|
+
hideEta: null,
|
220
|
+
maxHideTime: null
|
221
|
+
};
|
222
|
+
var response = {
|
223
|
+
toastId: toastId,
|
224
|
+
state: 'visible',
|
225
|
+
startTime: new Date(),
|
226
|
+
options: options,
|
227
|
+
map: map
|
228
|
+
};
|
229
|
+
|
230
|
+
personalizeToast();
|
241
231
|
|
242
|
-
|
243
|
-
|
244
|
-
|
232
|
+
displayToast();
|
233
|
+
|
234
|
+
handleEvents();
|
235
|
+
|
236
|
+
publish(response);
|
237
|
+
|
238
|
+
if (options.debug && console) {
|
239
|
+
console.log(response);
|
245
240
|
}
|
246
241
|
|
247
|
-
|
248
|
-
|
249
|
-
|
242
|
+
return $toastElement;
|
243
|
+
|
244
|
+
function personalizeToast() {
|
245
|
+
setIcon();
|
246
|
+
setTitle();
|
247
|
+
setMessage();
|
248
|
+
setCloseButton();
|
249
|
+
setProgressBar();
|
250
|
+
setSequence();
|
250
251
|
}
|
251
252
|
|
252
|
-
|
253
|
-
$
|
254
|
-
|
253
|
+
function handleEvents() {
|
254
|
+
$toastElement.hover(stickAround, delayedHideToast);
|
255
|
+
if (!options.onclick && options.tapToDismiss) {
|
256
|
+
$toastElement.click(hideToast);
|
257
|
+
}
|
258
|
+
|
259
|
+
if (options.closeButton && $closeElement) {
|
260
|
+
$closeElement.click(function (event) {
|
261
|
+
if (event.stopPropagation) {
|
262
|
+
event.stopPropagation();
|
263
|
+
} else if (event.cancelBubble !== undefined && event.cancelBubble !== true) {
|
264
|
+
event.cancelBubble = true;
|
265
|
+
}
|
266
|
+
hideToast(true);
|
267
|
+
});
|
268
|
+
}
|
269
|
+
|
270
|
+
if (options.onclick) {
|
271
|
+
$toastElement.click(function () {
|
272
|
+
options.onclick();
|
273
|
+
hideToast();
|
274
|
+
});
|
275
|
+
}
|
255
276
|
}
|
256
277
|
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
278
|
+
function displayToast() {
|
279
|
+
$toastElement.hide();
|
280
|
+
|
281
|
+
$toastElement[options.showMethod](
|
282
|
+
{duration: options.showDuration, easing: options.showEasing, complete: options.onShown}
|
283
|
+
);
|
284
|
+
|
285
|
+
if (options.timeOut > 0) {
|
286
|
+
intervalId = setTimeout(hideToast, options.timeOut);
|
287
|
+
progressBar.maxHideTime = parseFloat(options.timeOut);
|
288
|
+
progressBar.hideEta = new Date().getTime() + progressBar.maxHideTime;
|
289
|
+
if (options.progressBar) {
|
290
|
+
progressBar.intervalId = setInterval(updateProgress, 10);
|
291
|
+
}
|
292
|
+
}
|
262
293
|
}
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
if (options.timeOut > 0) {
|
268
|
-
intervalId = setTimeout(hideToast, options.timeOut);
|
269
|
-
progressBar.maxHideTime = parseFloat(options.timeOut);
|
270
|
-
progressBar.hideEta = new Date().getTime() + progressBar.maxHideTime;
|
271
|
-
if (options.progressBar) {
|
272
|
-
progressBar.intervalId = setInterval(updateProgress, 10);
|
294
|
+
|
295
|
+
function setIcon() {
|
296
|
+
if (map.iconClass) {
|
297
|
+
$toastElement.addClass(options.toastClass).addClass(iconClass);
|
273
298
|
}
|
274
299
|
}
|
275
300
|
|
276
|
-
|
277
|
-
|
278
|
-
|
301
|
+
function setSequence() {
|
302
|
+
if (options.newestOnTop) {
|
303
|
+
$container.prepend($toastElement);
|
304
|
+
} else {
|
305
|
+
$container.append($toastElement);
|
306
|
+
}
|
279
307
|
}
|
280
308
|
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
event.cancelBubble = true;
|
287
|
-
}
|
288
|
-
hideToast(true);
|
289
|
-
});
|
309
|
+
function setTitle() {
|
310
|
+
if (map.title) {
|
311
|
+
$titleElement.append(map.title).addClass(options.titleClass);
|
312
|
+
$toastElement.append($titleElement);
|
313
|
+
}
|
290
314
|
}
|
291
315
|
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
}
|
316
|
+
function setMessage() {
|
317
|
+
if (map.message) {
|
318
|
+
$messageElement.append(map.message).addClass(options.messageClass);
|
319
|
+
$toastElement.append($messageElement);
|
320
|
+
}
|
297
321
|
}
|
298
322
|
|
299
|
-
|
323
|
+
function setCloseButton() {
|
324
|
+
if (options.closeButton) {
|
325
|
+
$closeElement.addClass('toast-close-button').attr('role', 'button');
|
326
|
+
$toastElement.prepend($closeElement);
|
327
|
+
}
|
328
|
+
}
|
300
329
|
|
301
|
-
|
302
|
-
|
330
|
+
function setProgressBar() {
|
331
|
+
if (options.progressBar) {
|
332
|
+
$progressElement.addClass('toast-progress');
|
333
|
+
$toastElement.prepend($progressElement);
|
334
|
+
}
|
303
335
|
}
|
304
336
|
|
305
|
-
|
337
|
+
function shouldExit(options, map) {
|
338
|
+
if (options.preventDuplicates) {
|
339
|
+
if (map.message === previousToast) {
|
340
|
+
return true;
|
341
|
+
} else {
|
342
|
+
previousToast = map.message;
|
343
|
+
}
|
344
|
+
}
|
345
|
+
return false;
|
346
|
+
}
|
306
347
|
|
307
348
|
function hideToast(override) {
|
308
349
|
if ($(':focus', $toastElement).length && !override) {
|
@@ -362,7 +403,6 @@
|
|
362
403
|
previousToast = undefined;
|
363
404
|
}
|
364
405
|
}
|
365
|
-
//#endregion
|
366
406
|
|
367
407
|
})();
|
368
408
|
});
|
@@ -25,6 +25,12 @@ var showToast = function(flash){
|
|
25
25
|
warning: 'warning',
|
26
26
|
info: 'info'
|
27
27
|
};
|
28
|
-
|
28
|
+
var options = {
|
29
|
+
notice: {},
|
30
|
+
alert: { "timeOut": "0", "extendedTimeOut": "0" },
|
31
|
+
warning: { "timeOut": "0", "extendedTimeOut": "0" },
|
32
|
+
info: {}
|
33
|
+
};
|
34
|
+
toastr[type[msg[0]]](msg[1], '', options[msg[0]]);
|
29
35
|
}
|
30
36
|
};
|
@@ -158,7 +158,6 @@ button.toast-close-button {
|
|
158
158
|
.toast-warning {
|
159
159
|
background-color: #f89406;
|
160
160
|
}
|
161
|
-
|
162
161
|
.toast-progress {
|
163
162
|
position: absolute;
|
164
163
|
left: 0;
|
@@ -169,7 +168,6 @@ button.toast-close-button {
|
|
169
168
|
-ms-filter: progid:DXImageTransform.Microsoft.Alpha(Opacity=40);
|
170
169
|
filter: alpha(opacity=40);
|
171
170
|
}
|
172
|
-
|
173
171
|
/*Responsive Design*/
|
174
172
|
@media all and (max-width: 240px) {
|
175
173
|
#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.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stjepan Hadjic
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-05-08 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.4.5
|
84
84
|
signing_key:
|
85
85
|
specification_version: 4
|
86
86
|
summary: Opinionated toastr js asset gem.
|