-
Notifications
You must be signed in to change notification settings - Fork 7
/
dialog.js
47 lines (32 loc) · 921 Bytes
/
dialog.js
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
const { ipcRenderer } = require('electron');
$(document).ready(() => {
let answer = 0;
let $buttons = $('footer .toolbar-actions button');
$buttons.click((ev) => {
let $btn = $(ev.currentTarget);
answer = $btn.data('answer');
ipcRenderer.send('answer-from-dialog', {
answer: answer
});
});
ipcRenderer.on('open-dialog', (event, args) => {
$buttons.hide();
console.log(args);
if(args.title) {
$('#title, title').text(args.title);
}
if(args.message) {
$('#message').text(args.message);
}
if(args.detail) {
$('#detail').text(args.detail);
}
if(args.buttons) {
let i = 0;
args.buttons.forEach((btn) => {
$('#button_' + i).show().text(btn);
i++;
});
}
});
});