ng-toaster-rails 0.4.13.0 → 0.4.15.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4442e5603b52a8a0034bd2c39aba87181ef5a7c0
4
- data.tar.gz: 014e44b0d6fd9c1c0153cebbaffd4246c04ee4e7
3
+ metadata.gz: ddd5acc201ff42c6adbc37f3bdba4990bb262fbb
4
+ data.tar.gz: ea9478494e1257c933e37c7c05cdf3e48a54d480
5
5
  SHA512:
6
- metadata.gz: a2ad739bd961dfeea9c624259e9cfb2534a1cba90aac64fdacd437d5b60e45a954ae02e7c1375718e450229736ba5b57d46d5a7900d87bc666eb1c4c242005f1
7
- data.tar.gz: db1f7f8119e52b5125927f6b6d5a561c4fb563140cc66c365b272abd84ecf081465fe4d4afbb2fdd7611acf8d881e076429083a41c04f47c463049175040a0b8
6
+ metadata.gz: 5fe2d8f9a2c2ce728ea27c71fccf9b708613c914c83f53852c5ee21edb111874f317141b670d3cc012808ab294274275fccc600fe84d1ef0fc5cbee89ca08f86
7
+ data.tar.gz: 3c192db2b4a150aaa912b65bcae57af75a8edda25b89c72aa401b0a8bfc4d1b4533c7617ead0afedae6f331e8c097b1fc5bae1b88ef89d49b1e446706728a96f
@@ -1,6 +1,6 @@
1
1
  module NgToaster
2
2
  module Rails
3
- TOASTER_VERSION = "0.4.13"
3
+ TOASTER_VERSION = "0.4.15"
4
4
  VERSION = "#{TOASTER_VERSION}.0"
5
5
  end
6
6
  end
@@ -1,9 +1,10 @@
1
- (function () {
1
+ /* global angular */
2
+ (function (window, document) {
2
3
  'use strict';
3
4
 
4
5
  /*
5
6
  * AngularJS Toaster
6
- * Version: 0.4.13
7
+ * Version: 0.4.15
7
8
  *
8
9
  * Copyright 2013-2015 Jiri Kavulak.
9
10
  * All Rights Reserved.
@@ -14,9 +15,9 @@
14
15
  * Related to project of John Papa, Hans Fjällemark and Nguyễn Thiện Hùng (thienhung1989)
15
16
  */
16
17
 
17
- angular.module('toaster', ['ngAnimate']).constant(
18
+ angular.module('toaster', []).constant(
18
19
  'toasterConfig', {
19
- 'limit': 0, // limits max number of toasts
20
+ 'limit': 0, // limits max number of toasts
20
21
  'tap-to-dismiss': true,
21
22
 
22
23
  /* Options:
@@ -27,61 +28,63 @@
27
28
  icon-class value
28
29
  'close-button': { 'toast-error': true, 'toast-info': false }
29
30
  */
30
- 'close-button': false,
31
-
32
- 'newest-on-top': true, //'fade-in': 1000, // done in css
31
+ 'close-button': false,
32
+ 'newest-on-top': true,
33
+ //'fade-in': 1000, // done in css
33
34
  //'on-fade-in': undefined, // not implemented
34
35
  //'fade-out': 1000, // done in css
35
36
  //'on-fade-out': undefined, // not implemented
36
37
  //'extended-time-out': 1000, // not implemented
37
- 'time-out': 5000, // Set timeOut and extendedTimeout to 0 to make it sticky
38
- 'icon-classes': {
39
- error: 'toast-error',
40
- info: 'toast-info',
41
- wait: 'toast-wait',
38
+ 'time-out': 5000, // Set timeOut and extendedTimeout to 0 to make it sticky
39
+ 'icon-classes': {
40
+ error: 'toast-error',
41
+ info: 'toast-info',
42
+ wait: 'toast-wait',
42
43
  success: 'toast-success',
43
44
  warning: 'toast-warning'
44
45
  },
45
- 'body-output-type': '', // Options: '', 'trustedHtml', 'template', 'templateWithData'
46
- 'body-template': 'toasterBodyTmpl.html',
47
- 'icon-class': 'toast-info',
48
- 'position-class': 'toast-top-right', // Options (see CSS):
49
- // 'toast-top-full-width', 'toast-bottom-full-width', 'toast-center',
50
- // 'toast-top-left', 'toast-top-center', 'toast-top-right',
51
- // 'toast-bottom-left', 'toast-bottom-center', 'toast-bottom-right',
52
- 'title-class': 'toast-title',
53
- 'message-class': 'toast-message',
54
- 'prevent-duplicates': false,
46
+ 'body-output-type': '', // Options: '', 'trustedHtml', 'template', 'templateWithData'
47
+ 'body-template': 'toasterBodyTmpl.html',
48
+ 'icon-class': 'toast-info',
49
+ 'position-class': 'toast-top-right', // Options (see CSS):
50
+ // 'toast-top-full-width', 'toast-bottom-full-width', 'toast-center',
51
+ // 'toast-top-left', 'toast-top-center', 'toast-top-right',
52
+ // 'toast-bottom-left', 'toast-bottom-center', 'toast-bottom-right',
53
+ 'title-class': 'toast-title',
54
+ 'message-class': 'toast-message',
55
+ 'prevent-duplicates': false,
55
56
  'mouseover-timer-stop': true // stop timeout on mouseover and restart timer on mouseout
56
57
  }
57
58
  ).service(
58
59
  'toaster', [
59
60
  '$rootScope', 'toasterConfig', function ($rootScope, toasterConfig) {
60
- this.pop = function (type, title, body, timeout, bodyOutputType, clickHandler, toasterId, showCloseButton, toastId) {
61
+ this.pop = function (type, title, body, timeout, bodyOutputType, clickHandler, toasterId, showCloseButton, toastId, onHideCallback) {
61
62
  if (angular.isObject(type)) {
62
63
  var params = type; // Enable named parameters as pop argument
63
64
  this.toast = {
64
- type: params.type,
65
- title: params.title,
66
- body: params.body,
67
- timeout: params.timeout,
68
- bodyOutputType: params.bodyOutputType,
69
- clickHandler: params.clickHandler,
65
+ type: params.type,
66
+ title: params.title,
67
+ body: params.body,
68
+ timeout: params.timeout,
69
+ bodyOutputType: params.bodyOutputType,
70
+ clickHandler: params.clickHandler,
70
71
  showCloseButton: params.showCloseButton,
71
- uid: params.toastId
72
+ uid: params.toastId,
73
+ onHideCallback: params.onHideCallback
72
74
  };
73
75
  toastId = params.toastId;
74
76
  toasterId = params.toasterId;
75
77
  } else {
76
78
  this.toast = {
77
- type: type,
78
- title: title,
79
- body: body,
80
- timeout: timeout,
81
- bodyOutputType: bodyOutputType,
82
- clickHandler: clickHandler,
79
+ type: type,
80
+ title: title,
81
+ body: body,
82
+ timeout: timeout,
83
+ bodyOutputType: bodyOutputType,
84
+ clickHandler: clickHandler,
83
85
  showCloseButton: showCloseButton,
84
- uid: toastId
86
+ uid: toastId,
87
+ onHideCallback: onHideCallback
85
88
  };
86
89
  }
87
90
  $rootScope.$emit('toaster-newToast', toasterId, toastId);
@@ -94,7 +97,7 @@
94
97
  // Create one method per icon class, to allow to call toaster.info() and similar
95
98
  for (var type in toasterConfig['icon-classes']) {
96
99
  this[type] = (function (toasterType) {
97
- return function (title, body, timeout, bodyOutputType, clickHandler, toasterId, showCloseButton, toastId) {
100
+ return function (title, body, timeout, bodyOutputType, clickHandler, toasterId, showCloseButton, toastId,onHideCallback) {
98
101
  if (angular.isString(title)) {
99
102
  this.pop(
100
103
  toasterType,
@@ -105,10 +108,11 @@
105
108
  clickHandler,
106
109
  toasterId,
107
110
  showCloseButton,
108
- toastId
111
+ toastId,
112
+ onHideCallback
109
113
  );
110
114
  } else { // 'title' is actually an object with options
111
- this.pop(angular.extend(title, {type: toasterType}));
115
+ this.pop(angular.extend(title, { type: toasterType }));
112
116
  }
113
117
  };
114
118
  })(type);
@@ -142,13 +146,13 @@
142
146
  }
143
147
  },
144
148
 
145
- subscribeToNewToastEvent: function (onNewToast) {
149
+ subscribeToNewToastEvent: function (onNewToast) {
146
150
  newToastEventSubscribers.push(onNewToast);
147
151
  },
148
- subscribeToClearToastsEvent: function (onClearToasts) {
152
+ subscribeToClearToastsEvent: function (onClearToasts) {
149
153
  clearToastsEventSubscribers.push(onClearToasts);
150
154
  },
151
- unsubscribeToNewToastEvent: function (onNewToast) {
155
+ unsubscribeToNewToastEvent: function (onNewToast) {
152
156
  var index = newToastEventSubscribers.indexOf(onNewToast);
153
157
  if (index >= 0) {
154
158
  newToastEventSubscribers.splice(index, 1);
@@ -172,10 +176,10 @@
172
176
  }
173
177
  };
174
178
  return {
175
- setup: toasterFactory.setup,
176
- subscribeToNewToastEvent: toasterFactory.subscribeToNewToastEvent,
177
- subscribeToClearToastsEvent: toasterFactory.subscribeToClearToastsEvent,
178
- unsubscribeToNewToastEvent: toasterFactory.unsubscribeToNewToastEvent,
179
+ setup: toasterFactory.setup,
180
+ subscribeToNewToastEvent: toasterFactory.subscribeToNewToastEvent,
181
+ subscribeToClearToastsEvent: toasterFactory.subscribeToClearToastsEvent,
182
+ unsubscribeToNewToastEvent: toasterFactory.unsubscribeToNewToastEvent,
179
183
  unsubscribeToClearToastsEvent: toasterFactory.unsubscribeToClearToastsEvent
180
184
  };
181
185
  }]
@@ -184,23 +188,23 @@
184
188
  '$parse', '$rootScope', '$interval', '$sce', 'toasterConfig', 'toaster', 'toasterEventRegistry',
185
189
  function ($parse, $rootScope, $interval, $sce, toasterConfig, toaster, toasterEventRegistry) {
186
190
  return {
187
- replace: true,
188
- restrict: 'EA',
189
- scope: true, // creates an internal scope for this directive (one per directive instance)
190
- link: function (scope, elm, attrs) {
191
+ replace: true,
192
+ restrict: 'EA',
193
+ scope: true, // creates an internal scope for this directive (one per directive instance)
194
+ link: function (scope, elm, attrs) {
191
195
  var id = 0, mergedConfig;
192
196
 
193
197
  // Merges configuration set in directive with default one
194
198
  mergedConfig = angular.extend({}, toasterConfig, scope.$eval(attrs.toasterOptions));
195
199
 
196
200
  scope.config = {
197
- toasterId: mergedConfig['toaster-id'],
198
- position: mergedConfig['position-class'],
199
- title: mergedConfig['title-class'],
200
- message: mergedConfig['message-class'],
201
- tap: mergedConfig['tap-to-dismiss'],
202
- closeButton: mergedConfig['close-button'],
203
- animation: mergedConfig['animation-class'],
201
+ toasterId: mergedConfig['toaster-id'],
202
+ position: mergedConfig['position-class'],
203
+ title: mergedConfig['title-class'],
204
+ message: mergedConfig['message-class'],
205
+ tap: mergedConfig['tap-to-dismiss'],
206
+ closeButton: mergedConfig['close-button'],
207
+ animation: mergedConfig['animation-class'],
204
208
  mouseoverTimer: mergedConfig['mouseover-timer-stop']
205
209
  };
206
210
 
@@ -221,6 +225,7 @@
221
225
 
222
226
  scope.configureTimer = function (toast) {
223
227
  var timeout = angular.isNumber(toast.timeout) ? toast.timeout : mergedConfig['time-out'];
228
+ if (typeof timeout === "object") timeout = timeout[toast.type];
224
229
  if (timeout > 0) {
225
230
  setTimeout(toast, timeout);
226
231
  }
@@ -327,6 +332,10 @@
327
332
  $interval.cancel(toast.timeoutPromise);
328
333
  }
329
334
  scope.toasters.splice(toastIndex, 1);
335
+
336
+ if (angular.isFunction(toast.onHideCallback)) {
337
+ toast.onHideCallback();
338
+ }
330
339
  }
331
340
  }
332
341
 
@@ -392,16 +401,14 @@
392
401
  }
393
402
  };
394
403
 
395
- $scope.click = function (toast) {
396
- if ($scope.config.tap === true || toast.showCloseButton === true) {
404
+ $scope.click = function (toast, isCloseButton) {
405
+ if ($scope.config.tap === true || (toast.showCloseButton === true && isCloseButton === true)) {
397
406
  var removeToast = true;
398
407
  if (toast.clickHandler) {
399
408
  if (angular.isFunction(toast.clickHandler)) {
400
- removeToast = toast.clickHandler(toast, toast.showCloseButton);
409
+ removeToast = toast.clickHandler(toast, isCloseButton);
401
410
  } else if (angular.isFunction($scope.$parent.$eval(toast.clickHandler))) {
402
- removeToast = $scope.$parent.$eval(toast.clickHandler)(
403
- toast, toast.showCloseButton
404
- );
411
+ removeToast = $scope.$parent.$eval(toast.clickHandler)(toast, isCloseButton);
405
412
  } else {
406
413
  console.log("TOAST-NOTE: Your click handler is not inside a parent scope of toaster-container.");
407
414
  }
@@ -412,8 +419,8 @@
412
419
  }
413
420
  };
414
421
  }],
415
- template: '<div id="toast-container" ng-class="[config.position, config.animation]">' + '<div ng-repeat="toaster in toasters" class="toast" ng-class="toaster.type" ng-click="click(toaster)" ng-mouseover="stopTimer(toaster)" ng-mouseout="restartTimer(toaster)">' + '<button type="button" class="toast-close-button" ng-show="toaster.showCloseButton" ng-click="click(toaster)">&times;</button>' + '<div ng-class="config.title">{{toaster.title}}</div>' + '<div ng-class="config.message" ng-switch on="toaster.bodyOutputType">' + '<div ng-switch-when="trustedHtml" ng-bind-html="toaster.html"></div>' + '<div ng-switch-when="template"><div ng-include="toaster.bodyTemplate"></div></div>' + '<div ng-switch-when="templateWithData"><div ng-include="toaster.bodyTemplate"></div></div>' + '<div ng-switch-default >{{toaster.body}}</div>' + '</div>' + '</div>' + '</div>'
422
+ template: '<div id="toast-container" ng-class="[config.position, config.animation]">' + '<div ng-repeat="toaster in toasters" class="toast" ng-class="toaster.type" ng-click="click(toaster)" ng-mouseover="stopTimer(toaster)" ng-mouseout="restartTimer(toaster)">' + '<button type="button" class="toast-close-button" ng-show="toaster.showCloseButton" ng-click="click(toaster, true)">&times;</button>' + '<div ng-class="config.title">{{toaster.title}}</div>' + '<div ng-class="config.message" ng-switch on="toaster.bodyOutputType">' + '<div ng-switch-when="trustedHtml" ng-bind-html="toaster.html"></div>' + '<div ng-switch-when="template"><div ng-include="toaster.bodyTemplate"></div></div>' + '<div ng-switch-when="templateWithData"><div ng-include="toaster.bodyTemplate"></div></div>' + '<div ng-switch-default >{{toaster.body}}</div>' + '</div>' + '</div>' + '</div>'
416
423
  };
417
424
  }]
418
425
  );
419
- })(window, document);
426
+ })(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.13.0
4
+ version: 0.4.15.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-05-18 00:00:00.000000000 Z
11
+ date: 2015-06-26 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"'