From 4e471b5b55fa2272e3c72b0df8848dabc3196965 Mon Sep 17 00:00:00 2001 From: samhed Date: Tue, 26 Apr 2016 19:04:32 +0200 Subject: [PATCH] Moved and split the popupStatus function Now if popupStatus is called twice it will refresh the duration of the popup. If you want to wait 1.5 seconds and close the popup you can click the popup itself. --- include/ui.js | 56 +++++++++++++++++++++++++-------------------------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/include/ui.js b/include/ui.js index c67077f4..72878376 100644 --- a/include/ui.js +++ b/include/ui.js @@ -221,8 +221,8 @@ var UI; $D("xvpShutdownButton").onclick = UI.xvpShutdown; $D("xvpRebootButton").onclick = UI.xvpReboot; $D("xvpResetButton").onclick = UI.xvpReset; - $D("noVNC_status").onclick = UI.togglePopupStatus; - $D("noVNC_popup_status").onclick = UI.togglePopupStatus; + $D("noVNC_status").onclick = UI.popupStatus; + $D("noVNC_popup_status").onclick = UI.closePopup; $D("xvpButton").onclick = UI.toggleXvpPanel; $D("clipboardButton").onclick = UI.toggleClipboardPanel; $D("fullscreenButton").onclick = UI.toggleFullscreen; @@ -348,6 +348,31 @@ var UI; //Util.Debug("<< updateVisualState"); }, + popupStatus: function(text) { + var psp = $D('noVNC_popup_status'); + + clearTimeout(UI.popupStatusTimeout); + + if (typeof text === 'string') { + psp.innerHTML = text; + } else { + psp.innerHTML = $D('noVNC_status').innerHTML; + } + psp.style.display = "block"; + psp.style.left = window.innerWidth/2 - + parseInt(window.getComputedStyle(psp).width)/2 -30 + "px"; + + // Show the popup for a maximum of 1.5 seconds + UI.popupStatusTimeout = setTimeout(function() { + UI.closePopup(); + }, 1500); + }, + + closePopup: function() { + clearTimeout(UI.popupStatusTimeout); + $D('noVNC_popup_status').style.display = "none"; + }, + // Initial page load read/initialization of settings initSetting: function(name, defVal) { // Check Query string followed by cookie @@ -486,31 +511,6 @@ var UI; } }, - - // Show the popup status - togglePopupStatus: function(text) { - var psp = $D('noVNC_popup_status'); - - var closePopup = function() { psp.style.display = "none"; }; - - if (window.getComputedStyle(psp).display === 'none') { - if (typeof text === 'string') { - psp.innerHTML = text; - } else { - psp.innerHTML = $D('noVNC_status').innerHTML; - } - psp.style.display = "block"; - psp.style.left = window.innerWidth/2 - - parseInt(window.getComputedStyle(psp).width)/2 -30 + "px"; - - // Show the popup for a maximum of 1.5 seconds - UI.popupStatusTimeout = setTimeout(function() { closePopup(); }, 1500); - } else { - clearTimeout(UI.popupStatusTimeout); - closePopup(); - } - }, - // Show the XVP panel toggleXvpPanel: function() { // Close the description panel @@ -968,7 +968,7 @@ var UI; // The browser is IE and we are in fullscreen mode. // - We need to force clipping while in fullscreen since // scrollbars doesn't work. - UI.togglePopupStatus("Forcing clipping mode since scrollbars aren't supported by IE in fullscreen"); + UI.popupStatus("Forcing clipping mode since scrollbars aren't supported by IE in fullscreen"); UI.rememberedClipSetting = UI.getSetting('clip'); UI.setViewClip(true); $D('noVNC_clip').disabled = true;