-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.js
83 lines (67 loc) · 2.96 KB
/
config.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
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
73
74
75
76
77
78
79
80
81
"use strict";
requirejs('viewHandlers.js');
requirejs("Scripts/AddonMenu/addonMenu")
requirejs("controls/addonTree")
window.configInfo = {
load: function(panel, addon){
let _this = this;
// panel.innerHTML = window.loadFile(addon.configFile.replace('config.js','config.html'));
let pnl = panel.firstElementChild;
initializeControls(pnl);
let UI = getAllUIElements(qid('pnlCollectionsRoot'));
let TV = UI.lvTreeView;
let ds = TV.controlClass.dataSource;
addons.addonMenu.discardChanges();
ds.root.handlerID = 'addonMenuTreeRoot';
ds.root.dataSource = addons.addonMenu.getEditRootNode();
TV.controlClass.expandAll()
app.listen(TV, 'focuschange', function(e){
_this.handleButtonsDisableState(e);
});
app.listen(UI.btnNewGroup, 'click', function () {
let newGroupNode = addons.addonMenu.newGroup("New Group");
nodeUtils.refreshNodeChildren(TV.controlClass.root);
let newGroup = TV.controlClass.root.findChild(`addonGroupNode:${newGroupNode.id}`);
// focus node and enter edit node
TV.controlClass.focusNode(newGroup);
TV.controlClass.editStart()
});
app.listen(UI.btnDeleteGroup, 'click', function () {
TV.controlClass.deleteSelected();
});
app.listen(UI.btnRenameGroup, 'click', function () {
TV.controlClass.editStart()
});
app.listen(UI.btnResetTree, 'click', () => {
addons.addonMenu.resetActionTree();
let tree = app.createTree();
tree.root.handlerID = 'addonMenuTreeRoot';
tree.root.dataSource = addons.addonMenu.getEditRootNode();
TV.controlClass.dataSource = tree;
TV.controlClass.expandAll()
});
if(ds.root.dataSource.actions.length == 0){
// No addons were found, disable actions
UI.btnNewGroup.controlClass.disabled = true;
UI.btnResetTree.controlClass.disabled = true;
UI.btnDeleteGroup.controlClass.disabled = true;
UI.btnRenameGroup.controlClass.disabled = true;
UI.lblNoAddonsFound.style.display = "block";
TV.hidden = true;
}
},
save: function(panel, addon){
addons.addonMenu.applyChanges()
addons.addonMenu.saveSettings();
addons.addonMenu.refresh();
// the config menu runs in a separate context from the main window
let mainAppWindow = app.dialogs.getMainWindow()._window;
if(mainAppWindow.addons && mainAppWindow.addons.addonMenu){
mainAppWindow.addons.addonMenu.refresh();
}
},
handleButtonsDisableState: function(e){
qid('btnDeleteGroup').controlClass.disabled = 'group' != e.target.controlClass.focusedNode.dataSource.type;
qid('btnRenameGroup').controlClass.disabled = 'group' != e.target.controlClass.focusedNode.dataSource.type;
}
}