Unshow alert on menu display
diff --git a/dev/js/spec/hintSpec.js b/dev/js/spec/hintSpec.js
index 667ac7a..5df65fd 100644
--- a/dev/js/spec/hintSpec.js
+++ b/dev/js/spec/hintSpec.js
@@ -46,16 +46,16 @@
 
     afterEach(function () {
       document.getElementsByTagName("body")[0].removeChild(
-	input
+  input
       );    
     });
 
     afterAll(function () {
       try {
-	var mirrors = document.querySelectorAll(".hint.mirror");
-	for (var i in mirrors) {
-	  mirrors[i].parentNode.removeChild(mirrors[i])
-	};
+  var mirrors = document.querySelectorAll(".hint.mirror");
+  for (var i in mirrors) {
+    mirrors[i].parentNode.removeChild(mirrors[i])
+  };
       }
       catch (e) {};
     });
@@ -128,7 +128,7 @@
       expect(analyzer.test("impcnx/")).toEqual("impcnx/");
       expect(analyzer.test("cnx/c=npcnx/")).toEqual("npcnx/");
       expect(analyzer.test("mate/m=degree:pos corenlp/ne_dewac_175m_600="))
-	.toEqual("corenlp/ne_dewac_175m_600=");
+  .toEqual("corenlp/ne_dewac_175m_600=");
       expect(analyzer.test("corenlp/")).toEqual("corenlp/");
       expect(analyzer.test("corenlp/c=")).toEqual("corenlp/c=");
       expect(analyzer.test("corenlp/c=PP-")).toEqual("corenlp/c=PP-");
@@ -145,13 +145,13 @@
   describe('KorAP.Hint', function () {
     KorAP.hintArray = {
       "-" : [
-	["Base Annotation", "base/s=", "Structure"],
-	["CoreNLP", "corenlp/", "Constituency, Named Entities, Part-of-Speech"]
+  ["Base Annotation", "base/s=", "Structure"],
+  ["CoreNLP", "corenlp/", "Constituency, Named Entities, Part-of-Speech"]
       ],
       "corenlp/" : [
-	["Named Entity", "ne=" , "Combined"],
-	["Named Entity", "ne_dewac_175m_600=" , "ne_dewac_175m_600"],
-	["Named Entity", "ne_hgc_175m_600=",    "ne_hgc_175m_600"]
+  ["Named Entity", "ne=" , "Combined"],
+  ["Named Entity", "ne_dewac_175m_600=" , "ne_dewac_175m_600"],
+  ["Named Entity", "ne_hgc_175m_600=",    "ne_hgc_175m_600"]
       ]
     };
 
@@ -169,15 +169,16 @@
     it('should be initializable', function () {
       // Supports: context, searchField
       var hint = hintClass.create({
-	inputField : input
+  inputField : input
       });
 
       expect(hint).toBeTruthy();
     });
 
+    
     it('should alert at char pos', function () {
       var hint = hintClass.create({
-	inputField : input
+        inputField : input
       });
 
       expect(hint.active()).toBeFalsy();
@@ -198,13 +199,38 @@
       hint.update();
 
       expect(hint.alert().active).toBeFalsy();
-
       expect(hint.active()).toBeFalsy();
+
+      // Show again
+      expect(hint.alert(5, 'That does not work!')).toBeTruthy();
+      expect(hint.inputField().mirrorValue()).toEqual('abcde');
+      expect(hint.alert().active).toBeTruthy();
+      expect(hint.active()).toBeTruthy();
+
+      // Show menu, hide alert!
+      hint.show(false);
+      expect(hint.active()).toBeTruthy();
+      expect(hint.inputField().mirrorValue()).toEqual('abcde');
+      expect(hint.alert().active).toBeFalsy();
+
+            // Show again
+      expect(hint.alert(5, 'That does not work!')).toBeTruthy();
+      expect(hint.inputField().mirrorValue()).toEqual('abcde');
+      expect(hint.alert().active).toBeTruthy();
+      expect(hint.active()).toBeTruthy();
+
+      // Show menu, hide alert!
+      hint.show(false);
+      expect(hint.active()).toBeTruthy();
+      expect(hint.inputField().mirrorValue()).toEqual('abcde');
+      expect(hint.alert().active).toBeFalsy();
     });
 
+
+    
     it('should view main menu on default', function () {
       var hint = hintClass.create({
-	      inputField : input
+        inputField : input
       });
 
       expect(hint.active()).toBeFalsy();
@@ -247,23 +273,45 @@
       // show with context
       hint.show(true);
 
-      expect(hint.inputField().container().getElementsByTagName('div').length).toEqual(4);
-      expect(hint.inputField().container().getElementsByTagName('ul').length).toEqual(1);
+      expect(hint.inputField().container().getElementsByTagName('div').length).toEqual(1);
+      expect(hint.inputField().container().getElementsByTagName('ul').length).toEqual(0);
+    });
+
+    it('should not view main menu if context is mandatory', function () {
+      var hint = hintClass.create({
+        inputField : input
+      });
+
+      expect(hint.active()).toBeFalsy();
+
+      // Fine
+      hint.inputField().insert('der Baum corenlp/');
+      hint.show(true);
+      expect(hint.active()).toBeTruthy();
+
+      // Not analyzable
+      hint.inputField().insert('jhgjughjfhgnhfcvgnhj');
+      hint.show(true);
+      expect(hint.active()).toBeFalsy();
+
+      // Not available
+      hint.inputField().insert('jhgjughjfhgnhfcvgnhj/');
+      hint.show(true);
+      expect(hint.active()).toBeFalsy();
     });
     
     xit('should remove all menus on escape');
   });
 
-
   
   describe('KorAP.HintMenuItem', function () {
     it('should be initializable', function () {
       expect(
-	function() { menuItemClass.create([]) }
+  function() { menuItemClass.create([]) }
       ).toThrow(new Error("Missing parameters"));
 
       expect(
-	function() { menuItemClass.create(['CoreNLP']) }
+  function() { menuItemClass.create(['CoreNLP']) }
       ).toThrow(new Error("Missing parameters"));
 
       var menuItem = menuItemClass.create(['CoreNLP', 'corenlp/']);
@@ -272,7 +320,7 @@
       expect(menuItem.desc()).toBeUndefined();
 
       menuItem = menuItemClass.create(
-	['CoreNLP', 'corenlp/', 'It\'s funny']
+  ['CoreNLP', 'corenlp/', 'It\'s funny']
       );
       expect(menuItem.name()).toEqual('CoreNLP');
       expect(menuItem.action()).toEqual('corenlp/');
@@ -293,7 +341,7 @@
       expect(menuItem.element().childNodes[1]).toBe(undefined);
 
       menuItem = menuItemClass.create(
-	['CoreNLP', 'corenlp/', 'my DescRiption']
+  ['CoreNLP', 'corenlp/', 'my DescRiption']
       );
       expect(menuItem.element()).not.toBe(undefined);
       expect(menuItem.element().nodeName).toEqual("LI");
diff --git a/dev/js/src/hint.js b/dev/js/src/hint.js
index c5c689c..238b737 100644
--- a/dev/js/src/hint.js
+++ b/dev/js/src/hint.js
@@ -192,21 +192,22 @@
      * Get the correct menu based on the context
      */
     contextMenu : function (ifContext) {
-
+      
       // Get context (aka left text)
       var context = this._inputField.context();
 
       if (context === undefined || context.length === 0) {
-	      return ifContext ? false : this.menu("-");
+        return ifContext ? undefined : this.menu("-");
       };
 
       // Get context (aka left text matching regex)
       context = this._analyzer.test(context);
 
-      if (context === undefined || context.length == 0)
+      if (context === undefined || context.length == 0) {
 	      return ifContext ? undefined : this.menu("-");
+      };
 
-      return this.menu(context) || this.menu('-');
+      return this.menu(context) || (ifContext ? undefined : this.menu('-'));
     },
 
     /**
@@ -250,35 +251,15 @@
      */
     show : function (ifContext) {
 
-      var c = this._inputField.container();
-
-      // Menu is already active
-      if (this.active() !== null) {
-
-	      // This does not work for alert currently!
-	      if (this._active._type !== 'alert') {
-	        c.removeChild(this._active.element());
-	      };
-
-	      // This may already be hidden!
-	      // this._active.hide();
-	      this.active(null);
-
-	      // Alert is not active
-	      /*
-	        if (!this._alert.unshow())
-	        return;
-	      */
-      };
-
+      // Remove the active object
+      this._unshow();
+      
       // Get the menu
       var menu;
       if (menu = this.contextMenu(ifContext)) {
-
-        // TODO: Remove old element!
-        
 	      this.active(menu);
 
+        var c = this._inputField.container();
 	      c.appendChild(menu.element());
 	      menu.show();
 	      menu.focus();
@@ -305,19 +286,28 @@
      * Deactivate the current menu and focus on the input field.
      */
     unshow : function () {
-      var c = this._inputField.container();
+      this._unshow();
+      this._inputField.element().focus();
+    },
 
+    
+    _unshow : function () {
       if (this.active() !== null) {
-        var act = this.active();
+        // var act = this.active();
         
         // This does not work for alert currently!
-	      if (act._type !== 'alert') {
+	      //if (act._type !== 'alert') {
+        if (!this._alert.active) {
+          var c = this._inputField.container();
 	        c.removeChild(this._active.element());
-	      };
+	      }
+        else {
+          this._unshowAlert();
+        };
+        
         // this._active.hide();
         this.active(null);
       };
-      this._inputField.element().focus();
     }
   };
 });