1 parent 807d4ee commit 2d18292Copy full SHA for 2d18292
1 file changed
src/utils/settings.js
@@ -42,7 +42,7 @@ const settings = (() => {
42
return ret;
43
}
44
45
- function get(d) {
+ function getMessage(d) {
46
const page = d.getData('page');
47
const container = $('<div>');
48
const pageSettings = configs[page].settings;
@@ -96,8 +96,8 @@ const settings = (() => {
96
if (key === page) return;
97
buttons.push({
98
label: configs[key].name,
99
- action: () => {
100
- close();
+ action: (dialog) => {
+ dialog.close();
101
open(key);
102
},
103
});
@@ -110,12 +110,19 @@ const settings = (() => {
110
111
112
function open(page = 'main') {
113
+ if (typeof page !== 'string') throw new Error(`Attempted to open ${typeof page}`);
114
const displayName = configs[page].name;
- dialog = BootstrapDialog.show({
115
+ BootstrapDialog.show({
116
title: `UnderScript Configuration${page !== 'main' ? `: ${displayName}` : ''}`,
- message: get,
117
+ message: getMessage,
118
data: { page },
119
buttons: buttons(page),
120
+ onshown: (diag) => {
121
+ dialog = diag;
122
+ },
123
+ onhidden: () => {
124
+ dialog = null;
125
126
127
128
@@ -134,8 +141,12 @@ const settings = (() => {
134
141
135
142
136
143
144
+ function isOpen() {
145
+ return dialog !== null;
146
+ }
147
+
137
148
return {
138
- open, close, setDisplayName,
149
+ open, close, setDisplayName, isOpen,
139
150
register: add,
140
151
};
152
})();
0 commit comments