mirror of
				https://github.com/node-red/node-red.git
				synced 2025-03-01 10:36:34 +00:00 
			
		
		
		
	Allow tips to be enabled/disabled via menu option
This commit is contained in:
		| @@ -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") | ||||
|   | ||||
| @@ -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() { | ||||
|   | ||||
| @@ -53,7 +53,8 @@ | ||||
|             "keyboardShortcuts": "Keyboard shortcuts", | ||||
|             "login": "Login", | ||||
|             "logout": "Logout", | ||||
|             "editPalette":"Manage palette" | ||||
|             "editPalette":"Manage palette", | ||||
|             "showTips": "Show tips" | ||||
|         } | ||||
|     }, | ||||
|     "user": { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user