Release preparation, documentation, fixing vc bugs
diff --git a/dev/js/src/hint/input.js b/dev/js/src/hint/input.js
index b1c6632..c12d26a 100644
--- a/dev/js/src/hint/input.js
+++ b/dev/js/src/hint/input.js
@@ -1,9 +1,14 @@
// Input field for queries
define({
+
+ /**
+ * Create a new input field.
+ */
create : function (element) {
return Object.create(this)._init(element);
},
-
+
+ // Initialize new input field
_init : function (element) {
this._element = element;
@@ -29,34 +34,62 @@
return this;
},
- rightPos : function () {
+ // Get the right position
+ _rightPos : function () {
var box = this._mirror.firstChild.getBoundingClientRect();
return box.right - box.left;
},
+ /**
+ * Get the mirrored input field.
+ */
mirror : function () {
return this._mirror;
},
+
+ /**
+ * Get the container element.
+ * This contains the mirror and
+ * the hint helper.
+ */
container : function () {
return this._container;
},
+
+ /**
+ * Get the input element the
+ * hint helper is attached to.
+ */
element : function () {
return this._element;
},
+ /**
+ * Get the value of the input field
+ * the hint helper is attached to.
+ */
value : function () {
return this._element.value;
},
+
+ /**
+ * Update the mirror content.
+ */
update : function () {
- this._mirror.firstChild.textContent = this.split()[0];
- this._container.style.left = this.rightPos() + 'px';
+ this._mirror.firstChild.textContent = this._split()[0];
+ this._container.style.left = this._rightPos() + 'px';
},
+ /**
+ * Insert text into the mirror.
+ * This is a prefix of the input field's
+ * value.
+ */
insert : function (text) {
- var splittedText = this.split();
+ var splittedText = this._split();
var s = this._element;
s.value = splittedText[0] + text + splittedText[1];
s.selectionStart = (splittedText[0] + text).length;
@@ -64,18 +97,11 @@
this._mirror.firstChild.textContent = splittedText[0] + text;
},
- // Return two substrings, splitted at current cursor position
- split : function () {
- var s = this._element;
- var value = s.value;
- var start = s.selectionStart;
- return new Array(
- value.substring(0, start),
- value.substring(start, value.length)
- );
- },
- // Position the input mirror directly below the input box
+ /**
+ * Reposition the input mirror directly
+ * below the input box.
+ */
reposition : function () {
var inputClientRect = this._element.getBoundingClientRect();
var inputStyle = window.getComputedStyle(this._element, null);
@@ -97,7 +123,27 @@
mirrorStyle.fontSize = inputStyle.getPropertyValue("font-size");
mirrorStyle.fontFamily = inputStyle.getPropertyValue("font-family");
},
+
+ /**
+ * Get the context, which is the input
+ * field's value bounded to the
+ * cursor position.
+ */
context : function () {
- return this.split()[0];
+ return this._split()[0];
+ },
+
+ /*
+ * Return two substrings,
+ * splitted at the current cursor position.
+ */
+ _split : function () {
+ var s = this._element;
+ var value = s.value;
+ var start = s.selectionStart;
+ return new Array(
+ value.substring(0, start),
+ value.substring(start, value.length)
+ );
}
});