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-show-tips",label:RED._("menu.label.showTips"),toggle:true,selected:true,onselect:"core:toggle-show-tips"});
menuOptions.push({id:"menu-item-help",
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")

View File

@ -148,15 +148,30 @@ RED.sidebar.info = (function() {
var tips = (function() {
var startDelay = 2000;
var started = false;
var enabled = true;
var startDelay = 1000;
var cycleDelay = 10000;
var startTimeout;
var refreshTimeout;
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() {
var r = Math.floor(Math.random() * tipCount);
var tip = RED._("infotips:info.tip"+r);
@ -184,8 +199,9 @@ RED.sidebar.info = (function() {
setTip();
})
}
return {
start: function() {
function startTips() {
started = true;
if (enabled) {
if (!startTimeout && !refreshTimeout) {
$(content).html("");
if (tipCount === -1) {
@ -195,14 +211,20 @@ RED.sidebar.info = (function() {
}
startTimeout = setTimeout(setTip,startDelay);
}
},
stop: function() {
clearInterval(refreshTimeout);
clearTimeout(startTimeout);
refreshTimeout = null;
startTimeout = null;
}
}
function stopTips() {
started = false;
clearInterval(refreshTimeout);
clearTimeout(startTimeout);
refreshTimeout = null;
startTimeout = null;
$(".node-info-tip").remove();
}
return {
start: startTips,
stop: stopTips
}
})();
function clear() {

View File

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