1 | (function (global, factory) {
|
2 | typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('lodash'), require('sweetalert2'), require('ng-snotify'), require('@angular/common')) :
|
3 | typeof define === 'function' && define.amd ? define(['exports', '@angular/core', 'lodash', 'sweetalert2', 'ng-snotify', '@angular/common'], factory) :
|
4 | (factory((global['ngx-plus'] = global['ngx-plus'] || {}, global['ngx-plus']['ngx-alerts'] = {}),global.ng.core,global.lodash,global.swal,global.ngSnotify,global.ng.common));
|
5 | }(this, (function (exports,core,lodash,swal,ngSnotify,common) { 'use strict';
|
6 |
|
7 | swal = swal && swal.hasOwnProperty('default') ? swal['default'] : swal;
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 |
|
28 |
|
29 |
|
30 |
|
31 |
|
32 | function __read(o, n) {
|
33 | var m = typeof Symbol === "function" && o[Symbol.iterator];
|
34 | if (!m) return o;
|
35 | var i = m.call(o), r, ar = [], e;
|
36 | try {
|
37 | while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
38 | }
|
39 | catch (error) { e = { error: error }; }
|
40 | finally {
|
41 | try {
|
42 | if (r && !r.done && (m = i["return"])) m.call(i);
|
43 | }
|
44 | finally { if (e) throw e.error; }
|
45 | }
|
46 | return ar;
|
47 | }
|
48 | function __spread() {
|
49 | for (var ar = [], i = 0; i < arguments.length; i++)
|
50 | ar = ar.concat(__read(arguments[i]));
|
51 | return ar;
|
52 | }
|
53 |
|
54 |
|
55 |
|
56 |
|
57 |
|
58 | var NgxAlertTemplatesComponent = (function () {
|
59 | function NgxAlertTemplatesComponent() {
|
60 | }
|
61 | return NgxAlertTemplatesComponent;
|
62 | }());
|
63 | NgxAlertTemplatesComponent.decorators = [
|
64 | { type: core.Component, args: [{
|
65 | selector: 'ngx-alert-templates',
|
66 | template: "\n <ng-snotify></ng-snotify>\n ",
|
67 | },] },
|
68 | ];
|
69 |
|
70 | NgxAlertTemplatesComponent.ctorParameters = function () { return []; };
|
71 |
|
72 |
|
73 |
|
74 |
|
75 | var NgxAlertInterfaces = (function () {
|
76 | function NgxAlertInterfaces() {
|
77 | }
|
78 | return NgxAlertInterfaces;
|
79 | }());
|
80 |
|
81 |
|
82 |
|
83 |
|
84 |
|
85 |
|
86 |
|
87 |
|
88 |
|
89 |
|
90 |
|
91 | var NgxAlertsService = (function () {
|
92 | |
93 |
|
94 |
|
95 | function NgxAlertsService(notifyService) {
|
96 | this.notifyService = notifyService;
|
97 | }
|
98 | |
99 |
|
100 |
|
101 |
|
102 |
|
103 | NgxAlertsService.prototype.defaultNotify = function (type, config) {
|
104 | return this.notifyService[type](config.body, config.title || null, {
|
105 | timeout: config.timeout || 3000,
|
106 | showProgressBar: config.showProgressBar || true,
|
107 | closeOnClick: config.closeOnClick || true,
|
108 | pauseOnHover: config.pauseOnHover || true,
|
109 | buttons: config.buttons,
|
110 | placeholder: config.placeholder,
|
111 | html: config.html || null,
|
112 | position: config.position || 'rightBottom',
|
113 | });
|
114 | };
|
115 | |
116 |
|
117 |
|
118 |
|
119 | NgxAlertsService.prototype.notifySimple = function (config) {
|
120 | this.defaultNotify('simple', config);
|
121 | };
|
122 | |
123 |
|
124 |
|
125 |
|
126 | NgxAlertsService.prototype.notifySuccess = function (config) {
|
127 | this.defaultNotify('success', config);
|
128 | };
|
129 | |
130 |
|
131 |
|
132 |
|
133 | NgxAlertsService.prototype.notifyInfo = function (config) {
|
134 | this.defaultNotify('info', config);
|
135 | };
|
136 | |
137 |
|
138 |
|
139 |
|
140 | NgxAlertsService.prototype.notifyWarning = function (config) {
|
141 | this.defaultNotify('warning', config);
|
142 | };
|
143 | |
144 |
|
145 |
|
146 |
|
147 | NgxAlertsService.prototype.notifyError = function (config) {
|
148 | this.defaultNotify('error', config);
|
149 | };
|
150 | |
151 |
|
152 |
|
153 |
|
154 | NgxAlertsService.prototype.notifyPrompt = function (config) {
|
155 | this.defaultNotify('prompt', config);
|
156 | };
|
157 | |
158 |
|
159 |
|
160 |
|
161 | NgxAlertsService.prototype.notifyConfirm = function (config) {
|
162 | this.defaultNotify('confirm', config);
|
163 | };
|
164 | |
165 |
|
166 |
|
167 |
|
168 | NgxAlertsService.prototype.notifyDismiss = function (toastId) {
|
169 | this.notifyService.remove(toastId);
|
170 | };
|
171 | |
172 |
|
173 |
|
174 |
|
175 |
|
176 |
|
177 | NgxAlertsService.prototype.alert = function (options, successCb, closeCb) {
|
178 | if (options === void 0) { options = {}; }
|
179 | if (successCb === void 0) { successCb = lodash.noop; }
|
180 | if (closeCb === void 0) { closeCb = lodash.noop; }
|
181 | var defaultOptions = {
|
182 | type: options.type || null,
|
183 | title: options.title || null,
|
184 | text: options.text || null,
|
185 | buttonsStyling: options.buttonsStyling || false,
|
186 | confirmButtonClass: options.confirmButtonClass || 'btn btn-lg btn-secondary',
|
187 | animation: options.animation || true,
|
188 | customClass: options.customClass || '',
|
189 | };
|
190 | if (closeCb !== lodash.noop) {
|
191 | defaultOptions.showCancelButton = options.showCancelButton || true;
|
192 | defaultOptions.cancelButtonClass = options.cancelButtonClass || 'btn btn-lg btn-secondary';
|
193 | }
|
194 | return swal(lodash.assign(defaultOptions, options)).then(function (res) { return successCb(res); }, function (dismiss) { return closeCb(dismiss); });
|
195 | };
|
196 | |
197 |
|
198 |
|
199 |
|
200 |
|
201 |
|
202 | NgxAlertsService.prototype.alertSuccess = function (options, successCb, closeCb) {
|
203 | if (options === void 0) { options = {}; }
|
204 | if (successCb === void 0) { successCb = lodash.noop; }
|
205 | if (closeCb === void 0) { closeCb = lodash.noop; }
|
206 | var defaultOptions = {
|
207 | type: 'success',
|
208 | confirmButtonClass: 'btn btn-lg btn-success',
|
209 | };
|
210 | return this.alert(lodash.assign(defaultOptions, options), successCb, closeCb);
|
211 | };
|
212 | |
213 |
|
214 |
|
215 |
|
216 |
|
217 |
|
218 | NgxAlertsService.prototype.alertWarning = function (options, successCb, closeCb) {
|
219 | if (options === void 0) { options = {}; }
|
220 | if (successCb === void 0) { successCb = lodash.noop; }
|
221 | if (closeCb === void 0) { closeCb = lodash.noop; }
|
222 | var defaultOptions = {
|
223 | type: 'warning',
|
224 | confirmButtonClass: 'btn btn-lg btn-warning',
|
225 | };
|
226 | return this.alert(lodash.assign(defaultOptions, options), successCb, closeCb);
|
227 | };
|
228 | |
229 |
|
230 |
|
231 |
|
232 |
|
233 |
|
234 | NgxAlertsService.prototype.alertError = function (options, successCb, closeCb) {
|
235 | if (options === void 0) { options = {}; }
|
236 | if (successCb === void 0) { successCb = lodash.noop; }
|
237 | if (closeCb === void 0) { closeCb = lodash.noop; }
|
238 | var defaultOptions = {
|
239 | type: 'error',
|
240 | confirmButtonClass: 'btn btn-lg btn-danger',
|
241 | };
|
242 | return this.alert(lodash.assign(defaultOptions, options), successCb, closeCb);
|
243 | };
|
244 | |
245 |
|
246 |
|
247 |
|
248 |
|
249 |
|
250 | NgxAlertsService.prototype.alertInfo = function (options, successCb, closeCb) {
|
251 | if (options === void 0) { options = {}; }
|
252 | if (successCb === void 0) { successCb = lodash.noop; }
|
253 | if (closeCb === void 0) { closeCb = lodash.noop; }
|
254 | var defaultOptions = {
|
255 | type: 'info',
|
256 | confirmButtonClass: 'btn btn-lg btn-info',
|
257 | };
|
258 | return this.alert(lodash.assign(defaultOptions, options), successCb, closeCb);
|
259 | };
|
260 | |
261 |
|
262 |
|
263 |
|
264 |
|
265 |
|
266 | NgxAlertsService.prototype.alertQuestion = function (options, successCb, closeCb) {
|
267 | if (options === void 0) { options = {}; }
|
268 | if (successCb === void 0) { successCb = lodash.noop; }
|
269 | if (closeCb === void 0) { closeCb = lodash.noop; }
|
270 | var defaultOptions = {
|
271 | type: 'question',
|
272 | confirmButtonClass: 'btn btn-lg btn-primary',
|
273 | };
|
274 | return this.alert(lodash.assign(defaultOptions, options), successCb, closeCb);
|
275 | };
|
276 | return NgxAlertsService;
|
277 | }());
|
278 | NgxAlertsService.decorators = [
|
279 | { type: core.Injectable },
|
280 | ];
|
281 |
|
282 | NgxAlertsService.ctorParameters = function () { return [
|
283 | { type: ngSnotify.SnotifyService, },
|
284 | ]; };
|
285 |
|
286 |
|
287 |
|
288 |
|
289 |
|
290 |
|
291 |
|
292 |
|
293 | var components = [NgxAlertTemplatesComponent];
|
294 | var NgxAlertsModule = (function () {
|
295 | function NgxAlertsModule() {
|
296 | }
|
297 | |
298 |
|
299 |
|
300 | NgxAlertsModule.forRoot = function () {
|
301 | return {
|
302 | ngModule: NgxAlertsModule,
|
303 | providers: [{ provide: 'SnotifyToastConfig', useValue: ngSnotify.ToastDefaults }, ngSnotify.SnotifyService, NgxAlertsService],
|
304 | };
|
305 | };
|
306 | return NgxAlertsModule;
|
307 | }());
|
308 | NgxAlertsModule.decorators = [
|
309 | { type: core.NgModule, args: [{
|
310 | imports: [common.CommonModule, ngSnotify.SnotifyModule],
|
311 | declarations: __spread(components),
|
312 | exports: __spread(components),
|
313 | },] },
|
314 | ];
|
315 |
|
316 | NgxAlertsModule.ctorParameters = function () { return []; };
|
317 |
|
318 | exports.NgxAlertTemplatesComponent = NgxAlertTemplatesComponent;
|
319 | exports.NgxAlertInterfaces = NgxAlertInterfaces;
|
320 | exports.NgxAlertsService = NgxAlertsService;
|
321 | exports.NgxAlertsModule = NgxAlertsModule;
|
322 |
|
323 | Object.defineProperty(exports, '__esModule', { value: true });
|
324 |
|
325 | })));
|
326 |
|