1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

Allow tips to be enabled/disabled via menu option

This commit is contained in:
Nick O'Leary 2017-01-06 13:33:23 +00:00
parent 0c7705beff
commit d131addd63
No known key found for this signature in database
GPG Key ID: 4F2157149161A6C9
3 changed files with 35 additions and 11 deletions

View File

@ -231,6 +231,7 @@
} }
menuOptions.push({id:"menu-item-keyboard-shortcuts",label:RED._("menu.label.keyboardShortcuts"),onselect:"core:show-help"}); menuOptions.push({id:"menu-item-keyboard-shortcuts",label:RED._("menu.label.keyboardShortcuts"),onselect:"core:show-help"});
menuOptions.push({id:"menu-item-show-tips",label:RED._("menu.label.showTips"),toggle:true,selected:true,onselect:"core:toggle-show-tips"});
menuOptions.push({id:"menu-item-help", menuOptions.push({id:"menu-item-help",
label: RED.settings.theme("menu.menu-item-help.label","Node-RED website"), label: RED.settings.theme("menu.menu-item-help.label","Node-RED website"),
href: RED.settings.theme("menu.menu-item-help.url","http://nodered.org/docs") href: RED.settings.theme("menu.menu-item-help.url","http://nodered.org/docs")

View File

@ -148,15 +148,30 @@ RED.sidebar.info = (function() {
var tips = (function() { var tips = (function() {
var startDelay = 2000; var started = false;
var enabled = true;
var startDelay = 1000;
var cycleDelay = 10000; var cycleDelay = 10000;
var startTimeout; var startTimeout;
var refreshTimeout; var refreshTimeout;
var tipCount = -1; var tipCount = -1;
RED.actions.add("core:toggle-show-tips",function(state) {
if (state === undefined) {
RED.menu.toggleSelected("menu-item-show-tips");
} else {
enabled = state;
if (enabled) {
if (started) {
startTips();
}
} else {
stopTips();
}
}
});
function setTip() { function setTip() {
var r = Math.floor(Math.random() * tipCount); var r = Math.floor(Math.random() * tipCount);
var tip = RED._("infotips:info.tip"+r); var tip = RED._("infotips:info.tip"+r);
@ -184,8 +199,9 @@ RED.sidebar.info = (function() {
setTip(); setTip();
}) })
} }
return { function startTips() {
start: function() { started = true;
if (enabled) {
if (!startTimeout && !refreshTimeout) { if (!startTimeout && !refreshTimeout) {
$(content).html(""); $(content).html("");
if (tipCount === -1) { if (tipCount === -1) {
@ -195,13 +211,19 @@ RED.sidebar.info = (function() {
} }
startTimeout = setTimeout(setTip,startDelay); startTimeout = setTimeout(setTip,startDelay);
} }
}, }
stop: function() { }
function stopTips() {
started = false;
clearInterval(refreshTimeout); clearInterval(refreshTimeout);
clearTimeout(startTimeout); clearTimeout(startTimeout);
refreshTimeout = null; refreshTimeout = null;
startTimeout = null; startTimeout = null;
$(".node-info-tip").remove();
} }
return {
start: startTips,
stop: stopTips
} }
})(); })();

View File

@ -53,7 +53,8 @@
"keyboardShortcuts": "Keyboard shortcuts", "keyboardShortcuts": "Keyboard shortcuts",
"login": "Login", "login": "Login",
"logout": "Logout", "logout": "Logout",
"editPalette":"Manage palette" "editPalette":"Manage palette",
"showTips": "Show tips"
} }
}, },
"user": { "user": {