From f09197192805cbb28c1bcfd17aa8242142463f73 Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Tue, 22 Apr 2014 17:50:12 -0700 Subject: [PATCH] GUAC-326: Remove GuacUI component object. Make OSK global. --- .../src/main/webapp/scripts/client-ui.js | 56 ++--- guacamole/src/main/webapp/scripts/guac-ui.js | 195 ------------------ 2 files changed, 14 insertions(+), 237 deletions(-) diff --git a/guacamole/src/main/webapp/scripts/client-ui.js b/guacamole/src/main/webapp/scripts/client-ui.js index e4caf128e..85750ea2e 100644 --- a/guacamole/src/main/webapp/scripts/client-ui.js +++ b/guacamole/src/main/webapp/scripts/client-ui.js @@ -25,23 +25,6 @@ */ GuacUI.Client = { - /** - * Collection of all Guacamole client UI states. - */ - "states": { - - /** - * The normal default Guacamole client UI mode - */ - "INTERACTIVE" : 0, - - /** - * Same as INTERACTIVE except with visible on-screen keyboard. - */ - "OSK" : 1 - - }, - /** * Enumeration of all tunnel-specific error messages for each applicable * error code. @@ -261,9 +244,8 @@ GuacUI.Client = { * which sends key events to the Guacamole client. * * @constructor - * @augments GuacUI.Component */ -GuacUI.Client.OnScreenKeyboard = function() { +GuacUI.Client.OnScreenKeyboard = new (function() { /** * Event target. This is a hidden textarea element which will receive @@ -290,15 +272,21 @@ GuacUI.Client.OnScreenKeyboard = function() { } keyboard.onkeydown = function(keysym) { - GuacUI.Client.attachedClient.sendKeyEvent(1, keysym); + if (GuacUI.Client.attachedClient) + GuacUI.Client.attachedClient.sendKeyEvent(1, keysym); }; keyboard.onkeyup = function(keysym) { - GuacUI.Client.attachedClient.sendKeyEvent(0, keysym); + if (GuacUI.Client.attachedClient) + GuacUI.Client.attachedClient.sendKeyEvent(0, keysym); }; this.show = function() { + // Only add if not already present + if (keyboard_container.parentNode === document.body) + return; + // Show keyboard document.body.appendChild(keyboard_container); @@ -317,6 +305,10 @@ GuacUI.Client.OnScreenKeyboard = function() { this.hide = function() { + // Only remove if present + if (keyboard_container.parentNode !== document.body) + return; + // Hide keyboard document.body.removeChild(keyboard_container); window.clearInterval(keyboard_resize_interval); @@ -324,24 +316,7 @@ GuacUI.Client.OnScreenKeyboard = function() { }; -}; - -GuacUI.Client.OnScreenKeyboard.prototype = new GuacUI.Component(); - -/* - * Show on-screen keyboard during OSK mode only. - */ - -GuacUI.StateManager.registerComponent( - new GuacUI.Client.OnScreenKeyboard(), - GuacUI.Client.states.OSK -); - -/* - * Set initial state - */ - -GuacUI.StateManager.setState(GuacUI.Client.states.INTERACTIVE); +})(); /** * Modal status display. Displays a message to the user, covering the entire @@ -351,7 +326,6 @@ GuacUI.StateManager.setState(GuacUI.Client.states.INTERACTIVE); * components is impossible. * * @constructor - * @augments GuacUI.Component */ GuacUI.Client.ModalStatus = function(title_text, text, classname, reconnect) { @@ -430,8 +404,6 @@ GuacUI.Client.ModalStatus = function(title_text, text, classname, reconnect) { }; -GuacUI.Client.ModalStatus.prototype = new GuacUI.Component(); - /** * Monitors a given element for touch events, firing drag-specific events * based on pre-defined gestures. diff --git a/guacamole/src/main/webapp/scripts/guac-ui.js b/guacamole/src/main/webapp/scripts/guac-ui.js index ede090b68..e23b554a7 100644 --- a/guacamole/src/main/webapp/scripts/guac-ui.js +++ b/guacamole/src/main/webapp/scripts/guac-ui.js @@ -262,201 +262,6 @@ GuacUI.Video = new (function() { })(); -/** - * Central registry of all components for all states. - */ -GuacUI.StateManager = new (function() { - - /** - * The current state. - */ - var current_state = null; - - /** - * Array of arrays of components, indexed by the states they are in. - */ - var components = []; - - /** - * Registers the given component with this state manager, to be shown - * during the given states. - * - * @param {GuacUI.Component} component The component to register. - * @param {Number} [...] The list of states this component should be - * visible during. - */ - this.registerComponent = function(component) { - - // For each state specified, add the given component - for (var i=1; i