ng-toaster-rails 0.4.10.1 → 0.4.11.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/lib/ng-toaster-rails/version.rb +2 -2
- data/vendor/assets/javascripts/toaster.js +48 -12
- 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: 3482cecc90762a64a30040b8664ac611d335e083
|
4
|
+
data.tar.gz: 2871be5862d1d17ef6d85bcecd4cdae6f6cdd80b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fa805e539f6152d59f1cb546552007ca5039b0d2c81d35e20bd0cd26fd5575ef858d01a6f5476f20a350abed57aa16a2528c41a90dc9dfe5666aa245383caeb0
|
7
|
+
data.tar.gz: 3b85173a155704ed7b3c1b16d7e2c8caa0b3cb62dad3bbbe9d70a7e06ebd83263b3e86309a53b9c190f467acd16e0f40c5de94c17e940b66404558d95a752ef4
|
@@ -3,7 +3,7 @@
|
|
3
3
|
|
4
4
|
/*
|
5
5
|
* AngularJS Toaster
|
6
|
-
* Version: 0.4.
|
6
|
+
* Version: 0.4.11
|
7
7
|
*
|
8
8
|
* Copyright 2013-2014 Jiri Kavulak.
|
9
9
|
* All Rights Reserved.
|
@@ -18,7 +18,17 @@ angular.module('toaster', ['ngAnimate'])
|
|
18
18
|
.constant('toasterConfig', {
|
19
19
|
'limit': 0, // limits max number of toasts
|
20
20
|
'tap-to-dismiss': true,
|
21
|
+
|
22
|
+
/* Options:
|
23
|
+
- Boolean false/true
|
24
|
+
'close-button': true
|
25
|
+
- object if not a boolean that allows you to
|
26
|
+
override showing the close button for each
|
27
|
+
icon-class value
|
28
|
+
'close-button': { 'toast-error': true, 'toast-info': false }
|
29
|
+
*/
|
21
30
|
'close-button': false,
|
31
|
+
|
22
32
|
'newest-on-top': true,
|
23
33
|
//'fade-in': 1000, // done in css
|
24
34
|
//'on-fade-in': undefined, // not implemented
|
@@ -46,7 +56,7 @@ angular.module('toaster', ['ngAnimate'])
|
|
46
56
|
'mouseover-timer-stop': true // stop timeout on mouseover and restart timer on mouseout
|
47
57
|
})
|
48
58
|
.service('toaster', ['$rootScope', 'toasterConfig', function ($rootScope, toasterConfig) {
|
49
|
-
this.pop = function (type, title, body, timeout, bodyOutputType, clickHandler, toasterId) {
|
59
|
+
this.pop = function (type, title, body, timeout, bodyOutputType, clickHandler, toasterId, showCloseButton) {
|
50
60
|
if (angular.isObject(type)) {
|
51
61
|
var params = type; // Enable named parameters as pop argument
|
52
62
|
this.toast = {
|
@@ -55,7 +65,8 @@ angular.module('toaster', ['ngAnimate'])
|
|
55
65
|
body: params.body,
|
56
66
|
timeout: params.timeout,
|
57
67
|
bodyOutputType: params.bodyOutputType,
|
58
|
-
clickHandler: params.clickHandler
|
68
|
+
clickHandler: params.clickHandler,
|
69
|
+
showCloseButton: params.showCloseButton
|
59
70
|
};
|
60
71
|
toasterId = params.toasterId;
|
61
72
|
} else {
|
@@ -65,7 +76,8 @@ angular.module('toaster', ['ngAnimate'])
|
|
65
76
|
body: body,
|
66
77
|
timeout: timeout,
|
67
78
|
bodyOutputType: bodyOutputType,
|
68
|
-
clickHandler: clickHandler
|
79
|
+
clickHandler: clickHandler,
|
80
|
+
showCloseButton: showCloseButton
|
69
81
|
};
|
70
82
|
}
|
71
83
|
$rootScope.$emit('toaster-newToast', toasterId);
|
@@ -78,9 +90,9 @@ angular.module('toaster', ['ngAnimate'])
|
|
78
90
|
// Create one method per icon class, to allow to call toaster.info() and similar
|
79
91
|
for (var type in toasterConfig['icon-classes']) {
|
80
92
|
this[type] = (function (toasterType) {
|
81
|
-
return function(title, body, timeout, bodyOutputType, clickHandler, toasterId) {
|
93
|
+
return function(title, body, timeout, bodyOutputType, clickHandler, toasterId, showCloseButton) {
|
82
94
|
if (angular.isString(title)) {
|
83
|
-
this.pop(toasterType, title, body, timeout, bodyOutputType, clickHandler, toasterId);
|
95
|
+
this.pop(toasterType, title, body, timeout, bodyOutputType, clickHandler, toasterId, showCloseButton);
|
84
96
|
} else { // 'title' is actually an object with options
|
85
97
|
this.pop(angular.extend(title, { type: toasterType }));
|
86
98
|
}
|
@@ -203,6 +215,30 @@ function ($parse, $rootScope, $interval, $sce, toasterConfig, toaster, toasterEv
|
|
203
215
|
|
204
216
|
toast.id = ++id;
|
205
217
|
|
218
|
+
|
219
|
+
// set the showCloseButton property on the toast so that
|
220
|
+
// each template can bind directly to the property to show/hide
|
221
|
+
// the close button
|
222
|
+
var closeButton = mergedConfig['close-button'];
|
223
|
+
|
224
|
+
// if toast.showCloseButton is a boolean value,
|
225
|
+
// it was specifically overriden in the pop arguments
|
226
|
+
if (typeof toast.showCloseButton === "boolean") {
|
227
|
+
|
228
|
+
} else if (typeof closeButton === "boolean") {
|
229
|
+
toast.showCloseButton = closeButton;
|
230
|
+
} else if (typeof closeButton === "object") {
|
231
|
+
var closeButtonForType = closeButton[toast.type];
|
232
|
+
|
233
|
+
if (typeof closeButtonForType !== "undefined" && closeButtonForType !== null) {
|
234
|
+
toast.showCloseButton = closeButtonForType;
|
235
|
+
}
|
236
|
+
} else {
|
237
|
+
// if an option was not set, default to false.
|
238
|
+
toast.showCloseButton = false;
|
239
|
+
}
|
240
|
+
|
241
|
+
|
206
242
|
// Set the toast.bodyOutputType to the default if it isn't set
|
207
243
|
toast.bodyOutputType = toast.bodyOutputType || mergedConfig['body-output-type'];
|
208
244
|
switch (toast.bodyOutputType) {
|
@@ -301,14 +337,14 @@ function ($parse, $rootScope, $interval, $sce, toasterConfig, toaster, toasterEv
|
|
301
337
|
}
|
302
338
|
};
|
303
339
|
|
304
|
-
$scope.click = function (toast
|
305
|
-
if ($scope.config.tap === true ||
|
340
|
+
$scope.click = function (toast) {
|
341
|
+
if ($scope.config.tap === true || toast.showCloseButton === true) {
|
306
342
|
var removeToast = true;
|
307
343
|
if (toast.clickHandler) {
|
308
344
|
if (angular.isFunction(toast.clickHandler)) {
|
309
|
-
removeToast = toast.clickHandler(toast,
|
345
|
+
removeToast = toast.clickHandler(toast, toast.showCloseButton);
|
310
346
|
} else if (angular.isFunction($scope.$parent.$eval(toast.clickHandler))) {
|
311
|
-
removeToast = $scope.$parent.$eval(toast.clickHandler)(toast,
|
347
|
+
removeToast = $scope.$parent.$eval(toast.clickHandler)(toast, toast.showCloseButton);
|
312
348
|
} else {
|
313
349
|
console.log("TOAST-NOTE: Your click handler is not inside a parent scope of toaster-container.");
|
314
350
|
}
|
@@ -322,7 +358,7 @@ function ($parse, $rootScope, $interval, $sce, toasterConfig, toaster, toasterEv
|
|
322
358
|
template:
|
323
359
|
'<div id="toast-container" ng-class="[config.position, config.animation]">' +
|
324
360
|
'<div ng-repeat="toaster in toasters" class="toast" ng-class="toaster.type" ng-click="click(toaster)" ng-mouseover="stopTimer(toaster)" ng-mouseout="restartTimer(toaster)">' +
|
325
|
-
'<button class="toast-close-button" ng-show="
|
361
|
+
'<button type="button" class="toast-close-button" ng-show="toaster.showCloseButton" ng-click="click(toaster)">×</button>' +
|
326
362
|
'<div ng-class="config.title">{{toaster.title}}</div>' +
|
327
363
|
'<div ng-class="config.message" ng-switch on="toaster.bodyOutputType">' +
|
328
364
|
'<div ng-switch-when="trustedHtml" ng-bind-html="toaster.html"></div>' +
|
@@ -334,4 +370,4 @@ function ($parse, $rootScope, $interval, $sce, toasterConfig, toaster, toasterEv
|
|
334
370
|
'</div>'
|
335
371
|
};
|
336
372
|
}]);
|
337
|
-
})(window, document);
|
373
|
+
})(window, document);
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ng-toaster-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.11.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- fdibartolo
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-03-
|
11
|
+
date: 2015-03-25 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: 'Rails engine for jirikavi/AngularJS-Toaster: "AngularJS Toaster is a
|
14
14
|
customized version of "toastr" non-blocking notification javascript library"'
|