GUI -- TopoView - Reimplemented (most of) the ESCAPE key handling.

Change-Id: I4d05a3107e68e75aad47adb6c4ef6a7ca74ba82b
diff --git a/web/gui/src/main/webapp/app/view/topo/topo.js b/web/gui/src/main/webapp/app/view/topo/topo.js
index 18b4fe1..6e3dd5f 100644
--- a/web/gui/src/main/webapp/app/view/topo/topo.js
+++ b/web/gui/src/main/webapp/app/view/topo/topo.js
@@ -99,16 +99,26 @@
     }
 
     function handleEscape() {
-        $log.debug("TODO: handle-ESCAPE...");
-        // if showingAffinity: cancelAffinity
+        if (false) {
+            // TODO: if an instance is selected, cancel the affinity mapping
+            // tis.cancelAffinity()
 
-        // else if showingDetails: deselectAll
+        } else if (tss.haveDetails()) {
+            // else if we have node selections, deselect them all
+            tss.deselectAll();
 
-        // else if oiBox visible: hide oiBox
+        } else if (tis.isVisible()) {
+            // else if the Instance Panel is visible, hide it
+            tis.hide();
+            tfs.updateDeviceColors();
 
-        // else if summary panel visible: cancel Summary
+        } else if (tps.summaryVisible()) {
+            // else if the Summary Panel is visible, hide it
+            tps.hideSummaryPanel();
 
-        // else: hoverMode = hoverModeNone
+        } else {
+            // TODO: set hover mode to hoverModeNone
+        }
     }
 
     // --- Glyphs, Icons, and the like -----------------------------------