From a2aa78afd4e2e24c706a3dd32994c389588843ad Mon Sep 17 00:00:00 2001 From: Nick O'Leary Date: Mon, 13 Apr 2015 13:55:17 +0100 Subject: [PATCH] Add main menu customisation --- editor/js/ui/keyboard.js | 83 ++++++++++++++++++++++------------------ editor/js/ui/library.js | 4 +- editor/js/ui/menu.js | 48 ++++++++++++++++------- red/api/theme.js | 5 +++ 4 files changed, 87 insertions(+), 53 deletions(-) diff --git a/editor/js/ui/keyboard.js b/editor/js/ui/keyboard.js index e6ed7c17d..e62b85adc 100644 --- a/editor/js/ui/keyboard.js +++ b/editor/js/ui/keyboard.js @@ -59,46 +59,53 @@ RED.keyboard = (function() { } - var dialog = $('
'+ - '
'+ - ''+ - ''+ - ''+ - ''+ - ''+ - ''+ - ''+ - ''+ - '
Ctrl/⌘ + aSelect all nodes
Shift + ClickSelect all connected nodes
Ctrl/⌘ + ClickAdd/remove node from selection
DeleteDelete selected nodes or link
 
Ctrl/⌘ + iImport nodes
Ctrl/⌘ + eExport selected nodes
'+ - '
'+ - '
'+ - ''+ - ''+ - ''+ - ''+ - ''+ - ''+ - ''+ - ''+ - '
Ctrl/⌘ + SpaceToggle sidebar
DeleteDelete selected nodes or link
Ctrl/⌘ + cCopy selected nodes
Ctrl/⌘ + xCut selected nodes
Ctrl/⌘ + vPaste nodes
'+ - '
'+ - '
') - .appendTo("body") - .dialog({ - modal: true, - autoOpen: false, - width: "800", - title:"Keyboard shortcuts", - resizable: false, - open: function() { - RED.keyboard.disable(); - }, - close: function() { - RED.keyboard.enable(); - } - }); + var dialog = null; function showKeyboardHelp() { + if (!RED.settings.theme("menu.btn-keyboard-shortcuts",true)) { + return; + } + if (!dialog) { + dialog = $('
'+ + '
'+ + ''+ + ''+ + ''+ + ''+ + ''+ + ''+ + ''+ + ''+ + '
Ctrl/⌘ + aSelect all nodes
Shift + ClickSelect all connected nodes
Ctrl/⌘ + ClickAdd/remove node from selection
DeleteDelete selected nodes or link
 
Ctrl/⌘ + iImport nodes
Ctrl/⌘ + eExport selected nodes
'+ + '
'+ + '
'+ + ''+ + ''+ + ''+ + ''+ + ''+ + ''+ + ''+ + ''+ + '
Ctrl/⌘ + SpaceToggle sidebar
DeleteDelete selected nodes or link
Ctrl/⌘ + cCopy selected nodes
Ctrl/⌘ + xCut selected nodes
Ctrl/⌘ + vPaste nodes
'+ + '
'+ + '
') + .appendTo("body") + .dialog({ + modal: true, + autoOpen: false, + width: "800", + title:"Keyboard shortcuts", + resizable: false, + open: function() { + RED.keyboard.disable(); + }, + close: function() { + RED.keyboard.enable(); + } + }); + } + dialog.dialog("open"); } diff --git a/editor/js/ui/library.js b/editor/js/ui/library.js index 19193cd7f..c313d8797 100644 --- a/editor/js/ui/library.js +++ b/editor/js/ui/library.js @@ -402,7 +402,9 @@ RED.library = (function() { } }); - loadFlowLibrary(); + if (RED.settings.theme("menu.btn-import-library") !== false) { + loadFlowLibrary(); + } }, create: createUI, loadFlowLibrary: loadFlowLibrary, diff --git a/editor/js/ui/menu.js b/editor/js/ui/menu.js index 83606fd46..34bd73445 100644 --- a/editor/js/ui/menu.js +++ b/editor/js/ui/menu.js @@ -23,6 +23,13 @@ RED.menu = (function() { function createMenuItem(opt) { var item; + if (opt !== null && opt.id) { + var themeSetting = RED.settings.theme("menu."+opt.id); + if (themeSetting === false) { + return null; + } + } + function setState() { var savedStateActive = isSavedStateActive(opt.id); if (savedStateActive) { @@ -113,7 +120,10 @@ RED.menu = (function() { var submenu = $('').appendTo(item); for (var i=0;i",{id:options.id+"-submenu", class:"dropdown-menu pull-right"}).insertAfter(button); + var lastAddedSeparator = false; for (var i=0;i