-
-
Notifications
You must be signed in to change notification settings - Fork 118
Expand file tree
/
Copy pathAlertModal.js
More file actions
72 lines (63 loc) · 2.3 KB
/
AlertModal.js
File metadata and controls
72 lines (63 loc) · 2.3 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/*
* Project Name : Visual Python
* Description : GUI-based Python code generator
* File Name : AlertModal.js
* Author : Black Logic
* Note : AlertModal
* License : GNU GPLv3 with Visual Python special exception
* Date : 2021. 11. 18
* Change Date :
*/
//============================================================================
// [CLASS] AlertModal
//============================================================================
define([
__VP_TEXT_LOADER__('vp_base/html/component/alertModal.html'), // INTEGRATION: unified version of text loader
__VP_CSS_LOADER__('vp_base/css/component/alertModal'), // INTEGRATION: unified version of css loader
'vp_base/js/com/com_Const',
'vp_base/js/com/component/Component'
], function(msgHtml, msgCss, com_Const, Component) {
/**
* AlertModal
* com_util.renderAlertModal(title, detail);
* - title: string
* - detail: object
* - content: string
* - type: text / code
*/
class AlertModal extends Component {
constructor(title, detail={ content:'', type:'text' }) {
super($('body'), { title: title, detail: detail });
}
_bindEvent() {
let that = this;
// click ok button
$(this.wrapSelector('.vp-alertModal-yes')).click( function() {
that.remove();
});
}
template() {
return msgHtml.replaceAll('${vp_base}', com_Const.BASE_PATH);
}
render() {
super.render();
// set title
$(this.wrapSelector('.vp-alertModal-titleStr')).text(this.state.title);
// set detail
let { content='', type='text' } = this.state.detail;
if (content !== '') {
if (type === 'code') {
$(this.wrapSelector('.vp-alertModal-detailStr')).html('<pre>' + content + '</pre>')
} else {
$(this.wrapSelector('.vp-alertModal-detailStr')).text(content);
}
} else {
$(this.wrapSelector('.vp-alertModal-detailStr')).hide();
}
}
remove() {
$(this.wrapSelector()).remove();
}
}
return AlertModal;
});