Integrated hint alerts in the main frame
diff --git a/dev/js/src/hint/alert.js b/dev/js/src/hint/alert.js
new file mode 100644
index 0000000..a5b43de
--- /dev/null
+++ b/dev/js/src/hint/alert.js
@@ -0,0 +1,35 @@
+/**
+ * Hint menu alert
+ */
+define(function () {
+ "use strict";
+ return {
+ create : function (msg) {
+ return Object.create(this)._init(msg);
+ },
+ _init : function (msg) {
+ this.active = false;
+ this._element = document.createElement('div');
+ this._element.style.opacity = 0;
+ this._element.classList.add('alert', 'hint');
+ return this;
+ },
+ show : function (msg) {
+ this._element.textContent = msg;
+ this.active = true;
+ this._element.style.opacity = 1;
+ },
+
+ unshow : function () {
+ if (!this.active)
+ return false;
+ this._element.style.opacity = 0;
+ this.active = false;
+ return true;
+ },
+
+ element : function () {
+ return this._element;
+ }
+ }
+});
diff --git a/dev/js/src/hint/input.js b/dev/js/src/hint/input.js
index 6e02793..7145919 100644
--- a/dev/js/src/hint/input.js
+++ b/dev/js/src/hint/input.js
@@ -49,6 +49,13 @@
return this._element.value;
},
+ /**
+ * Get the value of the input field mirror.
+ */
+ mirrorValue : function () {
+ return this._mirror.firstChild.textContent;
+ },
+
/**
* Update the mirror content.
@@ -130,14 +137,14 @@
// Create mirror for searchField
// This is important for positioning
- if ((this._mirror = document.getElementById("searchMirror")) === null) {
+ // if ((this._mirror = document.getElementById("searchMirror")) === null) {
this._mirror = document.createElement("div");
- this._mirror.setAttribute("id", "searchMirror");
+ this._mirror.classList.add('hint', 'mirror');
this._mirror.appendChild(document.createElement("span"));
this._container = this._mirror.appendChild(document.createElement("div"));
this._mirror.style.height = "0px";
document.getElementsByTagName("body")[0].appendChild(this._mirror);
- };
+// };
// Update position of the mirror
window.addEventListener('resize', this.reposition.bind(this));
diff --git a/dev/js/src/hint/item.js b/dev/js/src/hint/item.js
index 7d97334..317dae7 100644
--- a/dev/js/src/hint/item.js
+++ b/dev/js/src/hint/item.js
@@ -54,8 +54,6 @@
var input = h.inputField();
input.insert(this._action).update();
- h.active = false;
-
e.halt();
h.show(true);
diff --git a/dev/js/src/hint/menu.js b/dev/js/src/hint/menu.js
index 7d89e51..df27a11 100644
--- a/dev/js/src/hint/menu.js
+++ b/dev/js/src/hint/menu.js
@@ -28,9 +28,7 @@
// Focus on input field on hide
obj.onHide = function () {
- var input = this._hint.inputField();
- input.container().classList.remove('active');
- input.element().focus();
+ this._hint.unshow();
};
return obj;