Remove multiple menus in hint
diff --git a/dev/js/src/hint.js b/dev/js/src/hint.js
index 8859c0a..c5c689c 100644
--- a/dev/js/src/hint.js
+++ b/dev/js/src/hint.js
@@ -5,6 +5,7 @@
* @author Nils Diewald
*/
/*
+ * TODO: Check for cnx/syn=
* TODO: List can be shown when prefix is like 'base/s=pcorenlp/'
* TODO: Sometimes the drop-down box down vanish when list is shown
* TODO: Create should expect an input text field
@@ -195,8 +196,9 @@
// Get context (aka left text)
var context = this._inputField.context();
- if (context === undefined || context.length === 0)
- return ifContext ? undefined : this.menu("-");
+ if (context === undefined || context.length === 0) {
+ return ifContext ? false : this.menu("-");
+ };
// Get context (aka left text matching regex)
context = this._analyzer.test(context);
@@ -239,8 +241,7 @@
/**
* Show the menu.
- * Currently this means that multiple menus may be loaded
- * but not shown.
+ * Remove all old menus.
*
* @param {boolean} Boolean value to indicate if context
* is necessary (true) or if the main context should
@@ -260,7 +261,7 @@
};
// This may already be hidden!
- this._active.hide();
+ // this._active.hide();
this.active(null);
// Alert is not active
@@ -283,26 +284,40 @@
menu.focus();
// Focus on input field
// this.inputField.element.focus();
+ }
+ else {
+ this._inputField.element().focus();
};
},
- // Show an object in the containerField
- // This will hide all other objects
- // Accepts menus as well as alerts
- show2 : function (obj) {
- var c = this._inputField.container();
-
- },
-
// This will get the context of the field
getContext : function () {},
/**
* Deactivate the current menu and focus on the input field.
*/
- unshow : function () {
+ unshow_old : function () {
this.active(null);
this.inputField().element().focus();
+ },
+
+ /**
+ * Deactivate the current menu and focus on the input field.
+ */
+ unshow : function () {
+ var c = this._inputField.container();
+
+ if (this.active() !== null) {
+ var act = this.active();
+
+ // This does not work for alert currently!
+ if (act._type !== 'alert') {
+ c.removeChild(this._active.element());
+ };
+ // this._active.hide();
+ this.active(null);
+ };
+ this._inputField.element().focus();
}
};
});
diff --git a/dev/js/src/hint/item.js b/dev/js/src/hint/item.js
index cfea816..66819c6 100644
--- a/dev/js/src/hint/item.js
+++ b/dev/js/src/hint/item.js
@@ -9,23 +9,23 @@
*/
create : function (params) {
return Object.create(itemClass)
- .upgradeTo(this)
- ._init(params);
+ .upgradeTo(this)
+ ._init(params);
},
// Initialize menu item object
_init : function (params) {
if (params[0] === undefined ||
- params[1] === undefined)
- throw new Error("Missing parameters");
+ params[1] === undefined)
+ throw new Error("Missing parameters");
this._name = params[0];
this._action = params[1];
this._lcField = ' ' + this._name.toLowerCase();
if (params.length > 2) {
- this._desc = params[2];
- this._lcField += " " + this._desc.toLowerCase();
+ this._desc = params[2];
+ this._lcField += " " + this._desc.toLowerCase();
};
return this;
@@ -36,7 +36,7 @@
*/
content : function (content) {
if (arguments.length === 1) {
- this._content = content;
+ this._content = content;
};
return this._content;
},
@@ -89,13 +89,13 @@
element : function () {
// already defined
if (this._element !== undefined)
- return this._element;
+ return this._element;
// Create list item
var li = document.createElement("li");
if (this.onclick !== undefined) {
- li["onclick"] = this.onclick.bind(this);
+ li["onclick"] = this.onclick.bind(this);
};
// Create title
@@ -106,10 +106,10 @@
// Create description
if (this._desc !== undefined) {
- var desc = document.createElement("span");
- desc.classList.add('desc');
- desc.appendChild(document.createTextNode(this._desc));
- li.appendChild(desc);
+ var desc = document.createElement("span");
+ desc.classList.add('desc');
+ desc.appendChild(document.createTextNode(this._desc));
+ li.appendChild(desc);
};
return this._element = li;
}