Clean up panel open/close API
This commit is contained in:
parent
d9e8621436
commit
ed8cbe4e7b
255
app/ui.js
255
app/ui.js
|
|
@ -42,11 +42,7 @@ var UI;
|
||||||
popupStatusTimeout: null,
|
popupStatusTimeout: null,
|
||||||
hideKeyboardTimeout: null,
|
hideKeyboardTimeout: null,
|
||||||
|
|
||||||
settingsOpen: false,
|
|
||||||
connSettingsOpen: false,
|
|
||||||
clipboardOpen: false,
|
|
||||||
keyboardVisible: false,
|
keyboardVisible: false,
|
||||||
extraKeysVisible: false,
|
|
||||||
|
|
||||||
isTouchDevice: false,
|
isTouchDevice: false,
|
||||||
isSafari: false,
|
isSafari: false,
|
||||||
|
|
@ -97,8 +93,9 @@ var UI;
|
||||||
UI.addSettingsHandlers();
|
UI.addSettingsHandlers();
|
||||||
|
|
||||||
// Show the connect panel on first load unless autoconnecting
|
// Show the connect panel on first load unless autoconnecting
|
||||||
if (!autoconnect && !UI.connSettingsOpen)
|
if (!autoconnect) {
|
||||||
UI.toggleConnectPanel();
|
UI.openConnectPanel();
|
||||||
|
}
|
||||||
|
|
||||||
UI.updateViewClip();
|
UI.updateViewClip();
|
||||||
UI.setBarPosition();
|
UI.setBarPosition();
|
||||||
|
|
@ -416,8 +413,7 @@ var UI;
|
||||||
.classList.remove("noVNC_hidden");
|
.classList.remove("noVNC_hidden");
|
||||||
document.getElementById('noVNC_disconnect_button')
|
document.getElementById('noVNC_disconnect_button')
|
||||||
.classList.add("noVNC_hidden");
|
.classList.add("noVNC_hidden");
|
||||||
UI.connSettingsOpen = false;
|
UI.openConnectPanel();
|
||||||
UI.toggleConnectPanel();
|
|
||||||
break;
|
break;
|
||||||
case 'loaded':
|
case 'loaded':
|
||||||
document.getElementById('noVNC_connect_controls_button')
|
document.getElementById('noVNC_connect_controls_button')
|
||||||
|
|
@ -575,44 +571,28 @@ var UI;
|
||||||
//Util.Debug("<< settingsApply");
|
//Util.Debug("<< settingsApply");
|
||||||
},
|
},
|
||||||
|
|
||||||
// Open menu
|
/* ------^-------
|
||||||
openSettingsMenu: function() {
|
* /SETTINGS
|
||||||
// Close clipboard panel if open
|
* ==============
|
||||||
if (UI.clipboardOpen === true) {
|
* PANELS
|
||||||
UI.toggleClipboardPanel();
|
* ------v------*/
|
||||||
}
|
|
||||||
// Close connection settings if open
|
closeAllPanels: function() {
|
||||||
if (UI.connSettingsOpen === true) {
|
UI.closeSettingsPanel();
|
||||||
UI.toggleConnectPanel();
|
UI.closeXvpPanel();
|
||||||
}
|
UI.closeClipboardPanel();
|
||||||
// Close XVP panel if open
|
UI.closeConnectPanel();
|
||||||
if (UI.xvpOpen === true) {
|
|
||||||
UI.toggleXvpPanel();
|
|
||||||
}
|
|
||||||
document.getElementById('noVNC_settings')
|
|
||||||
.classList.add("noVNC_open");
|
|
||||||
document.getElementById('noVNC_settings_button')
|
|
||||||
.classList.add("noVNC_selected");
|
|
||||||
UI.settingsOpen = true;
|
|
||||||
},
|
},
|
||||||
|
|
||||||
// Close menu (without applying settings)
|
/* ------^-------
|
||||||
closeSettingsMenu: function() {
|
* /PANELS
|
||||||
document.getElementById('noVNC_settings')
|
* ==============
|
||||||
.classList.remove("noVNC_open");
|
* SETTINGS (panel)
|
||||||
document.getElementById('noVNC_settings_button')
|
* ------v------*/
|
||||||
.classList.remove("noVNC_selected");
|
|
||||||
UI.settingsOpen = false;
|
openSettingsPanel: function() {
|
||||||
},
|
UI.closeAllPanels();
|
||||||
|
|
||||||
// Toggle the settings menu:
|
|
||||||
// On open, settings are refreshed from saved cookies.
|
|
||||||
// On close, settings are applied
|
|
||||||
toggleSettingsPanel: function() {
|
|
||||||
if (UI.settingsOpen) {
|
|
||||||
UI.settingsApply();
|
|
||||||
UI.closeSettingsMenu();
|
|
||||||
} else {
|
|
||||||
UI.updateSetting('encrypt');
|
UI.updateSetting('encrypt');
|
||||||
UI.updateSetting('true_color');
|
UI.updateSetting('true_color');
|
||||||
if (Util.browserSupportsCursorURIs()) {
|
if (Util.browserSupportsCursorURIs()) {
|
||||||
|
|
@ -630,7 +610,29 @@ var UI;
|
||||||
UI.updateSetting('stylesheet');
|
UI.updateSetting('stylesheet');
|
||||||
UI.updateSetting('logging');
|
UI.updateSetting('logging');
|
||||||
|
|
||||||
UI.openSettingsMenu();
|
document.getElementById('noVNC_settings')
|
||||||
|
.classList.add("noVNC_open");
|
||||||
|
document.getElementById('noVNC_settings_button')
|
||||||
|
.classList.add("noVNC_selected");
|
||||||
|
},
|
||||||
|
|
||||||
|
closeSettingsPanel: function() {
|
||||||
|
document.getElementById('noVNC_settings')
|
||||||
|
.classList.remove("noVNC_open");
|
||||||
|
document.getElementById('noVNC_settings_button')
|
||||||
|
.classList.remove("noVNC_selected");
|
||||||
|
},
|
||||||
|
|
||||||
|
// Toggle the settings menu:
|
||||||
|
// On open, settings are refreshed from saved cookies.
|
||||||
|
// On close, settings are applied
|
||||||
|
toggleSettingsPanel: function() {
|
||||||
|
if (document.getElementById('noVNC_settings')
|
||||||
|
.classList.contains("noVNC_open")) {
|
||||||
|
UI.settingsApply();
|
||||||
|
UI.closeSettingsPanel();
|
||||||
|
} else {
|
||||||
|
UI.openSettingsPanel();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
@ -640,34 +642,28 @@ var UI;
|
||||||
* XVP
|
* XVP
|
||||||
* ------v------*/
|
* ------v------*/
|
||||||
|
|
||||||
// Show the XVP panel
|
openXvpPanel: function() {
|
||||||
toggleXvpPanel: function() {
|
UI.closeAllPanels();
|
||||||
// Close settings if open
|
|
||||||
if (UI.settingsOpen === true) {
|
|
||||||
UI.settingsApply();
|
|
||||||
UI.closeSettingsMenu();
|
|
||||||
}
|
|
||||||
// Close connection settings if open
|
|
||||||
if (UI.connSettingsOpen === true) {
|
|
||||||
UI.toggleConnectPanel();
|
|
||||||
}
|
|
||||||
// Close clipboard panel if open
|
|
||||||
if (UI.clipboardOpen === true) {
|
|
||||||
UI.toggleClipboardPanel();
|
|
||||||
}
|
|
||||||
// Toggle XVP panel
|
|
||||||
if (UI.xvpOpen === true) {
|
|
||||||
document.getElementById('noVNC_xvp')
|
|
||||||
.classList.remove("noVNC_open");
|
|
||||||
document.getElementById('noVNC_xvp_button')
|
|
||||||
.classList.remove("noVNC_selected");
|
|
||||||
UI.xvpOpen = false;
|
|
||||||
} else {
|
|
||||||
document.getElementById('noVNC_xvp')
|
document.getElementById('noVNC_xvp')
|
||||||
.classList.add("noVNC_open");
|
.classList.add("noVNC_open");
|
||||||
document.getElementById('noVNC_xvp_button')
|
document.getElementById('noVNC_xvp_button')
|
||||||
.classList.add("noVNC_selected");
|
.classList.add("noVNC_selected");
|
||||||
UI.xvpOpen = true;
|
},
|
||||||
|
|
||||||
|
closeXvpPanel: function() {
|
||||||
|
document.getElementById('noVNC_xvp')
|
||||||
|
.classList.remove("noVNC_open");
|
||||||
|
document.getElementById('noVNC_xvp_button')
|
||||||
|
.classList.remove("noVNC_selected");
|
||||||
|
},
|
||||||
|
|
||||||
|
toggleXvpPanel: function() {
|
||||||
|
if (document.getElementById('noVNC_xvp')
|
||||||
|
.classList.contains("noVNC_open")) {
|
||||||
|
UI.closeXvpPanel();
|
||||||
|
} else {
|
||||||
|
UI.openXvpPanel();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
@ -680,9 +676,7 @@ var UI;
|
||||||
document.getElementById('noVNC_xvp_button')
|
document.getElementById('noVNC_xvp_button')
|
||||||
.classList.add("noVNC_hidden");
|
.classList.add("noVNC_hidden");
|
||||||
// Close XVP panel if open
|
// Close XVP panel if open
|
||||||
if (UI.xvpOpen === true) {
|
UI.closeXvpPanel();
|
||||||
UI.toggleXvpPanel();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
@ -692,34 +686,28 @@ var UI;
|
||||||
* CLIPBOARD
|
* CLIPBOARD
|
||||||
* ------v------*/
|
* ------v------*/
|
||||||
|
|
||||||
// Show the clipboard panel
|
openClipboardPanel: function() {
|
||||||
toggleClipboardPanel: function() {
|
UI.closeAllPanels();
|
||||||
// Close settings if open
|
|
||||||
if (UI.settingsOpen === true) {
|
|
||||||
UI.settingsApply();
|
|
||||||
UI.closeSettingsMenu();
|
|
||||||
}
|
|
||||||
// Close connection settings if open
|
|
||||||
if (UI.connSettingsOpen === true) {
|
|
||||||
UI.toggleConnectPanel();
|
|
||||||
}
|
|
||||||
// Close XVP panel if open
|
|
||||||
if (UI.xvpOpen === true) {
|
|
||||||
UI.toggleXvpPanel();
|
|
||||||
}
|
|
||||||
// Toggle Clipboard Panel
|
|
||||||
if (UI.clipboardOpen === true) {
|
|
||||||
document.getElementById('noVNC_clipboard')
|
|
||||||
.classList.remove("noVNC_open");
|
|
||||||
document.getElementById('noVNC_clipboard_button')
|
|
||||||
.classList.remove("noVNC_selected");
|
|
||||||
UI.clipboardOpen = false;
|
|
||||||
} else {
|
|
||||||
document.getElementById('noVNC_clipboard')
|
document.getElementById('noVNC_clipboard')
|
||||||
.classList.add("noVNC_open");
|
.classList.add("noVNC_open");
|
||||||
document.getElementById('noVNC_clipboard_button')
|
document.getElementById('noVNC_clipboard_button')
|
||||||
.classList.add("noVNC_selected");
|
.classList.add("noVNC_selected");
|
||||||
UI.clipboardOpen = true;
|
},
|
||||||
|
|
||||||
|
closeClipboardPanel: function() {
|
||||||
|
document.getElementById('noVNC_clipboard')
|
||||||
|
.classList.remove("noVNC_open");
|
||||||
|
document.getElementById('noVNC_clipboard_button')
|
||||||
|
.classList.remove("noVNC_selected");
|
||||||
|
},
|
||||||
|
|
||||||
|
toggleClipboardPanel: function() {
|
||||||
|
if (document.getElementById('noVNC_clipboard')
|
||||||
|
.classList.contains("noVNC_open")) {
|
||||||
|
UI.closeClipboardPanel();
|
||||||
|
} else {
|
||||||
|
UI.openClipboardPanel();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
@ -747,48 +735,40 @@ var UI;
|
||||||
* CONNECTION
|
* CONNECTION
|
||||||
* ------v------*/
|
* ------v------*/
|
||||||
|
|
||||||
// Show the connection settings panel/menu
|
openConnectPanel: function() {
|
||||||
toggleConnectPanel: function() {
|
UI.closeAllPanels();
|
||||||
// Close connection settings if open
|
|
||||||
if (UI.settingsOpen === true) {
|
|
||||||
UI.settingsApply();
|
|
||||||
UI.closeSettingsMenu();
|
|
||||||
document.getElementById('noVNC_connect_controls_button')
|
|
||||||
.classList.remove("noVNC_selected");
|
|
||||||
}
|
|
||||||
// Close clipboard panel if open
|
|
||||||
if (UI.clipboardOpen === true) {
|
|
||||||
UI.toggleClipboardPanel();
|
|
||||||
}
|
|
||||||
// Close XVP panel if open
|
|
||||||
if (UI.xvpOpen === true) {
|
|
||||||
UI.toggleXvpPanel();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Toggle Connection Panel
|
|
||||||
if (UI.connSettingsOpen === true) {
|
|
||||||
document.getElementById('noVNC_connect_controls')
|
|
||||||
.classList.remove("noVNC_open");
|
|
||||||
document.getElementById('noVNC_connect_controls_button')
|
|
||||||
.classList.remove("noVNC_selected");
|
|
||||||
UI.connSettingsOpen = false;
|
|
||||||
UI.saveSetting('host');
|
|
||||||
UI.saveSetting('port');
|
|
||||||
UI.saveSetting('token');
|
|
||||||
//UI.saveSetting('password');
|
|
||||||
} else {
|
|
||||||
document.getElementById('noVNC_connect_controls')
|
document.getElementById('noVNC_connect_controls')
|
||||||
.classList.add("noVNC_open");
|
.classList.add("noVNC_open");
|
||||||
document.getElementById('noVNC_connect_controls_button')
|
document.getElementById('noVNC_connect_controls_button')
|
||||||
.classList.add("noVNC_selected");
|
.classList.add("noVNC_selected");
|
||||||
UI.connSettingsOpen = true;
|
|
||||||
document.getElementById('noVNC_setting_host').focus();
|
document.getElementById('noVNC_setting_host').focus();
|
||||||
|
},
|
||||||
|
|
||||||
|
closeConnectPanel: function() {
|
||||||
|
document.getElementById('noVNC_connect_controls')
|
||||||
|
.classList.remove("noVNC_open");
|
||||||
|
document.getElementById('noVNC_connect_controls_button')
|
||||||
|
.classList.remove("noVNC_selected");
|
||||||
|
|
||||||
|
UI.saveSetting('host');
|
||||||
|
UI.saveSetting('port');
|
||||||
|
UI.saveSetting('token');
|
||||||
|
//UI.saveSetting('password');
|
||||||
|
},
|
||||||
|
|
||||||
|
toggleConnectPanel: function() {
|
||||||
|
if (document.getElementById('noVNC_connect_controls')
|
||||||
|
.classList.contains("noVNC_open")) {
|
||||||
|
UI.closeConnectPanel();
|
||||||
|
} else {
|
||||||
|
UI.openConnectPanel();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
connect: function() {
|
connect: function() {
|
||||||
UI.closeSettingsMenu();
|
UI.closeAllPanels();
|
||||||
UI.toggleConnectPanel();
|
|
||||||
|
|
||||||
var host = document.getElementById('noVNC_setting_host').value;
|
var host = document.getElementById('noVNC_setting_host').value;
|
||||||
var port = document.getElementById('noVNC_setting_port').value;
|
var port = document.getElementById('noVNC_setting_port').value;
|
||||||
|
|
@ -821,7 +801,7 @@ var UI;
|
||||||
},
|
},
|
||||||
|
|
||||||
disconnect: function() {
|
disconnect: function() {
|
||||||
UI.closeSettingsMenu();
|
UI.closeAllPanels();
|
||||||
UI.rfb.disconnect();
|
UI.rfb.disconnect();
|
||||||
|
|
||||||
// Restore the callback used for initial resize
|
// Restore the callback used for initial resize
|
||||||
|
|
@ -1258,20 +1238,27 @@ var UI;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
toggleExtraKeys: function() {
|
openExtraKeys: function() {
|
||||||
UI.keepKeyboard();
|
|
||||||
if(UI.extraKeysVisible === false) {
|
|
||||||
document.getElementById('noVNC_modifiers')
|
document.getElementById('noVNC_modifiers')
|
||||||
.classList.add("noVNC_open");
|
.classList.add("noVNC_open");
|
||||||
document.getElementById('noVNC_toggle_extra_keys_button')
|
document.getElementById('noVNC_toggle_extra_keys_button')
|
||||||
.classList.add("noVNC_selected");
|
.classList.add("noVNC_selected");
|
||||||
UI.extraKeysVisible = true;
|
},
|
||||||
} else if(UI.extraKeysVisible === true) {
|
|
||||||
|
closeExtraKeys: function() {
|
||||||
document.getElementById('noVNC_modifiers')
|
document.getElementById('noVNC_modifiers')
|
||||||
.classList.remove("noVNC_open");
|
.classList.remove("noVNC_open");
|
||||||
document.getElementById('noVNC_toggle_extra_keys_button')
|
document.getElementById('noVNC_toggle_extra_keys_button')
|
||||||
.classList.remove("noVNC_selected");
|
.classList.remove("noVNC_selected");
|
||||||
UI.extraKeysVisible = false;
|
},
|
||||||
|
|
||||||
|
toggleExtraKeys: function() {
|
||||||
|
UI.keepKeyboard();
|
||||||
|
if(document.getElementById('noVNC_modifiers')
|
||||||
|
.classList.contains("noVNC_open")) {
|
||||||
|
UI.closeExtraKeys();
|
||||||
|
} else {
|
||||||
|
UI.openExtraKeys();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue