Fixed init value of string fields in virtual corpora
Change-Id: I7d9bd8f3a2d440cc6ef9a07f88d1058b65793f63
diff --git a/dev/js/spec/vcSpec.js b/dev/js/spec/vcSpec.js
index ae62f10..0c86d85 100644
--- a/dev/js/spec/vcSpec.js
+++ b/dev/js/spec/vcSpec.js
@@ -140,6 +140,7 @@
// Set values
doc.key("title");
+
doc.value("Der alte Mann");
expect(doc.matchop()).toEqual('eq');
expect(doc.key()).toEqual("title");
@@ -2218,6 +2219,14 @@
ul.getElementsByTagName('li')[1].click();
expect(vc.element().firstChild.children[1].tagName).toEqual("SPAN");
expect(vc.element().firstChild.children[1].innerText).toEqual("ne");
+
+ // Click on text
+ expect(vc.element().firstChild.children[2].innerText).toEqual("⋯");
+ vc.element().firstChild.children[2].click();
+
+ // Blur text element
+ expect(vc.element().firstChild.children[2].firstChild.value).toEqual('');
+
// blur
document.body.click();
});
diff --git a/dev/js/src/vc/doc.js b/dev/js/src/vc/doc.js
index bdedb70..d2a413e 100644
--- a/dev/js/src/vc/doc.js
+++ b/dev/js/src/vc/doc.js
@@ -213,7 +213,6 @@
// Check the VC list if the field is known
var type = KorAP._vcKeyMenu.typeOf(this.key());
if (type != undefined) {
- console.log("Guessed the type for " + this.key() + " to be " + type);
json["type"] = "type:" + type;
};
};
@@ -476,7 +475,7 @@
_changeValue : function (e) {
var v = this.value();
var that = this;
-
+
// Show datepicker
if (this.type() === 'date') {
var dp = KorAP._vcDatePicker;
diff --git a/dev/js/src/vc/stringval.js b/dev/js/src/vc/stringval.js
index bd3a65c..10daaee 100644
--- a/dev/js/src/vc/stringval.js
+++ b/dev/js/src/vc/stringval.js
@@ -13,7 +13,8 @@
regex = arguments[1];
};
if (arguments.length >= 1) {
- value = arguments[0];
+ if (arguments[0] !== undefined)
+ value = arguments[0];
};
return Object.create(this)._init(value, regex);
},
@@ -119,8 +120,10 @@
// Add input field
this._input = e.addE('input');
- if (this.value() !== undefined)
+
+ if (this.value() !== undefined) {
this._input.value = this.value();
+ };
// Add regex button
var re = e.addE('div');
@@ -138,7 +141,7 @@
// delegate focus to
this._input.addEventListener(
'blur',
- function (ev) {
+ function (ev) {
if (!this._inField) {
this.value(this._input.value);
this.store(this.value(), this.regex());