Skip to content

Commit 8135da7

Browse files
committed
Add basic user settings panel
1 parent a3c73a0 commit 8135da7

5 files changed

Lines changed: 99 additions & 1 deletion

File tree

Gruntfile.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ module.exports = function(grunt) {
148148
"editor/js/ui/search.js",
149149
"editor/js/ui/typeSearch.js",
150150
"editor/js/ui/subflow.js",
151+
"editor/js/ui/userSettings.js",
151152
"editor/js/ui/touch/radialMenu.js"
152153
],
153154
dest: "public/red/red.js"

editor/js/keymap.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
"ctrl-g c": "core:show-config-tab",
1313
"ctrl-e": "core:show-export-dialog",
1414
"ctrl-i": "core:show-import-dialog",
15-
"ctrl-space": "core:toggle-sidebar"
15+
"ctrl-space": "core:toggle-sidebar",
16+
"ctrl-,": "core:show-user-settings"
1617
},
1718
"workspace": {
1819
"backspace": "core:delete-selection",

editor/js/main.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,9 @@
213213
menuOptions.push(null);
214214
}
215215

216+
menuOptions.push({id:"menu-item-user-settings",label:RED._("menu.label.userSettings"),onselect:"core:show-user-settings"});
217+
menuOptions.push(null);
218+
216219
menuOptions.push({id:"menu-item-keyboard-shortcuts",label:RED._("menu.label.keyboardShortcuts"),onselect:"core:show-help"});
217220
menuOptions.push({id:"menu-item-show-tips",label:RED._("menu.label.showTips"),toggle:true,selected:true,onselect:"core:toggle-show-tips"});
218221
menuOptions.push({id:"menu-item-help",
@@ -234,6 +237,7 @@
234237
RED.editor.init();
235238
RED.keyboard.init();
236239
RED.diff.init();
240+
RED.userSettings.init();
237241

238242
RED.menu.init({id:"btn-sidemenu",options: menuOptions});
239243

editor/js/ui/userSettings.js

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
/**
2+
* Copyright JS Foundation and other contributors, http://js.foundation
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
**/
16+
17+
RED.userSettings = (function() {
18+
19+
var trayWidth = null;
20+
var settingsVisible = false;
21+
22+
function show() {
23+
if (settingsVisible) {
24+
return;
25+
}
26+
settingsVisible = true;
27+
28+
var trayOptions = {
29+
title: "User Settings",
30+
buttons: [
31+
{
32+
id: "node-dialog-ok",
33+
text: RED._("common.label.close"),
34+
class: "primary",
35+
click: function() {
36+
RED.tray.close();
37+
}
38+
}
39+
],
40+
resize: function(dimensions) {
41+
trayWidth = dimensions.width;
42+
},
43+
open: function(tray) {
44+
var trayBody = tray.find('.editor-tray-body');
45+
46+
$('<ul></ul>',{id:"user-settings-tabs"}).appendTo(trayBody);
47+
var tabContents = $('<div></div>',{id:"user-settings-tabs-content"}).appendTo(trayBody);
48+
49+
$('<div class="hide" id="user-settings-tab-view">View Tab</div>').appendTo(tabContents);
50+
$('<div class="hide" id="user-settings-tab-keyboard">Keyboard Tab</div>').appendTo(tabContents);
51+
$('<div class="hide" id="user-settings-tab-something">Something Tab</div>').appendTo(tabContents);
52+
53+
54+
var tabs = RED.tabs.create({
55+
id: "user-settings-tabs",
56+
onchange: function(tab) {
57+
$("#user-settings-tabs-content").children().hide();
58+
$("#" + tab.id).show();
59+
}
60+
});
61+
tabs.addTab({
62+
id: "user-settings-tab-view",
63+
label: "View"
64+
});
65+
tabs.addTab({
66+
id: "user-settings-tab-keyboard",
67+
label: "Keyboard Shortcuts"
68+
});
69+
tabs.addTab({
70+
id: "user-settings-tab-something",
71+
label: "Something Else"
72+
});
73+
},
74+
close: function() {
75+
settingsVisible = false;
76+
},
77+
show: function() {}
78+
}
79+
if (trayWidth !== null) {
80+
trayOptions.width = trayWidth;
81+
}
82+
RED.tray.show(trayOptions);
83+
}
84+
85+
function init() {
86+
RED.actions.add("core:show-user-settings",show);
87+
}
88+
return {
89+
init: init
90+
};
91+
})();

red/api/locales/en-US/editor.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
"sidebar": {
4141
"show": "Show sidebar"
4242
},
43+
"userSettings": "Settings",
4344
"displayStatus": "Show node status",
4445
"displayConfig": "Configuration nodes",
4546
"import": "Import",

0 commit comments

Comments
 (0)