@finqu/cool 1.2.29 → 1.3.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.
- package/README.md +680 -1
- package/dist/css/cool.css +23575 -16644
- package/dist/css/cool.css.map +1 -154
- package/dist/css/cool.min.css +89 -3
- package/dist/css/cool.min.css.map +1 -1
- package/dist/js/cool.bundle.js +15402 -3800
- package/dist/js/cool.bundle.js.map +1 -1
- package/dist/js/cool.bundle.min.js +20 -8
- package/dist/js/cool.bundle.min.js.map +1 -1
- package/dist/js/cool.esm.js +4269 -3360
- package/dist/js/cool.esm.js.map +1 -1
- package/dist/js/cool.esm.min.js +9 -8
- package/dist/js/cool.esm.min.js.map +1 -1
- package/dist/js/cool.js +4271 -3362
- package/dist/js/cool.js.map +1 -1
- package/dist/js/cool.min.js +9 -8
- package/dist/js/cool.min.js.map +1 -1
- package/package.json +94 -61
- package/.babelrc.js +0 -20
- package/.browserslistrc +0 -13
- package/build/.eslintrc.json +0 -10
- package/build/banner.js +0 -14
- package/build/build-plugins.js +0 -92
- package/build/rollup.config.js +0 -46
- package/dist/css/cool-grid.css +0 -4390
- package/dist/css/cool-grid.css.map +0 -30
- package/dist/css/cool-grid.min.css +0 -7
- package/dist/css/cool-grid.min.css.map +0 -1
- package/dist/css/cool-reboot.css +0 -286
- package/dist/css/cool-reboot.css.map +0 -62
- package/dist/css/cool-reboot.min.css +0 -7
- package/dist/css/cool-reboot.min.css.map +0 -1
- package/html/index.html +0 -2703
- package/js/dist/collapse.js +0 -5535
- package/js/dist/collapse.js.map +0 -1
- package/js/dist/common.js +0 -21996
- package/js/dist/common.js.map +0 -1
- package/js/dist/cooldropdown.js +0 -467
- package/js/dist/cooldropdown.js.map +0 -1
- package/js/dist/coolpopover.js +0 -391
- package/js/dist/coolpopover.js.map +0 -1
- package/js/dist/coolsectiontabs.js +0 -256
- package/js/dist/coolsectiontabs.js.map +0 -1
- package/js/dist/coolselect.js +0 -796
- package/js/dist/coolselect.js.map +0 -1
- package/js/dist/cooltooltip.js +0 -360
- package/js/dist/cooltooltip.js.map +0 -1
- package/js/dist/coolui.js +0 -73
- package/js/dist/coolui.js.map +0 -1
- package/js/dist/dropdown.js +0 -27421
- package/js/dist/dropdown.js.map +0 -1
- package/js/dist/popover.js +0 -9472
- package/js/dist/popover.js.map +0 -1
- package/js/dist/sectiontabs.js +0 -4483
- package/js/dist/sectiontabs.js.map +0 -1
- package/js/dist/select.js +0 -37080
- package/js/dist/select.js.map +0 -1
- package/js/dist/tooltip.js +0 -8786
- package/js/dist/tooltip.js.map +0 -1
- package/js/index.esm.js +0 -21
- package/js/index.umd.js +0 -21
- package/js/src/abstract-ui-component.js +0 -81
- package/js/src/collapse.js +0 -286
- package/js/src/common.js +0 -296
- package/js/src/dialog.js +0 -579
- package/js/src/dropdown.js +0 -525
- package/js/src/popover.js +0 -632
- package/js/src/section-tabs.js +0 -215
- package/js/src/select.js +0 -1342
- package/js/src/toast.js +0 -581
- package/js/src/tooltip.js +0 -591
- package/js/src/util/animate-css.js +0 -22
- package/js/src/util/index.js +0 -122
- package/js/src/util/perfect-scrollbar.js +0 -1316
- package/less/alert.less +0 -345
- package/less/badge.less +0 -38
- package/less/bootstrap-noconflict.less +0 -23
- package/less/bootstrap.less +0 -23
- package/less/button-group.less +0 -153
- package/less/buttons.less +0 -287
- package/less/dialog-noconflict.less +0 -174
- package/less/dialog.less +0 -203
- package/less/dropdown.less +0 -209
- package/less/forms.less +0 -770
- package/less/images.less +0 -242
- package/less/input-group.less +0 -163
- package/less/list-group.less +0 -73
- package/less/mixins/aspect-ratio.less +0 -23
- package/less/mixins/border-radius.less +0 -24
- package/less/mixins/box-shadow.less +0 -4
- package/less/mixins/buttons.less +0 -17
- package/less/mixins/caret.less +0 -51
- package/less/mixins/clearfix.less +0 -10
- package/less/mixins/gradients.less +0 -34
- package/less/mixins/nav-divider.less +0 -7
- package/less/mixins/object-fit.less +0 -13
- package/less/mixins/reset-text.less +0 -16
- package/less/mixins.less +0 -11
- package/less/package.json +0 -11
- package/less/pagination.less +0 -69
- package/less/popover.less +0 -143
- package/less/project.sublime-workspace +0 -774
- package/less/reboot.less +0 -235
- package/less/section.less +0 -793
- package/less/select.less +0 -150
- package/less/tables.less +0 -737
- package/less/tabs.less +0 -162
- package/less/tooltip.less +0 -87
- package/less/type.less +0 -71
- package/less/utilities/align.less +0 -27
- package/less/utilities/animate.less +0 -3512
- package/less/utilities/background.less +0 -70
- package/less/utilities/borders.less +0 -16
- package/less/utilities/color.less +0 -70
- package/less/utilities/cursor.less +0 -8
- package/less/utilities/display.less +0 -38
- package/less/utilities/embed.less +0 -61
- package/less/utilities/flex.less +0 -76
- package/less/utilities/jquery-ui.less +0 -116
- package/less/utilities/lazyload.less +0 -29
- package/less/utilities/overflow.less +0 -11
- package/less/utilities/pace.less +0 -25
- package/less/utilities/placeholder.less +0 -60
- package/less/utilities/position.less +0 -42
- package/less/utilities/scrollbar.less +0 -152
- package/less/utilities/spacing.less +0 -197
- package/less/utilities/text.less +0 -68
- package/less/utilities/transform.less +0 -7
- package/less/utilities.less +0 -21
- package/less/variables.less +0 -343
- package/scss/LISENCE +0 -15
- package/scss/_alert.scss +0 -102
- package/scss/_badge.scss +0 -102
- package/scss/_button-group.scss +0 -129
- package/scss/_buttons.scss +0 -248
- package/scss/_custom-forms.scss +0 -444
- package/scss/_dialog.scss +0 -160
- package/scss/_dropdown.scss +0 -233
- package/scss/_forms.scss +0 -258
- package/scss/_frame.scss +0 -627
- package/scss/_functions.scss +0 -124
- package/scss/_grid.scss +0 -35
- package/scss/_images.scss +0 -361
- package/scss/_input-group.scss +0 -285
- package/scss/_list-group.scss +0 -82
- package/scss/_mixins.scss +0 -34
- package/scss/_navbar.scss +0 -290
- package/scss/_notification.scss +0 -13
- package/scss/_pagination.scss +0 -88
- package/scss/_popover.scss +0 -167
- package/scss/_reboot.scss +0 -284
- package/scss/_root.scss +0 -15
- package/scss/_section.scss +0 -977
- package/scss/_select.scss +0 -187
- package/scss/_tables.scss +0 -735
- package/scss/_tabs.scss +0 -178
- package/scss/_toast.scss +0 -182
- package/scss/_tooltip.scss +0 -101
- package/scss/_type.scss +0 -129
- package/scss/_utilities.scss +0 -23
- package/scss/_variables.scss +0 -823
- package/scss/cool-grid.scss +0 -29
- package/scss/cool-reboot.scss +0 -11
- package/scss/cool.scss +0 -37
- package/scss/mixins/_alert-variant.scss +0 -20
- package/scss/mixins/_aspect-ratio.scss +0 -29
- package/scss/mixins/_background-variant.scss +0 -25
- package/scss/mixins/_badge-variant.scss +0 -36
- package/scss/mixins/_breakpoints.scss +0 -102
- package/scss/mixins/_buttons.scss +0 -104
- package/scss/mixins/_caret.scss +0 -80
- package/scss/mixins/_clearfix.scss +0 -10
- package/scss/mixins/_float.scss +0 -14
- package/scss/mixins/_forms.scss +0 -67
- package/scss/mixins/_gradients.scss +0 -40
- package/scss/mixins/_grid-framework.scss +0 -72
- package/scss/mixins/_grid.scss +0 -60
- package/scss/mixins/_nav-divider.scss +0 -9
- package/scss/mixins/_notification-variant.scss +0 -7
- package/scss/mixins/_object-fit.scss +0 -16
- package/scss/mixins/_reset-text.scss +0 -19
- package/scss/mixins/_text-emphasis.scss +0 -21
- package/scss/mixins/_text-hide.scss +0 -10
- package/scss/mixins/_text-truncate.scss +0 -81
- package/scss/mixins/_visibility.scss +0 -7
- package/scss/project.sublime-workspace +0 -491
- package/scss/utilities/_align.scss +0 -41
- package/scss/utilities/_animate.scss +0 -3512
- package/scss/utilities/_background.scss +0 -14
- package/scss/utilities/_borders.scss +0 -146
- package/scss/utilities/_clearfix.scss +0 -6
- package/scss/utilities/_collapse.scss +0 -33
- package/scss/utilities/_cursor.scss +0 -22
- package/scss/utilities/_display.scss +0 -16
- package/scss/utilities/_embed.scss +0 -78
- package/scss/utilities/_flex.scss +0 -52
- package/scss/utilities/_lazyload.scss +0 -31
- package/scss/utilities/_overflow.scss +0 -6
- package/scss/utilities/_perfect-scrollbar.scss +0 -141
- package/scss/utilities/_placeholder.scss +0 -77
- package/scss/utilities/_position.scss +0 -30
- package/scss/utilities/_sizing.scss +0 -32
- package/scss/utilities/_spacing.scss +0 -92
- package/scss/utilities/_text.scss +0 -99
- package/scss/utilities/_user-select.scss +0 -14
- package/scss/utilities/_visibility.scss +0 -10
package/js/src/toast.js
DELETED
|
@@ -1,581 +0,0 @@
|
|
|
1
|
-
import 'jquery';
|
|
2
|
-
import { debounce } from './util/index';
|
|
3
|
-
import AbstractUIComponent from './abstract-ui-component';
|
|
4
|
-
|
|
5
|
-
const NAME = 'coolToast';
|
|
6
|
-
const DATA_KEY = 'plugin_coolToast';
|
|
7
|
-
|
|
8
|
-
class Toast {
|
|
9
|
-
|
|
10
|
-
constructor(container, opts) {
|
|
11
|
-
|
|
12
|
-
this.settings = {};
|
|
13
|
-
|
|
14
|
-
if (window.Cool.settings.toast) {
|
|
15
|
-
|
|
16
|
-
$.extend(true, this.settings, $.fn[NAME].defaults, window.Cool.settings.toast, opts);
|
|
17
|
-
|
|
18
|
-
} else {
|
|
19
|
-
|
|
20
|
-
$.extend(true, this.settings, $.fn[NAME].defaults, opts);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
this.container = container;
|
|
24
|
-
this.$container = $(this.container);
|
|
25
|
-
this.debug = this.settings.debug;
|
|
26
|
-
this.faPro = this.settings.faPro;
|
|
27
|
-
this.toasts = [];
|
|
28
|
-
this.queue = [];
|
|
29
|
-
this.processingQueue = false;
|
|
30
|
-
this.onInitialize = this.settings.onInitialize;
|
|
31
|
-
this.onDestroy = this.settings.onDestroy;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
// Add item to queue
|
|
35
|
-
addQueue(toast) {
|
|
36
|
-
|
|
37
|
-
this.queue.push(toast);
|
|
38
|
-
|
|
39
|
-
if (this.processingQueue) {
|
|
40
|
-
return;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
return this.processQueue();
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
// Process queue
|
|
47
|
-
processQueue() {
|
|
48
|
-
|
|
49
|
-
if (this.processingQueue) {
|
|
50
|
-
|
|
51
|
-
this.queue.shift();
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
if (!this.queue.length) {
|
|
55
|
-
|
|
56
|
-
this.processingQueue = false;
|
|
57
|
-
return;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
this.processingQueue = true;
|
|
61
|
-
|
|
62
|
-
return this.show(this.queue[0]);
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
// Init toast
|
|
66
|
-
init(opts) {
|
|
67
|
-
|
|
68
|
-
let settings = {};
|
|
69
|
-
|
|
70
|
-
$.extend(true, settings, this.settings, opts);
|
|
71
|
-
|
|
72
|
-
let toast = this.buildToast(settings);
|
|
73
|
-
|
|
74
|
-
this.addQueue(toast);
|
|
75
|
-
this.onInit(toast);
|
|
76
|
-
|
|
77
|
-
return toast;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
// Remove plugin instance completely
|
|
81
|
-
destroy() {
|
|
82
|
-
|
|
83
|
-
this.$container.removeData(DATA_KEY);
|
|
84
|
-
this.onDestroy();
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
// Build toast
|
|
88
|
-
buildToast(settings) {
|
|
89
|
-
|
|
90
|
-
let toast = {
|
|
91
|
-
uuid: 'toast-'+this.generateUUID(),
|
|
92
|
-
placement: settings.placement,
|
|
93
|
-
placementX: settings.placementX,
|
|
94
|
-
placementY: settings.placementY,
|
|
95
|
-
offset: settings.offset,
|
|
96
|
-
animation: settings.animation,
|
|
97
|
-
animationIn: settings.animationIn,
|
|
98
|
-
animationOut: settings.animationOut,
|
|
99
|
-
animationSpeed: settings.animationSpeed,
|
|
100
|
-
dismiss: settings.dismiss,
|
|
101
|
-
size: settings.size,
|
|
102
|
-
header: settings.header,
|
|
103
|
-
theme: settings.theme,
|
|
104
|
-
title: settings.title,
|
|
105
|
-
content: settings.content,
|
|
106
|
-
template: settings.template,
|
|
107
|
-
maxBodyHeight: settings.maxBodyHeight,
|
|
108
|
-
onInit: settings.onInit,
|
|
109
|
-
onShow: settings.onShow,
|
|
110
|
-
onClose: settings.onClose
|
|
111
|
-
};
|
|
112
|
-
|
|
113
|
-
if (typeof toast.content === 'function') {
|
|
114
|
-
|
|
115
|
-
toast.$el = $(toast.template());
|
|
116
|
-
|
|
117
|
-
} else {
|
|
118
|
-
|
|
119
|
-
toast.$el = $(this._renderTemplate(toast));
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
toast.$inner = toast.$el.find('.toast-inner');
|
|
123
|
-
toast.$closeBtn = toast.$el.find('[data-toast-close]');
|
|
124
|
-
|
|
125
|
-
this.log(toast);
|
|
126
|
-
this.toasts.push(toast);
|
|
127
|
-
|
|
128
|
-
return toast;
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
// Bind events that trigger methods
|
|
132
|
-
bindEvents(toast) {
|
|
133
|
-
|
|
134
|
-
let self = this;
|
|
135
|
-
|
|
136
|
-
toast.$el.on('click', '[data-toast-close]', () => {
|
|
137
|
-
|
|
138
|
-
if (toast.$el) {
|
|
139
|
-
self.close(toast);
|
|
140
|
-
}
|
|
141
|
-
});
|
|
142
|
-
|
|
143
|
-
$(window).on('resize', debounce(() => {
|
|
144
|
-
|
|
145
|
-
if (toast.$el) {
|
|
146
|
-
this.setPosition(toast);
|
|
147
|
-
}
|
|
148
|
-
}, 250));
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
// Generate UUID
|
|
152
|
-
generateUUID() {
|
|
153
|
-
|
|
154
|
-
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
|
|
155
|
-
let r = Math.random() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8);
|
|
156
|
-
return v.toString(16);
|
|
157
|
-
});
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
// Set positions
|
|
161
|
-
setPosition(toast, placement, placementY, placementX) {
|
|
162
|
-
|
|
163
|
-
if (typeof placementY === 'undefined' || placementY === null) {
|
|
164
|
-
placementY = toast.placementY;
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
if (typeof placementX === 'undefined' || placementX === null) {
|
|
168
|
-
placementX = toast.placementX;
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
if (!placementX || !placementY) {
|
|
172
|
-
placement = toast.placement
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
if (toast.offset) {
|
|
176
|
-
|
|
177
|
-
let offsets = toast.offset.split(',')
|
|
178
|
-
let offsetX = parseInt(offsets[0], 10);
|
|
179
|
-
let offsetY = parseInt(offsets[1], 10);
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
let toastWidth = toast.$el.outerWidth(true);
|
|
183
|
-
let toastHeight = toast.$el.outerHeight(true);
|
|
184
|
-
let toastPosX;
|
|
185
|
-
let toastPosY;
|
|
186
|
-
|
|
187
|
-
if (placement) {
|
|
188
|
-
|
|
189
|
-
if (placement === 'top-left') {
|
|
190
|
-
|
|
191
|
-
toastPosX = 0;
|
|
192
|
-
toastPosY = 0;
|
|
193
|
-
|
|
194
|
-
if (toast.offset) {
|
|
195
|
-
toastPosX += offsetX;
|
|
196
|
-
toastPosY += offsetY;
|
|
197
|
-
} else {
|
|
198
|
-
toastPosX += 30;
|
|
199
|
-
toastPosY += 30;
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
} else if (placement === 'top-center') {
|
|
203
|
-
|
|
204
|
-
toastPosX = (this.$container.width() / 2) - toastWidth / 2;
|
|
205
|
-
toastPosY = 0;
|
|
206
|
-
|
|
207
|
-
this.log(this.$container.width);
|
|
208
|
-
|
|
209
|
-
if (toast.offset) {
|
|
210
|
-
toastPosX += offsetX;
|
|
211
|
-
toastPosY += offsetY;
|
|
212
|
-
} else {
|
|
213
|
-
toastPosY += 30;
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
} else if (placement === 'top-right') {
|
|
217
|
-
|
|
218
|
-
toastPosX = this.$container.width() - toastWidth;
|
|
219
|
-
toastPosY = 0;
|
|
220
|
-
|
|
221
|
-
if (toast.offset) {
|
|
222
|
-
toastPosX += -offsetX;
|
|
223
|
-
toastPosY += offsetY;
|
|
224
|
-
} else {
|
|
225
|
-
toastPosX += -30;
|
|
226
|
-
toastPosY += 30;
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
} else if (placement === 'center-left') {
|
|
230
|
-
|
|
231
|
-
toastPosX = 0;
|
|
232
|
-
toastPosY = (this.$container.height() / 2) - toastHeight / 2;
|
|
233
|
-
|
|
234
|
-
if (toast.offset) {
|
|
235
|
-
toastPosX += offsetX;
|
|
236
|
-
toastPosY += offsetY;
|
|
237
|
-
} else {
|
|
238
|
-
toastPosX += 30;
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
} else if (placement === 'center-center') {
|
|
242
|
-
|
|
243
|
-
toastPosX = (this.$container.width() / 2) - toastWidth / 2;
|
|
244
|
-
toastPosY = (this.$container.height() / 2) - toastHeight / 2;
|
|
245
|
-
|
|
246
|
-
if (toast.offset) {
|
|
247
|
-
toastPosX += offsetX;
|
|
248
|
-
toastPosY += offsetY;
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
} else if (placement === 'center-right') {
|
|
252
|
-
|
|
253
|
-
toastPosX = this.$container.width() - toastWidth;
|
|
254
|
-
toastPosY = (this.$container.height() / 2) - toastHeight / 2;
|
|
255
|
-
|
|
256
|
-
if (toast.offset) {
|
|
257
|
-
toastPosX += -offsetX;
|
|
258
|
-
toastPosY += offsetY;
|
|
259
|
-
} else {
|
|
260
|
-
toastPosX += -30;
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
} else if (placement === 'bottom-left') {
|
|
264
|
-
|
|
265
|
-
toastPosX = 0;
|
|
266
|
-
toastPosY = this.$container.height() - toastHeight;
|
|
267
|
-
|
|
268
|
-
if (toast.offset) {
|
|
269
|
-
toastPosX += offsetX;
|
|
270
|
-
toastPosY += -offsetY;
|
|
271
|
-
} else {
|
|
272
|
-
toastPosX += 30;
|
|
273
|
-
toastPosY += -30;
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
} else if (placement === 'bottom-center') {
|
|
277
|
-
|
|
278
|
-
toastPosX = (this.$container.width() / 2) - toastWidth / 2;
|
|
279
|
-
toastPosY = this.$container.height() - toastHeight;
|
|
280
|
-
|
|
281
|
-
if (toast.offset) {
|
|
282
|
-
toastPosX += offsetX;
|
|
283
|
-
toastPosY += -offsetY;
|
|
284
|
-
} else {
|
|
285
|
-
toastPosY += -30;
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
} else if (placement === 'bottom-right') {
|
|
289
|
-
|
|
290
|
-
toastPosX = this.$container.width() - toastWidth
|
|
291
|
-
toastPosY = this.$container.height() - toastHeight;
|
|
292
|
-
|
|
293
|
-
if (toast.offset) {
|
|
294
|
-
toastPosX += -offsetX;
|
|
295
|
-
toastPosY += -offsetY;
|
|
296
|
-
} else {
|
|
297
|
-
toastPosX += -30;
|
|
298
|
-
toastPosY += -30;
|
|
299
|
-
}
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
} else {
|
|
303
|
-
|
|
304
|
-
toastPosX = placementX;
|
|
305
|
-
toastPosY = placementY;
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
toast.$el.css({
|
|
309
|
-
position: 'absolute',
|
|
310
|
-
top: '0px',
|
|
311
|
-
left: '0px',
|
|
312
|
-
transform: 'translate3d('+toastPosX+'px, '+toastPosY+'px, 0px)',
|
|
313
|
-
'will-change': 'transform'
|
|
314
|
-
});
|
|
315
|
-
|
|
316
|
-
this.log('Toast width: '+toastWidth+'px');
|
|
317
|
-
this.log('Toast height: '+toastHeight+'px');
|
|
318
|
-
this.log('Toast position Y: '+toastPosX+'px');
|
|
319
|
-
this.log('Toast position x: '+toastPosY+'px');
|
|
320
|
-
}
|
|
321
|
-
|
|
322
|
-
// Show
|
|
323
|
-
show(toast) {
|
|
324
|
-
|
|
325
|
-
this.$container.append(toast.$el);
|
|
326
|
-
this.bindEvents(toast);
|
|
327
|
-
this.setPosition(toast);
|
|
328
|
-
|
|
329
|
-
if (toast.animation) {
|
|
330
|
-
|
|
331
|
-
toast.$el.addClass('show');
|
|
332
|
-
toast.$inner.addClass(toast.animationSpeed);
|
|
333
|
-
toast.$inner.animateCss(toast.animationIn);
|
|
334
|
-
|
|
335
|
-
} else {
|
|
336
|
-
|
|
337
|
-
toast.$el.addClass('show');
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
if (toast.dismiss) {
|
|
341
|
-
|
|
342
|
-
setTimeout(() => {
|
|
343
|
-
this.close(toast);
|
|
344
|
-
}, toast.dismiss * 1000);
|
|
345
|
-
}
|
|
346
|
-
|
|
347
|
-
this.onShow(toast);
|
|
348
|
-
}
|
|
349
|
-
|
|
350
|
-
// Close
|
|
351
|
-
close(toast) {
|
|
352
|
-
|
|
353
|
-
if (toast.animation && !toast.$inner.hasClass('animated')) {
|
|
354
|
-
|
|
355
|
-
toast.$el.removeClass('show');
|
|
356
|
-
toast.$inner.animateCss(toast.animationOut, () => {
|
|
357
|
-
|
|
358
|
-
toast.$el.remove();
|
|
359
|
-
|
|
360
|
-
this.toasts = $.grep(this.toasts, function(item) {
|
|
361
|
-
return item.uuid != toast.uuid;
|
|
362
|
-
});
|
|
363
|
-
|
|
364
|
-
this.processQueue();
|
|
365
|
-
this.onClose(toast);
|
|
366
|
-
});
|
|
367
|
-
|
|
368
|
-
} else {
|
|
369
|
-
|
|
370
|
-
toast.$el.remove();
|
|
371
|
-
|
|
372
|
-
this.toasts = $.grep(this.toasts, function(item) {
|
|
373
|
-
return item.uuid != toast.uuid;
|
|
374
|
-
});
|
|
375
|
-
|
|
376
|
-
this.processQueue();
|
|
377
|
-
this.onClose(toast);
|
|
378
|
-
}
|
|
379
|
-
}
|
|
380
|
-
|
|
381
|
-
// Initialize callback
|
|
382
|
-
onInitialize() {
|
|
383
|
-
|
|
384
|
-
let onInitialize = this.onInitialize;
|
|
385
|
-
|
|
386
|
-
if (typeof onInitialize === 'function') {
|
|
387
|
-
|
|
388
|
-
onInitialize.call(this.container);
|
|
389
|
-
}
|
|
390
|
-
}
|
|
391
|
-
|
|
392
|
-
// Destroy callback
|
|
393
|
-
onDestroy() {
|
|
394
|
-
|
|
395
|
-
let onDestroy = this.onDestroy;
|
|
396
|
-
|
|
397
|
-
if (typeof onDestroy === 'function') {
|
|
398
|
-
|
|
399
|
-
onDestroy.call(this.container);
|
|
400
|
-
}
|
|
401
|
-
}
|
|
402
|
-
|
|
403
|
-
// Init callback
|
|
404
|
-
onInit(toast) {
|
|
405
|
-
|
|
406
|
-
let onInit = toast.onInit;
|
|
407
|
-
|
|
408
|
-
if (typeof onInit === 'function') {
|
|
409
|
-
|
|
410
|
-
onInit.call(toast);
|
|
411
|
-
}
|
|
412
|
-
}
|
|
413
|
-
|
|
414
|
-
// Show callback
|
|
415
|
-
onShow(toast) {
|
|
416
|
-
|
|
417
|
-
let onShow = toast.onShow;
|
|
418
|
-
|
|
419
|
-
if (typeof onShow === 'function') {
|
|
420
|
-
|
|
421
|
-
onShow.call(toast);
|
|
422
|
-
}
|
|
423
|
-
}
|
|
424
|
-
|
|
425
|
-
// Close callback
|
|
426
|
-
onClose(toast) {
|
|
427
|
-
|
|
428
|
-
let onClose = toast.onClose;
|
|
429
|
-
|
|
430
|
-
if (typeof onClose === 'function') {
|
|
431
|
-
|
|
432
|
-
onClose.call(toast);
|
|
433
|
-
}
|
|
434
|
-
}
|
|
435
|
-
|
|
436
|
-
// Debug log
|
|
437
|
-
log(...args) {
|
|
438
|
-
|
|
439
|
-
if (this.debug) {
|
|
440
|
-
|
|
441
|
-
if (typeof this.debug === 'function') {
|
|
442
|
-
this.debug(...args);
|
|
443
|
-
} else {
|
|
444
|
-
console.log(...args);
|
|
445
|
-
}
|
|
446
|
-
}
|
|
447
|
-
}
|
|
448
|
-
|
|
449
|
-
// Render template
|
|
450
|
-
_renderTemplate(toast) {
|
|
451
|
-
|
|
452
|
-
let faNameSpace = this.faPro ? 'far' : 'fas';
|
|
453
|
-
let content = '';
|
|
454
|
-
let header = '';
|
|
455
|
-
let body = '';
|
|
456
|
-
let bodyCloseBtn = '';
|
|
457
|
-
|
|
458
|
-
if (typeof toast.content === 'function') {
|
|
459
|
-
|
|
460
|
-
content = toast.content();
|
|
461
|
-
|
|
462
|
-
} else {
|
|
463
|
-
|
|
464
|
-
content = toast.content;
|
|
465
|
-
}
|
|
466
|
-
|
|
467
|
-
if (toast.header) {
|
|
468
|
-
|
|
469
|
-
header = `
|
|
470
|
-
<div class="toast-header">
|
|
471
|
-
|
|
472
|
-
<span>${toast.title}</span>
|
|
473
|
-
|
|
474
|
-
<button type="button" data-toast-close>
|
|
475
|
-
<i class="${faNameSpace} fa-times icon"></i>
|
|
476
|
-
</button>
|
|
477
|
-
|
|
478
|
-
</div>
|
|
479
|
-
`;
|
|
480
|
-
|
|
481
|
-
} else {
|
|
482
|
-
|
|
483
|
-
bodyCloseBtn = `
|
|
484
|
-
<button type="button" data-toast-close>
|
|
485
|
-
|
|
486
|
-
<i class="${faNameSpace} fa-times icon"></i>
|
|
487
|
-
|
|
488
|
-
</button>
|
|
489
|
-
`;
|
|
490
|
-
}
|
|
491
|
-
|
|
492
|
-
body = `
|
|
493
|
-
<div class="toast-body">
|
|
494
|
-
|
|
495
|
-
<span>${content}</span>
|
|
496
|
-
${bodyCloseBtn}
|
|
497
|
-
|
|
498
|
-
</div>
|
|
499
|
-
`;
|
|
500
|
-
|
|
501
|
-
return `
|
|
502
|
-
<div class="toast toast-${toast.size} toast-${toast.theme}" role="alert" id="${toast.uuid}">
|
|
503
|
-
|
|
504
|
-
<div class="toast-inner">
|
|
505
|
-
|
|
506
|
-
${header}
|
|
507
|
-
${body}
|
|
508
|
-
|
|
509
|
-
</div>
|
|
510
|
-
|
|
511
|
-
</div>
|
|
512
|
-
`;
|
|
513
|
-
}
|
|
514
|
-
|
|
515
|
-
static _jQueryInterface(config) {
|
|
516
|
-
|
|
517
|
-
return this.each(function() {
|
|
518
|
-
|
|
519
|
-
let data = $(this).data(DATA_KEY);
|
|
520
|
-
const _config = typeof config === 'object' && config;
|
|
521
|
-
|
|
522
|
-
if (!data) {
|
|
523
|
-
data = new Toast(this, _config);
|
|
524
|
-
$(this).data(DATA_KEY, data);
|
|
525
|
-
}
|
|
526
|
-
|
|
527
|
-
if (typeof config === 'string') {
|
|
528
|
-
|
|
529
|
-
if (typeof data[config] === 'undefined') {
|
|
530
|
-
throw new TypeError(`No method named "${config}"`)
|
|
531
|
-
}
|
|
532
|
-
|
|
533
|
-
data[config]()
|
|
534
|
-
}
|
|
535
|
-
});
|
|
536
|
-
}
|
|
537
|
-
}
|
|
538
|
-
|
|
539
|
-
if (typeof $ !== 'undefined') {
|
|
540
|
-
|
|
541
|
-
// jQuery
|
|
542
|
-
const JQUERY_NO_CONFLICT = $.fn[NAME];
|
|
543
|
-
|
|
544
|
-
$.fn[NAME] = Toast._jQueryInterface;
|
|
545
|
-
$.fn[NAME].Constructor = Toast;
|
|
546
|
-
|
|
547
|
-
$.fn[NAME].noConflict = () => {
|
|
548
|
-
|
|
549
|
-
$.fn[NAME] = JQUERY_NO_CONFLICT;
|
|
550
|
-
|
|
551
|
-
return Toast._jQueryInterface;
|
|
552
|
-
}
|
|
553
|
-
|
|
554
|
-
$.fn[NAME].defaults = {
|
|
555
|
-
title: '',
|
|
556
|
-
content: '',
|
|
557
|
-
template: '',
|
|
558
|
-
theme: 'dark',
|
|
559
|
-
placement: 'bottom-center',
|
|
560
|
-
placementX: null,
|
|
561
|
-
placementY: null,
|
|
562
|
-
animation: true,
|
|
563
|
-
animationIn: 'slideInUp',
|
|
564
|
-
animationOut: 'slideOutDown',
|
|
565
|
-
animationSpeed: 'faster',
|
|
566
|
-
offset: null,
|
|
567
|
-
size: null,
|
|
568
|
-
dismiss: 3,
|
|
569
|
-
header: false,
|
|
570
|
-
faPro: false,
|
|
571
|
-
debug: false,
|
|
572
|
-
onInitialize: null,
|
|
573
|
-
onDestroy: null,
|
|
574
|
-
onInit: null,
|
|
575
|
-
onDestroy: null,
|
|
576
|
-
onShow: null,
|
|
577
|
-
onClose: null
|
|
578
|
-
}
|
|
579
|
-
}
|
|
580
|
-
|
|
581
|
-
export default Toast;
|