-
Notifications
You must be signed in to change notification settings - Fork 111
Expand file tree
/
Copy pathcreate-modal.plugin.js
More file actions
48 lines (43 loc) · 1.39 KB
/
create-modal.plugin.js
File metadata and controls
48 lines (43 loc) · 1.39 KB
1
2
3
4
5
6
7
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import $ from 'external/jquery';
import AtkPlugin from './atk.plugin';
export default class AtkCreateModalPlugin extends AtkPlugin {
main() {
const options = this.settings;
// make sure we have an object when no option is passed
if ($.isArray(options.urlOptions)) {
options.urlOptions = {};
}
// create modal and add it to the DOM
const $m = $('<div class="atk-modal ui modal" />')
.appendTo('body')
.html(this.getDialogHtml(options.title));
// add setting to our modal for modalService
$m.data({
url: options.url,
type: options.dataType,
args: options.urlOptions,
needRemove: true,
loadingLabel: options.loadingLabel,
});
// call Fomantic-UI modal
$m.modal(options.modal).modal('show');
$m.addClass(this.settings.modalCss);
}
getDialogHtml(title) {
return `<i class="close icon"></i>
` + (title ? `<div class="${this.settings.headerCss}">${title}</div>
` : '') + `<div class="${this.settings.contentCss} content atk-dialog-content">
</div>
</div>`;
}
}
AtkCreateModalPlugin.DEFAULTS = {
title: '',
url: null,
urlOptions: {},
headerCss: 'header',
modalCss: 'scrolling',
contentCss: 'image',
loadingLabel: 'Loading...',
modal: {},
};