@finqu/cool 1.2.28 → 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 +23510 -16076
- 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 +15397 -3775
- 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 +4281 -3352
- 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 +4283 -3354
- 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 -3704
- 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 -285
- 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/dropdown-test.html +0 -200
- package/html/index.html +0 -2704
- package/js/dist/collapse.js +0 -5290
- package/js/dist/collapse.js.map +0 -1
- package/js/dist/common.js +0 -22152
- 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 -9298
- 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 -37052
- 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 -272
- package/js/src/common.js +0 -313
- package/js/src/dialog.js +0 -578
- package/js/src/dropdown.js +0 -525
- package/js/src/popover.js +0 -621
- package/js/src/section-tabs.js +0 -215
- package/js/src/select.js +0 -1341
- 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 -106
- package/scss/_badge.scss +0 -71
- package/scss/_button-group.scss +0 -129
- package/scss/_buttons.scss +0 -207
- package/scss/_custom-forms.scss +0 -429
- package/scss/_dialog.scss +0 -161
- package/scss/_dropdown.scss +0 -231
- package/scss/_forms.scss +0 -257
- package/scss/_frame.scss +0 -548
- package/scss/_functions.scss +0 -124
- package/scss/_grid.scss +0 -35
- package/scss/_images.scss +0 -362
- package/scss/_input-group.scss +0 -271
- package/scss/_list-group.scss +0 -82
- package/scss/_mixins.scss +0 -34
- package/scss/_navbar.scss +0 -264
- package/scss/_notification.scss +0 -13
- package/scss/_pagination.scss +0 -79
- package/scss/_popover.scss +0 -165
- package/scss/_reboot.scss +0 -283
- package/scss/_root.scss +0 -15
- package/scss/_section.scss +0 -912
- package/scss/_select.scss +0 -175
- package/scss/_tables.scss +0 -716
- package/scss/_tabs.scss +0 -175
- package/scss/_toast.scss +0 -182
- package/scss/_tooltip.scss +0 -101
- package/scss/_type.scss +0 -121
- package/scss/_utilities.scss +0 -23
- package/scss/_variables.scss +0 -699
- 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 -25
- 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 -76
- 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/dialog.js
DELETED
|
@@ -1,578 +0,0 @@
|
|
|
1
|
-
import 'jquery';
|
|
2
|
-
import { debounce, touchEvents } from './util/index';
|
|
3
|
-
|
|
4
|
-
const NAME = 'coolDialog';
|
|
5
|
-
const DATA_KEY = 'plugin_coolDialog';
|
|
6
|
-
|
|
7
|
-
class Dialog {
|
|
8
|
-
|
|
9
|
-
constructor(container, opts) {
|
|
10
|
-
|
|
11
|
-
this.settings = {};
|
|
12
|
-
|
|
13
|
-
if (window.Cool.settings.dialog) {
|
|
14
|
-
|
|
15
|
-
$.extend(true, this.settings, $.fn[NAME].defaults, window.Cool.settings.dialog, opts);
|
|
16
|
-
|
|
17
|
-
} else {
|
|
18
|
-
|
|
19
|
-
$.extend(true, this.settings, $.fn[NAME].defaults, opts);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
this.container = container;
|
|
23
|
-
this.$container = $(this.container);
|
|
24
|
-
this.debug = this.settings.debug;
|
|
25
|
-
this.faPro = this.settings.faPro;
|
|
26
|
-
this.dialogs = [];
|
|
27
|
-
this.onInitialize = this.settings.onInitialize;
|
|
28
|
-
this.onDestroy = this.settings.onDestroy;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
// Init dialog
|
|
32
|
-
init(opts) {
|
|
33
|
-
|
|
34
|
-
let settings = {};
|
|
35
|
-
|
|
36
|
-
$.extend(true, settings, this.settings, opts);
|
|
37
|
-
|
|
38
|
-
let dialog = this.buildDialog(settings);
|
|
39
|
-
|
|
40
|
-
this.show(dialog);
|
|
41
|
-
this.bindEvents(dialog);
|
|
42
|
-
this.onInit(dialog);
|
|
43
|
-
|
|
44
|
-
return dialog;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
// Remove plugin instance completely
|
|
48
|
-
destroy() {
|
|
49
|
-
|
|
50
|
-
this.$container.removeData(DATA_KEY);
|
|
51
|
-
this.onDestroy();
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
// Build dialog
|
|
55
|
-
buildDialog(settings) {
|
|
56
|
-
|
|
57
|
-
let self = this;
|
|
58
|
-
let dialog = {
|
|
59
|
-
uuid: 'dialog-'+this.generateUUID(),
|
|
60
|
-
title: settings.title,
|
|
61
|
-
template: settings.template,
|
|
62
|
-
body: settings.body,
|
|
63
|
-
footer: settings.footer,
|
|
64
|
-
size: settings.size,
|
|
65
|
-
classes: settings.classes,
|
|
66
|
-
centered: settings.centered,
|
|
67
|
-
backdrop: settings.backdrop,
|
|
68
|
-
preventScroll: settings.preventScroll,
|
|
69
|
-
closeBtn: settings.closeBtn,
|
|
70
|
-
animation: settings.animation,
|
|
71
|
-
animationIn: settings.animationIn,
|
|
72
|
-
animationOut: settings.animationOut,
|
|
73
|
-
animationSpeed: settings.animationSpeed,
|
|
74
|
-
callbacks: settings.callbacks,
|
|
75
|
-
maxBodyHeight: settings.maxBodyHeight,
|
|
76
|
-
overflowVisible: settings.overflowVisible,
|
|
77
|
-
actions: settings.actions,
|
|
78
|
-
onInit: settings.onInit,
|
|
79
|
-
onShow: settings.onShow,
|
|
80
|
-
onClose: settings.onClose
|
|
81
|
-
};
|
|
82
|
-
|
|
83
|
-
if (dialog.maxBodyHeight == null) {
|
|
84
|
-
|
|
85
|
-
dialog.maxBodyHeight = window.innerHeight - 200;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
if (typeof dialog.template === 'function') {
|
|
89
|
-
|
|
90
|
-
dialog.$el = $(dialog.template());
|
|
91
|
-
|
|
92
|
-
} else {
|
|
93
|
-
|
|
94
|
-
dialog.$el = $(this._renderTemplate(dialog));
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
dialog.show = function() {
|
|
98
|
-
self.show(dialog);
|
|
99
|
-
};
|
|
100
|
-
|
|
101
|
-
dialog.close = function() {
|
|
102
|
-
self.close(dialog);
|
|
103
|
-
};
|
|
104
|
-
|
|
105
|
-
this.log(dialog);
|
|
106
|
-
this.dialogs.push(dialog);
|
|
107
|
-
|
|
108
|
-
return dialog;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
// Bind events that trigger methods
|
|
112
|
-
bindEvents(dialog) {
|
|
113
|
-
|
|
114
|
-
let self = this;
|
|
115
|
-
|
|
116
|
-
dialog.$el.on('click', '[data-dialog-close]', function (e) {
|
|
117
|
-
|
|
118
|
-
dialog.$el.trigger('dialog.close');
|
|
119
|
-
|
|
120
|
-
if (typeof dialog.callbacks.close === 'function') {
|
|
121
|
-
|
|
122
|
-
dialog.callbacks.close.call(self, function () {
|
|
123
|
-
self.close(dialog)
|
|
124
|
-
}, dialog);
|
|
125
|
-
|
|
126
|
-
} else {
|
|
127
|
-
|
|
128
|
-
self.close(dialog);
|
|
129
|
-
}
|
|
130
|
-
});
|
|
131
|
-
|
|
132
|
-
dialog.$el.on('click', '[data-dialog-remove]', function (e) {
|
|
133
|
-
|
|
134
|
-
dialog.$el.trigger('dialog.remove');
|
|
135
|
-
|
|
136
|
-
if (typeof dialog.callbacks.remove === 'function') {
|
|
137
|
-
|
|
138
|
-
dialog.callbacks.remove.call(self, function () {
|
|
139
|
-
self.close(dialog)
|
|
140
|
-
}, dialog);
|
|
141
|
-
}
|
|
142
|
-
});
|
|
143
|
-
|
|
144
|
-
dialog.$el.on('click', '[data-dialog-confirm]', debounce(function (e) {
|
|
145
|
-
|
|
146
|
-
dialog.$el.trigger('dialog.close');
|
|
147
|
-
|
|
148
|
-
if (typeof dialog.callbacks.confirm === 'function') {
|
|
149
|
-
|
|
150
|
-
dialog.callbacks.confirm.call(self, function () {
|
|
151
|
-
self.close(dialog)
|
|
152
|
-
}, dialog);
|
|
153
|
-
|
|
154
|
-
} else {
|
|
155
|
-
|
|
156
|
-
self.close(dialog);
|
|
157
|
-
}
|
|
158
|
-
}));
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
// Generate UUID
|
|
162
|
-
generateUUID() {
|
|
163
|
-
|
|
164
|
-
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
|
|
165
|
-
let r = Math.random() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8);
|
|
166
|
-
return v.toString(16);
|
|
167
|
-
});
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
// Show
|
|
171
|
-
show(dialog) {
|
|
172
|
-
|
|
173
|
-
if (!this.$container.hasClass('has-dialogs')) {
|
|
174
|
-
this.$container.addClass('has-dialogs');
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
if (dialog.preventScroll && !this.$container.hasClass('dialog-prevent-scroll')) {
|
|
178
|
-
this.$container.addClass('dialog-prevent-scroll');
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
if (this.dialogs.length > 1) {
|
|
182
|
-
|
|
183
|
-
let $prevDialog = $(this.dialogs).eq(-2)[0].$el;
|
|
184
|
-
let zIndex = parseInt($prevDialog.css('z-index'), 10) + 1;
|
|
185
|
-
|
|
186
|
-
dialog.$el.css('z-index', zIndex);
|
|
187
|
-
|
|
188
|
-
$prevDialog.css({
|
|
189
|
-
'transition': 'opacity 0.3s',
|
|
190
|
-
'opacity': 0,
|
|
191
|
-
'visibility': 'visible'
|
|
192
|
-
});
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
if (dialog.backdrop && $('.dialog-backdrop').length < 1) {
|
|
196
|
-
|
|
197
|
-
this.$container.append('<div class="dialog-backdrop"></div>');
|
|
198
|
-
|
|
199
|
-
let checkForBackdrop = setInterval(() => {
|
|
200
|
-
|
|
201
|
-
if (this.dialogs.length == 0 && $('.dialog-backdrop').length) {
|
|
202
|
-
|
|
203
|
-
$('.dialog-backdrop').remove();
|
|
204
|
-
clearInterval(checkForBackdrop);
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
}, 100);
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
this.$container.append(dialog.$el);
|
|
211
|
-
|
|
212
|
-
if (dialog.animation) {
|
|
213
|
-
dialog.$el.find('.dialog-content').addClass(dialog.animationSpeed).animateCss(dialog.animationIn);
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
this.onShow(dialog);
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
// Close
|
|
220
|
-
close(dialog) {
|
|
221
|
-
|
|
222
|
-
let $prevDialog = null;
|
|
223
|
-
|
|
224
|
-
if (this.dialogs.length > 1) {
|
|
225
|
-
$prevDialog = $(this.dialogs).eq(-2)[0].$el;
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
if ($('.dialog[data-dialog-backdrop="true"]').length === 0 && $('.dialog-backdrop').length) {
|
|
229
|
-
$('.dialog-backdrop').remove();
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
if (dialog.animation) {
|
|
233
|
-
|
|
234
|
-
dialog.$el.find('.dialog-content').animateCss(dialog.animationOut, () => {
|
|
235
|
-
|
|
236
|
-
dialog.$el.remove();
|
|
237
|
-
|
|
238
|
-
this.dialogs = $.grep(this.dialogs, function(item) {
|
|
239
|
-
return item.uuid != dialog.uuid;
|
|
240
|
-
});
|
|
241
|
-
|
|
242
|
-
if (this.dialogs.length == 0) {
|
|
243
|
-
|
|
244
|
-
this.$container.removeClass('has-dialogs');
|
|
245
|
-
|
|
246
|
-
if (this.$container.hasClass('dialog-prevent-scroll')) {
|
|
247
|
-
this.$container.removeClass('dialog-prevent-scroll');
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
} else {
|
|
251
|
-
|
|
252
|
-
if ($prevDialog) {
|
|
253
|
-
$prevDialog.css('opacity', 1);
|
|
254
|
-
}
|
|
255
|
-
}
|
|
256
|
-
});
|
|
257
|
-
|
|
258
|
-
} else {
|
|
259
|
-
|
|
260
|
-
dialog.$el.remove();
|
|
261
|
-
|
|
262
|
-
this.dialogs = $.grep(this.dialogs, function(item) {
|
|
263
|
-
return item.uuid != dialog.uuid;
|
|
264
|
-
});
|
|
265
|
-
|
|
266
|
-
if (this.dialogs.length == 0) {
|
|
267
|
-
|
|
268
|
-
this.$container.removeClass('has-dialogs');
|
|
269
|
-
|
|
270
|
-
if (this.$container.hasClass('dialog-prevent-scroll')) {
|
|
271
|
-
this.$container.removeClass('dialog-prevent-scroll');
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
} else {
|
|
275
|
-
|
|
276
|
-
if ($prevDialog) {
|
|
277
|
-
$prevDialog.css('opacity', 1);
|
|
278
|
-
}
|
|
279
|
-
}
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
this.onClose(dialog);
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
// Initialize callback
|
|
286
|
-
onInitialize() {
|
|
287
|
-
|
|
288
|
-
let onInitialize = this.onInitialize;
|
|
289
|
-
|
|
290
|
-
if (typeof onInitialize === 'function') {
|
|
291
|
-
|
|
292
|
-
onInitialize.call(this.container);
|
|
293
|
-
}
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
// Destroy callback
|
|
297
|
-
onDestroy() {
|
|
298
|
-
|
|
299
|
-
let onDestroy = this.onDestroy;
|
|
300
|
-
|
|
301
|
-
if (typeof onDestroy === 'function') {
|
|
302
|
-
|
|
303
|
-
onDestroy.call(this.container);
|
|
304
|
-
}
|
|
305
|
-
}
|
|
306
|
-
|
|
307
|
-
// Init callback
|
|
308
|
-
onInit(dialog) {
|
|
309
|
-
|
|
310
|
-
let onInit = dialog.onInit;
|
|
311
|
-
|
|
312
|
-
if (typeof onInit === 'function') {
|
|
313
|
-
|
|
314
|
-
onInit.call(dialog);
|
|
315
|
-
}
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
// Show callback
|
|
319
|
-
onShow(dialog) {
|
|
320
|
-
|
|
321
|
-
let onShow = dialog.onShow;
|
|
322
|
-
|
|
323
|
-
if (typeof onShow === 'function') {
|
|
324
|
-
|
|
325
|
-
onShow.call(dialog);
|
|
326
|
-
}
|
|
327
|
-
}
|
|
328
|
-
|
|
329
|
-
// Close callback
|
|
330
|
-
onClose(dialog) {
|
|
331
|
-
|
|
332
|
-
let onClose = dialog.onClose;
|
|
333
|
-
|
|
334
|
-
if (typeof onClose === 'function') {
|
|
335
|
-
|
|
336
|
-
onClose.call(dialog);
|
|
337
|
-
}
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
// Debug log
|
|
341
|
-
log(...args) {
|
|
342
|
-
|
|
343
|
-
if (this.debug) {
|
|
344
|
-
|
|
345
|
-
if (typeof this.debug === 'function') {
|
|
346
|
-
this.debug(...args);
|
|
347
|
-
} else {
|
|
348
|
-
console.log(...args);
|
|
349
|
-
}
|
|
350
|
-
}
|
|
351
|
-
}
|
|
352
|
-
|
|
353
|
-
// Render footer
|
|
354
|
-
_renderFooter(dialog) {
|
|
355
|
-
|
|
356
|
-
let footer = '';
|
|
357
|
-
|
|
358
|
-
if (typeof dialog.footer === 'function') {
|
|
359
|
-
|
|
360
|
-
footer = dialog.footer();
|
|
361
|
-
|
|
362
|
-
} else if (dialog.footer !== '' && dialog.footer !== false && dialog.footer !== true) {
|
|
363
|
-
|
|
364
|
-
footer = dialog.footer;
|
|
365
|
-
|
|
366
|
-
} else if (dialog.footer === true) {
|
|
367
|
-
|
|
368
|
-
let btnCancel = '';
|
|
369
|
-
let btnRemove = '';
|
|
370
|
-
let btnConfirm = '';
|
|
371
|
-
let btnStyle = '';
|
|
372
|
-
let btnClasses = '';
|
|
373
|
-
let btnAttrs = '';
|
|
374
|
-
|
|
375
|
-
if (dialog.actions.close.visible) {
|
|
376
|
-
|
|
377
|
-
btnStyle = dialog.actions.close.primary ? 'btn-primary' : 'btn-secondary';
|
|
378
|
-
btnClasses = dialog.actions.close.classes ? ' '+dialog.actions.close.classes : '';
|
|
379
|
-
btnAttrs = dialog.actions.close.attrs ? ' '+dialog.actions.close.attrs : '';
|
|
380
|
-
btnCancel = `
|
|
381
|
-
<button type="button" class="btn ${btnStyle}${btnClasses}"${btnAttrs} data-dialog-close>
|
|
382
|
-
${dialog.actions.close.content}
|
|
383
|
-
</button>
|
|
384
|
-
`;
|
|
385
|
-
}
|
|
386
|
-
|
|
387
|
-
if (dialog.actions.remove.visible) {
|
|
388
|
-
|
|
389
|
-
btnStyle = dialog.actions.remove.primary ? 'btn-primary' : 'btn-secondary';
|
|
390
|
-
btnClasses = dialog.actions.remove.classes ? ' '+dialog.actions.remove.classes : '';
|
|
391
|
-
btnAttrs = dialog.actions.remove.attrs ? ' '+dialog.actions.remove.attrs : '';
|
|
392
|
-
btnRemove = `
|
|
393
|
-
<button type="button" class="btn ${btnStyle}${btnClasses}"${btnAttrs} data-dialog-remove>
|
|
394
|
-
${dialog.actions.remove.content}
|
|
395
|
-
</button>
|
|
396
|
-
`;
|
|
397
|
-
}
|
|
398
|
-
|
|
399
|
-
if (dialog.actions.confirm.visible) {
|
|
400
|
-
|
|
401
|
-
btnStyle = dialog.actions.confirm.primary ? 'btn-primary' : 'btn-secondary';
|
|
402
|
-
btnClasses = dialog.actions.confirm.classes ? ' '+dialog.actions.confirm.classes : '';
|
|
403
|
-
btnAttrs = dialog.actions.confirm.attrs ? ' '+dialog.actions.confirm.attrs : '';
|
|
404
|
-
btnConfirm = `
|
|
405
|
-
<button type="button" class="btn ${btnStyle}${btnClasses}"${btnAttrs} data-dialog-confirm>
|
|
406
|
-
${dialog.actions.confirm.content}
|
|
407
|
-
</button>
|
|
408
|
-
`;
|
|
409
|
-
}
|
|
410
|
-
|
|
411
|
-
footer = `
|
|
412
|
-
${btnCancel}
|
|
413
|
-
${btnRemove}
|
|
414
|
-
${btnConfirm}
|
|
415
|
-
`;
|
|
416
|
-
|
|
417
|
-
} else {
|
|
418
|
-
|
|
419
|
-
return footer;
|
|
420
|
-
}
|
|
421
|
-
|
|
422
|
-
if (footer) {
|
|
423
|
-
|
|
424
|
-
return `
|
|
425
|
-
<div class="dialog-footer">
|
|
426
|
-
${footer}
|
|
427
|
-
</div>
|
|
428
|
-
`;
|
|
429
|
-
}
|
|
430
|
-
}
|
|
431
|
-
|
|
432
|
-
// Render template
|
|
433
|
-
_renderTemplate(dialog) {
|
|
434
|
-
|
|
435
|
-
let faNameSpace = this.faPro ? 'far' : 'fas';
|
|
436
|
-
let classes = dialog.classes ? ' '+dialog.classes : '';
|
|
437
|
-
let centered = dialog.centered ? ' dialog-centered' : '';
|
|
438
|
-
let size = dialog.size ? ' dialog-'+dialog.size : '';
|
|
439
|
-
let overFlowVisible = dialog.overflowVisible ? ' dialog-overflow-visible' : '';
|
|
440
|
-
let uuid = ' data-dialog-uuid="'+dialog.uuid+'"';
|
|
441
|
-
let backdrop = dialog.backdrop ? ' data-dialog-backdrop="true"' : ' data-dialog-backdrop="false"';
|
|
442
|
-
let title = dialog.title;
|
|
443
|
-
let closeBtn = dialog.closeBtn ? `<button type="button" data-dialog-close><i class="${faNameSpace} fa-times icon"></i></button>` : '';
|
|
444
|
-
let maxBodyHeight = dialog.maxBodyHeight ? ' style="max-height: '+dialog.maxBodyHeight+'px"' : '';
|
|
445
|
-
let body = '';
|
|
446
|
-
let footer = this._renderFooter(dialog);
|
|
447
|
-
|
|
448
|
-
if (typeof dialog.body === 'function') {
|
|
449
|
-
|
|
450
|
-
body = dialog.body();
|
|
451
|
-
|
|
452
|
-
} else {
|
|
453
|
-
|
|
454
|
-
body = dialog.body;
|
|
455
|
-
}
|
|
456
|
-
|
|
457
|
-
return `
|
|
458
|
-
<div class="dialog${classes}${centered}${size}${overFlowVisible}"${uuid}${backdrop}>
|
|
459
|
-
|
|
460
|
-
<div class="dialog-container">
|
|
461
|
-
|
|
462
|
-
<div class="dialog-content">
|
|
463
|
-
|
|
464
|
-
<div class="dialog-header">
|
|
465
|
-
|
|
466
|
-
<span class="dialog-title">
|
|
467
|
-
${title}
|
|
468
|
-
</span>
|
|
469
|
-
|
|
470
|
-
${closeBtn}
|
|
471
|
-
|
|
472
|
-
</div>
|
|
473
|
-
|
|
474
|
-
<div class="dialog-body"${maxBodyHeight}>
|
|
475
|
-
|
|
476
|
-
${body}
|
|
477
|
-
|
|
478
|
-
</div>
|
|
479
|
-
|
|
480
|
-
${footer}
|
|
481
|
-
|
|
482
|
-
</div>
|
|
483
|
-
|
|
484
|
-
</div>
|
|
485
|
-
|
|
486
|
-
</div>
|
|
487
|
-
`;
|
|
488
|
-
}
|
|
489
|
-
|
|
490
|
-
static _jQueryInterface(config) {
|
|
491
|
-
|
|
492
|
-
let data = $(this).data(DATA_KEY);
|
|
493
|
-
const _config = typeof config === 'object' && config;
|
|
494
|
-
|
|
495
|
-
if (!data) {
|
|
496
|
-
data = new Dialog(this, _config);
|
|
497
|
-
$(this).data(DATA_KEY, data);
|
|
498
|
-
}
|
|
499
|
-
|
|
500
|
-
if (typeof config === 'string') {
|
|
501
|
-
|
|
502
|
-
if (typeof data[config] === 'undefined') {
|
|
503
|
-
throw new TypeError(`No method named "${config}"`)
|
|
504
|
-
}
|
|
505
|
-
|
|
506
|
-
data[config]()
|
|
507
|
-
}
|
|
508
|
-
}
|
|
509
|
-
}
|
|
510
|
-
|
|
511
|
-
if (typeof $ !== 'undefined') {
|
|
512
|
-
|
|
513
|
-
// jQuery
|
|
514
|
-
const JQUERY_NO_CONFLICT = $.fn[NAME];
|
|
515
|
-
|
|
516
|
-
$.fn[NAME] = Dialog._jQueryInterface;
|
|
517
|
-
$.fn[NAME].Constructor = Dialog;
|
|
518
|
-
|
|
519
|
-
$.fn[NAME].noConflict = () => {
|
|
520
|
-
|
|
521
|
-
$.fn[NAME] = JQUERY_NO_CONFLICT;
|
|
522
|
-
|
|
523
|
-
return Dialog._jQueryInterface;
|
|
524
|
-
}
|
|
525
|
-
|
|
526
|
-
$.fn[NAME].defaults = {
|
|
527
|
-
title: '',
|
|
528
|
-
template: '',
|
|
529
|
-
body: '',
|
|
530
|
-
footer: true,
|
|
531
|
-
size: '', // sm/lg
|
|
532
|
-
classes: '',
|
|
533
|
-
centered: true,
|
|
534
|
-
backdrop: true,
|
|
535
|
-
preventScroll: true,
|
|
536
|
-
closeBtn: true,
|
|
537
|
-
animation: true,
|
|
538
|
-
animationIn: 'zoomIn',
|
|
539
|
-
animationOut: 'fadeOut',
|
|
540
|
-
animationSpeed: 'fastest',
|
|
541
|
-
callbacks: {},
|
|
542
|
-
maxBodyHeight: null,
|
|
543
|
-
overflowVisible: false,
|
|
544
|
-
faPro: false,
|
|
545
|
-
debug: true,
|
|
546
|
-
onInitialize: null,
|
|
547
|
-
onDestroy: null,
|
|
548
|
-
onInit: null,
|
|
549
|
-
onDestroy: null,
|
|
550
|
-
onShow: null,
|
|
551
|
-
onClose: null,
|
|
552
|
-
actions: {
|
|
553
|
-
close: {
|
|
554
|
-
primary: false,
|
|
555
|
-
visible: true,
|
|
556
|
-
content: 'Close',
|
|
557
|
-
classes: '',
|
|
558
|
-
attrs: ''
|
|
559
|
-
},
|
|
560
|
-
remove: {
|
|
561
|
-
primary: false,
|
|
562
|
-
visible: true,
|
|
563
|
-
content: 'Remove',
|
|
564
|
-
classes: '',
|
|
565
|
-
attrs: ''
|
|
566
|
-
},
|
|
567
|
-
confirm: {
|
|
568
|
-
primary: true,
|
|
569
|
-
visible: true,
|
|
570
|
-
content: 'Confirm',
|
|
571
|
-
classes: '',
|
|
572
|
-
attrs: ''
|
|
573
|
-
}
|
|
574
|
-
}
|
|
575
|
-
}
|
|
576
|
-
}
|
|
577
|
-
|
|
578
|
-
export default Dialog;
|