Renamed to Kalamar and updated Virtual Collection Chooser
diff --git a/public/css/vc.css b/public/css/vc.css
index 377f19a..e05c3cb 100644
--- a/public/css/vc.css
+++ b/public/css/vc.css
@@ -31,23 +31,28 @@
}
.vc .rewritten .rewrite {
- color: red;
- font-weight: bold;
- background-color: yellow;
- width: 1.5em;
- height: 1.2em;
- margin-left: 2px;
- border-radius: 8pt;
+ margin-left: 4pt;
display: inline-block;
+ color: #ffa500;
+}
+
+.vc .rewritten .rewrite:after {
+ font-family: FontAwesome;
+ font-style: normal;
+ font-weight: normal;
+ content: "\f040"; // "\f14b";
+ text-decoration: underline;
}
.vc .rewritten .rewrite span {
display: none;
}
+/*
.vc .rewritten .rewrite:hover span {
display: block;
}
+*/
.vc .docGroup .docGroup {
display: block;
diff --git a/public/js/demo/vc.html b/public/js/demo/vc.html
index 9254d68..ea4a53c 100644
--- a/public/js/demo/vc.html
+++ b/public/js/demo/vc.html
@@ -3,6 +3,7 @@
<head>
<title>Virtual Collection demo</title>
<meta charset="utf-8" />
+ <script src="../src/menu.js"></script>
<script src="../src/vc.js"></script>
<link href="../../css/vc.css" rel="stylesheet" type="text/css"></link>
<style type="text/css" rel="stylesheet">
@@ -16,46 +17,47 @@
</head>
<body>
<div id="vc"></div>
+ <div id="menu"></div>
<script>
var json = {
- "@type":"korap:docGroup",
+ "@type":"koral:docGroup",
"operation":"operation:or",
"operands":[
{
- "@type":"korap:docGroup",
+ "@type":"koral:docGroup",
"operation":"operation:and",
"operands":[
{
- "@type":"korap:doc",
+ "@type":"koral:doc",
"key":"Titel",
"value":"Baum",
"match":"match:eq"
},
{
- "@type":"korap:doc",
+ "@type":"koral:doc",
"key":"Veröffentlichungsort",
"value":"hihi",
"match":"match:eq"
},
{
- "@type":"korap:docGroup",
+ "@type":"koral:docGroup",
"operation":"operation:or",
"operands":[
{
- "@type":"korap:doc",
+ "@type":"koral:doc",
"key":"Titel",
"value":"Baum",
"match":"match:eq"
},
{
- "@type":"korap:doc",
+ "@type":"koral:doc",
"key":"Veröffentlichungsort",
"value":"hihi",
"match":"match:eq",
"rewrites" : [
{
- "@type": "korap:rewrite",
+ "@type": "koral:rewrite",
"src" : "policy",
"operation" : "operation:injection",
}
@@ -66,7 +68,7 @@
]
},
{
- "@type":"korap:doc",
+ "@type":"koral:doc",
"key":"Untertitel",
"value":"huhu",
"match":"match:eq"
@@ -87,6 +89,19 @@
document.getElementById("query").innerHTML = vc.root().toQuery();
};
+ var menu = KorAP.FieldMenu.create([
+ ['Titel', 'title', 'string'],
+ ['Untertitel', 'subTitle', 'string'],
+ ['Veröffentlichungsdatum', 'pubDate', 'date']
+ ]);
+ menu.limit(4);
+ menu.show();
+
+ document.getElementById('menu').appendChild(menu.element());
+
+ menu.focus();
+
+
</script>
<hr />
diff --git a/public/js/runner/vc.html b/public/js/runner/vc.html
index e010587..f0e8179 100644
--- a/public/js/runner/vc.html
+++ b/public/js/runner/vc.html
@@ -8,6 +8,7 @@
<script src="../lib/jasmine-2.1.1/jasmine.js"></script>
<script src="../lib/jasmine-2.1.1/jasmine-html.js"></script>
<script src="../lib/jasmine-2.1.1/boot.js"></script>
+ <script src="../src/menu.js"></script>
<script src="../src/vc.js"></script>
<script src="../spec/vcSpec.js"></script>
</head>
diff --git a/public/js/spec/hintSpec.js b/public/js/spec/hintSpec.js
index 80807ff..a7232d4 100644
--- a/public/js/spec/hintSpec.js
+++ b/public/js/spec/hintSpec.js
@@ -705,4 +705,81 @@
var hint = KorAP.Hint.create();
});
});
+
+
+describe('KorAP.ContextAnalyzer', function () {
+
+ it('should be initializable', function () {
+ var analyzer = KorAP.ContextAnalyzer.create(")");
+ expect(analyzer).toBe(undefined);
+
+ analyzer = KorAP.ContextAnalyzer.create(".+?");
+ expect(analyzer).not.toBe(undefined);
+
+ });
+
+ it('should check correctly', function () {
+ analyzer = KorAP.ContextAnalyzer.create(KorAP.context);
+ expect(analyzer.test("cnx/]cnx/c=")).toEqual("cnx/c=");
+ expect(analyzer.test("cnx/c=")).toEqual("cnx/c=");
+ expect(analyzer.test("cnx/c=np mate/m=mood:")).toEqual("mate/m=mood:");
+ 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=");
+ });
+});
+
+describe('KorAP.InputField', function () {
+ var input;
+
+ beforeAll(function () {
+ input = document.createElement("input");
+ input.setAttribute("type", "text");
+ input.setAttribute("value", "abcdefghijklmno");
+ input.style.position = 'absolute';
+ input.style.top = "20px";
+ input.style.left = "30px";
+ input.focus();
+ input.selectionStart = 5;
+ });
+
+ afterAll(function () {
+ document.getElementsByTagName("body")[0].removeChild(input);
+ document.getElementsByTagName("body")[0].removeChild(
+ document.getElementById("searchMirror")
+ );
+ });
+
+ it('should be initializable', function () {
+ // Supports: context, searchField
+ var inputField = KorAP.InputField.create(input);
+ expect(inputField._element).not.toBe(undefined);
+ });
+
+ it('should have text', function () {
+ var inputField = KorAP.InputField.create(input);
+
+ expect(inputField.value).toEqual("abcdefghijklmno");
+ expect(inputField.element.selectionStart).toEqual(5);
+ expect(inputField.split()[0]).toEqual("abcde");
+ expect(inputField.split()[1]).toEqual("fghijklmno");
+
+ inputField.insert("xyz");
+ expect(inputField.split()[0]).toEqual("abcdexyz");
+ expect(inputField.split()[1]).toEqual("fghijklmno");
+
+ });
+
+ it('should be correctly positioned', function () {
+ var inputField = KorAP.InputField.create(input);
+ document.getElementsByTagName("body")[0].appendChild(input);
+ inputField.reposition();
+ expect(inputField.mirror.style.left).toEqual("30px");
+ expect(inputField.mirror.style.top.match(/^(\d+)px$/)[1]).toBeGreaterThan(20);
+ });
+});
+
+
+
*/
diff --git a/public/js/spec/menuSpec.js b/public/js/spec/menuSpec.js
index 98f6e72..cc569a8 100644
--- a/public/js/spec/menuSpec.js
+++ b/public/js/spec/menuSpec.js
@@ -1,3 +1,4 @@
+// The OwnMenu item
KorAP.OwnMenuItem = {
create : function (params) {
return Object.create(KorAP.MenuItem).upgradeTo(KorAP.OwnMenuItem)._init(params);
@@ -19,36 +20,8 @@
}
};
-KorAP.ComplexMenuItem = {
- create : function (params) {
- return Object.create(KorAP.MenuItem)
- .upgradeTo(KorAP.ComplexMenuItem)
- ._init(params);
- },
- content : function (content) {
- if (arguments.length === 1) {
- this._content = content;
- };
- return this._content;
- },
- _init : function (params) {
- if (params[0] === undefined)
- throw new Error("Missing parameters");
- var r = document.createElement('div');
- for (var i = 1; i <= params.length; i++) {
- var h = document.createElement('h' + i);
- h.appendChild(document.createTextNode(params[i-1]));
- r.appendChild(h);
- };
-
- this._content = r;
- this._lcField = ' ' + this.content().textContent.toLowerCase();
-
- return this;
- }
-};
-
+// The OwnMenu
KorAP.OwnMenu = {
create : function (params) {
return Object.create(KorAP.Menu)
@@ -58,17 +31,7 @@
};
-// Support for hint
-KorAP.HintMenu = {
- create : function (context, params) {
- var obj = Object.create(KorAP.Menu)
- .upgradeTo(KorAP.HintMenu)
- ._init(KorAP.HintMenuItem, params);
- obj._context = context;
- return obj;
- }
-};
-
+// HintMenuItem
KorAP.HintMenuItem = {
create : function (params) {
return Object.create(KorAP.MenuItem)
@@ -131,6 +94,50 @@
};
+// HintMenu
+KorAP.HintMenu = {
+ create : function (context, params) {
+ var obj = Object.create(KorAP.Menu)
+ .upgradeTo(KorAP.HintMenu)
+ ._init(KorAP.HintMenuItem, params);
+ obj._context = context;
+ return obj;
+ }
+};
+
+
+// The ComplexMenuItem
+KorAP.ComplexMenuItem = {
+ create : function (params) {
+ return Object.create(KorAP.MenuItem)
+ .upgradeTo(KorAP.ComplexMenuItem)
+ ._init(params);
+ },
+ content : function (content) {
+ if (arguments.length === 1) {
+ this._content = content;
+ };
+ return this._content;
+ },
+ _init : function (params) {
+ if (params[0] === undefined)
+ throw new Error("Missing parameters");
+
+ var r = document.createElement('div');
+ for (var i = 1; i <= params.length; i++) {
+ var h = document.createElement('h' + i);
+ h.appendChild(document.createTextNode(params[i-1]));
+ r.appendChild(h);
+ };
+
+ this._content = r;
+ this._lcField = ' ' + this.content().textContent.toLowerCase();
+
+ return this;
+ }
+};
+
+
describe('KorAP.MenuItem', function () {
it('should be initializable', function () {
@@ -305,6 +312,14 @@
describe('KorAP.Menu', function () {
+ var list = [
+ ["Constituency", "c=", "Example 1"],
+ ["Lemma", "l="],
+ ["Morphology", "m=", "Example 2"],
+ ["Part-of-Speech", "p="],
+ ["Syntax", "syn="]
+ ];
+
it('should be initializable', function () {
var list = [
["Constituency"],
@@ -342,13 +357,6 @@
});
it('should be visible', function () {
- var list = [
- ["Constituency", "c=", "Example 1"],
- ["Lemma", "l="],
- ["Morphology", "m=", "Example 2"],
- ["Part-of-Speech", "p="],
- ["Syntax", "syn="]
- ];
var menu = KorAP.HintMenu.create("cnx/", list);
expect(menu.delete()).toBe(undefined);
menu.limit(3);
@@ -368,14 +376,6 @@
});
it('should be filterable', function () {
- var list = [
- ["Constituency", "c=", "Example 1"],
- ["Lemma", "l="],
- ["Morphology", "m=", "Example 2"],
- ["Part-of-Speech", "p="],
- ["Syntax", "syn="]
- ];
-
var menu = KorAP.HintMenu.create("cnx/", list);
menu.limit(3);
@@ -421,14 +421,6 @@
it('should be nextable', function () {
- var list = [
- ["Constituency", "c=", "Example 1"],
- ["Lemma", "l="],
- ["Morphology", "m=", "Example 2"],
- ["Part-of-Speech", "p="],
- ["Syntax", "syn="]
- ];
-
var menu = KorAP.HintMenu.create("cnx/", list);
// Show only 3 items
@@ -464,332 +456,249 @@
expect(menu.element().childNodes[3]).toBe(undefined);
// Activate next (3)
+ // scroll!
menu.next();
-// expect(menu.element().childNodes[0].innerHTML).toEqual("<strong>Lemma</strong>");
+ expect(menu.element().childNodes[0].innerHTML).toEqual("<strong>Lemma</strong>");
+
expect(menu.shownItem(0).active()).toBe(false);
-// expect(menu.element().childNodes[1].innerHTML).toEqual("<strong>Morphology</strong><span>Example 2</span>");
+ expect(menu.element().childNodes[1].innerHTML).toEqual("<strong>Morphology</strong><span>Example 2</span>");
expect(menu.shownItem(1).active()).toBe(false);
-// expect(menu.element().childNodes[2].innerHTML).toEqual("<strong>Part-of-Speech</strong>");
+ expect(menu.element().childNodes[2].innerHTML).toEqual("<strong>Part-of-Speech</strong>");
expect(menu.shownItem(2).active()).toBe(true);
expect(menu.element().childNodes[3]).toBe(undefined);
- });
-});
-
-
-/*
-describe('KorAP.Menu', function () {
-
-
// Activate next (4)
menu.next();
- expect(menu.element.childNodes[0].innerHTML).toEqual("<strong>Morphology</strong><span>Example 2</span>");
+ expect(menu.element().childNodes[0].innerHTML).toEqual("<strong>Morphology</strong><span>Example 2</span>");
expect(menu.shownItem(0).active()).toBe(false);
- expect(menu.element.childNodes[1].innerHTML).toEqual("<strong>Part-of-Speech</strong>");
+ expect(menu.element().childNodes[1].innerHTML).toEqual("<strong>Part-of-Speech</strong>");
expect(menu.shownItem(1).active()).toBe(false);
- expect(menu.element.childNodes[2].innerHTML).toEqual("<strong>Syntax</strong>");
+ expect(menu.element().childNodes[2].innerHTML).toEqual("<strong>Syntax</strong>");
expect(menu.shownItem(2).active()).toBe(true);
- expect(menu.element.childNodes[3]).toBe(undefined);
+ expect(menu.element().childNodes[3]).toBe(undefined);
// Activate next (5) - ROLL
menu.next();
- expect(menu.element.childNodes[0].innerHTML).toEqual("<strong>Constituency</strong><span>Example 1</span>");
+ expect(menu.element().childNodes[0].innerHTML).toEqual("<strong>Constituency</strong><span>Example 1</span>");
expect(menu.shownItem(0).active()).toBe(true);
- expect(menu.element.childNodes[1].innerHTML).toEqual("<strong>Lemma</strong>");
+ expect(menu.element().childNodes[1].innerHTML).toEqual("<strong>Lemma</strong>");
expect(menu.shownItem(1).active()).toBe(false);
- expect(menu.element.childNodes[2].innerHTML).toEqual("<strong>Morphology</strong><span>Example 2</span>");
+ expect(menu.element().childNodes[2].innerHTML).toEqual("<strong>Morphology</strong><span>Example 2</span>");
expect(menu.shownItem(2).active()).toBe(false);
- expect(menu.element.childNodes[3]).toBe(undefined);
+ expect(menu.element().childNodes[3]).toBe(undefined);
// Active next (6)
menu.next();
- expect(menu.element.childNodes[0].innerHTML).toEqual("<strong>Constituency</strong><span>Example 1</span>");
+ expect(menu.element().childNodes[0].innerHTML).toEqual("<strong>Constituency</strong><span>Example 1</span>");
expect(menu.shownItem(0).active()).toBe(false);
- expect(menu.element.childNodes[1].innerHTML).toEqual("<strong>Lemma</strong>");
+ expect(menu.element().childNodes[1].innerHTML).toEqual("<strong>Lemma</strong>");
expect(menu.shownItem(1).active()).toBe(true);
- expect(menu.element.childNodes[2].innerHTML).toEqual("<strong>Morphology</strong><span>Example 2</span>");
+ expect(menu.element().childNodes[2].innerHTML).toEqual("<strong>Morphology</strong><span>Example 2</span>");
expect(menu.shownItem(2).active()).toBe(false);
- expect(menu.element.childNodes[3]).toBe(undefined);
-
+ expect(menu.element().childNodes[3]).toBe(undefined);
});
-
it('should be prevable', function () {
- var menu = KorAP.Menu.create("cnx/", list);
+ var menu = KorAP.HintMenu.create("cnx/", list);
- KorAP.limit = 3;
+ menu.limit(3);
expect(menu.show()).toBe(undefined);
- expect(menu.element.childNodes[0].innerHTML).toEqual("<strong>Constituency</strong><span>Example 1</span>");
+ expect(menu.element().childNodes[0].innerHTML).toEqual("<strong>Constituency</strong><span>Example 1</span>");
expect(menu.shownItem(0).active()).toBe(true);
- expect(menu.element.childNodes[1].innerHTML).toEqual("<strong>Lemma</strong>");
+ expect(menu.element().childNodes[1].innerHTML).toEqual("<strong>Lemma</strong>");
expect(menu.shownItem(1).active()).toBe(false);
- expect(menu.element.childNodes[2].innerHTML).toEqual("<strong>Morphology</strong><span>Example 2</span>");
+ expect(menu.element().childNodes[2].innerHTML).toEqual("<strong>Morphology</strong><span>Example 2</span>");
expect(menu.shownItem(2).active()).toBe(false);
- expect(menu.element.childNodes[3]).toBe(undefined);
+ expect(menu.element().childNodes[3]).toBe(undefined);
// Activate prev (1) - roll to bottom
menu.prev();
- expect(menu.element.childNodes[0].innerHTML).toEqual("<strong>Morphology</strong><span>Example 2</span>");
+ expect(menu.element().childNodes[0].innerHTML).toEqual("<strong>Morphology</strong><span>Example 2</span>");
expect(menu.shownItem(0).active()).toBe(false);
- expect(menu.element.childNodes[1].innerHTML).toEqual("<strong>Part-of-Speech</strong>");
+ expect(menu.element().childNodes[1].innerHTML).toEqual("<strong>Part-of-Speech</strong>");
expect(menu.shownItem(1).active()).toBe(false);
- expect(menu.element.childNodes[2].innerHTML).toEqual("<strong>Syntax</strong>");
+ expect(menu.element().childNodes[2].innerHTML).toEqual("<strong>Syntax</strong>");
expect(menu.shownItem(2).active()).toBe(true);
- expect(menu.element.childNodes[3]).toBe(undefined);
+ expect(menu.element().childNodes[3]).toBe(undefined);
// Activate prev (2)
menu.prev();
- expect(menu.element.childNodes[0].innerHTML).toEqual("<strong>Morphology</strong><span>Example 2</span>");
+ expect(menu.element().childNodes[0].innerHTML).toEqual("<strong>Morphology</strong><span>Example 2</span>");
expect(menu.shownItem(0).active()).toBe(false);
- expect(menu.element.childNodes[1].innerHTML).toEqual("<strong>Part-of-Speech</strong>");
+ expect(menu.element().childNodes[1].innerHTML).toEqual("<strong>Part-of-Speech</strong>");
expect(menu.shownItem(1).active()).toBe(true);
- expect(menu.element.childNodes[2].innerHTML).toEqual("<strong>Syntax</strong>");
+ expect(menu.element().childNodes[2].innerHTML).toEqual("<strong>Syntax</strong>");
expect(menu.shownItem(2).active()).toBe(false);
- expect(menu.element.childNodes[3]).toBe(undefined);
+ expect(menu.element().childNodes[3]).toBe(undefined);
// Activate prev (3)
menu.prev();
- expect(menu.shownItem(0).name).toEqual("Morphology");
+ expect(menu.shownItem(0).name()).toEqual("Morphology");
expect(menu.shownItem(0).active()).toBe(true);
- expect(menu.shownItem(1).name).toEqual("Part-of-Speech");
+ expect(menu.shownItem(1).name()).toEqual("Part-of-Speech");
expect(menu.shownItem(1).active()).toBe(false);
- expect(menu.shownItem(2).name).toEqual("Syntax");
+ expect(menu.shownItem(2).name()).toEqual("Syntax");
expect(menu.shownItem(2).active()).toBe(false);
- expect(menu.element.childNodes[3]).toBe(undefined);
+ expect(menu.element().childNodes[3]).toBe(undefined);
// Activate prev (4)
menu.prev();
- expect(menu.shownItem(0).name).toEqual("Lemma");
+ expect(menu.shownItem(0).name()).toEqual("Lemma");
expect(menu.shownItem(0).active()).toBe(true);
- expect(menu.shownItem(1).name).toEqual("Morphology");
+ expect(menu.shownItem(1).name()).toEqual("Morphology");
expect(menu.shownItem(1).active()).toBe(false);
- expect(menu.shownItem(2).name).toEqual("Part-of-Speech");
+ expect(menu.shownItem(2).name()).toEqual("Part-of-Speech");
expect(menu.shownItem(2).active()).toBe(false);
- expect(menu.element.childNodes[3]).toBe(undefined);
+ expect(menu.element().childNodes[3]).toBe(undefined);
// Activate prev (5)
menu.prev();
- expect(menu.shownItem(0).name).toEqual("Constituency");
+ expect(menu.shownItem(0).name()).toEqual("Constituency");
expect(menu.shownItem(0).active()).toBe(true);
- expect(menu.shownItem(1).name).toEqual("Lemma");
+ expect(menu.shownItem(1).name()).toEqual("Lemma");
expect(menu.shownItem(1).active()).toBe(false);
- expect(menu.shownItem(2).name).toEqual("Morphology");
+ expect(menu.shownItem(2).name()).toEqual("Morphology");
expect(menu.shownItem(2).active()).toBe(false);
- expect(menu.element.childNodes[3]).toBe(undefined);
+ expect(menu.element().childNodes[3]).toBe(undefined);
// Activate next (1)
menu.next();
- expect(menu.shownItem(0).name).toEqual("Constituency");
+ expect(menu.shownItem(0).name()).toEqual("Constituency");
expect(menu.shownItem(0).active()).toBe(false);
- expect(menu.shownItem(1).name).toEqual("Lemma");
+ expect(menu.shownItem(1).name()).toEqual("Lemma");
expect(menu.shownItem(1).active()).toBe(true);
- expect(menu.shownItem(2).name).toEqual("Morphology");
+ expect(menu.shownItem(2).name()).toEqual("Morphology");
expect(menu.shownItem(2).active()).toBe(false);
- expect(menu.element.childNodes[3]).toBe(undefined);
+ expect(menu.element().childNodes[3]).toBe(undefined);
// Activate prev (6)
menu.prev();
// Activate prev (7)
menu.prev();
- expect(menu.shownItem(0).name).toEqual("Morphology");
+ expect(menu.shownItem(0).name()).toEqual("Morphology");
expect(menu.shownItem(0).active()).toBe(false);
- expect(menu.shownItem(1).name).toEqual("Part-of-Speech");
+ expect(menu.shownItem(1).name()).toEqual("Part-of-Speech");
expect(menu.shownItem(1).active()).toBe(false);
- expect(menu.shownItem(2).name).toEqual("Syntax");
+ expect(menu.shownItem(2).name()).toEqual("Syntax");
expect(menu.shownItem(2).active()).toBe(true);
- expect(menu.element.childNodes[3]).toBe(undefined);
+ expect(menu.element().childNodes[3]).toBe(undefined);
});
- it('should be navigatable and filterable (prefix = "o")', function () {
- var menu = KorAP.Menu.create("cnx/", list);
- KorAP.limit = 2;
+ it('should be navigatable and filterable (prefix = "o")', function () {
+ var menu = KorAP.HintMenu.create("cnx/", list);
+ menu.limit(2);
expect(menu.show("o")).toBe(undefined);
- expect(menu.shownItem(0).name).toEqual("Constituency");
- expect(menu.element.childNodes[0].innerHTML).toEqual("<strong>C<em>o</em>nstituency</strong><span>Example 1</span>");
+ expect(menu.shownItem(0).name()).toEqual("Constituency");
+ expect(menu.element().childNodes[0].innerHTML).toEqual("<strong>C<mark>o</mark>nstituency</strong><span>Example 1</span>");
expect(menu.shownItem(0).active()).toBe(true);
- expect(menu.shownItem(1).name).toEqual("Morphology");
- expect(menu.element.childNodes[1].innerHTML).toEqual("<strong>M<em>o</em>rphology</strong><span>Example 2</span>");
+ expect(menu.shownItem(1).name()).toEqual("Morphology");
+ expect(menu.element().childNodes[1].innerHTML).toEqual("<strong>M<mark>o</mark>rph<mark>o</mark>l<mark>o</mark>gy</strong><span>Example 2</span>");
expect(menu.shownItem(1).active()).toBe(false);
expect(menu.shownItem(2)).toBe(undefined);
// Next (1)
menu.next();
- expect(menu.shownItem(0).name).toEqual("Constituency");
- expect(menu.element.childNodes[0].innerHTML).toEqual("<strong>C<em>o</em>nstituency</strong><span>Example 1</span>");
+ expect(menu.shownItem(0).name()).toEqual("Constituency");
+ expect(menu.element().childNodes[0].innerHTML).toEqual("<strong>C<mark>o</mark>nstituency</strong><span>Example 1</span>");
expect(menu.shownItem(0).active()).toBe(false);
- expect(menu.shownItem(1).name).toEqual("Morphology");
- expect(menu.element.childNodes[1].innerHTML).toEqual("<strong>M<em>o</em>rphology</strong><span>Example 2</span>");
+ expect(menu.shownItem(1).name()).toEqual("Morphology");
+ expect(menu.element().childNodes[1].innerHTML).toEqual("<strong>M<mark>o</mark>rph<mark>o</mark>l<mark>o</mark>gy</strong><span>Example 2</span>");
expect(menu.shownItem(1).active()).toBe(true);
expect(menu.shownItem(2)).toBe(undefined);
-
// Next (2)
menu.next();
- expect(menu.shownItem(0).name).toEqual("Morphology");
- expect(menu.element.childNodes[0].innerHTML).toEqual("<strong>M<em>o</em>rphology</strong><span>Example 2</span>");
+ expect(menu.shownItem(0).name()).toEqual("Morphology");
+ expect(menu.element().childNodes[0].innerHTML).toEqual("<strong>M<mark>o</mark>rph<mark>o</mark>l<mark>o</mark>gy</strong><span>Example 2</span>");
expect(menu.shownItem(0).active()).toBe(false);
- expect(menu.shownItem(1).name).toEqual("Part-of-Speech");
- expect(menu.element.childNodes[1].innerHTML).toEqual("<strong>Part-<em>o</em>f-Speech</strong>");
+ expect(menu.shownItem(1).name()).toEqual("Part-of-Speech");
+ expect(menu.element().childNodes[1].innerHTML).toEqual("<strong>Part-<mark>o</mark>f-Speech</strong>");
expect(menu.shownItem(1).active()).toBe(true);
expect(menu.shownItem(2)).toBe(undefined);
// Next (3)
menu.next();
- expect(menu.shownItem(0).name).toEqual("Constituency");
- expect(menu.element.childNodes[0].innerHTML).toEqual("<strong>C<em>o</em>nstituency</strong><span>Example 1</span>");
+ expect(menu.shownItem(0).name()).toEqual("Constituency");
+ expect(menu.element().childNodes[0].innerHTML).toEqual("<strong>C<mark>o</mark>nstituency</strong><span>Example 1</span>");
expect(menu.shownItem(0).active()).toBe(true);
- expect(menu.shownItem(1).name).toEqual("Morphology");
- expect(menu.element.childNodes[1].innerHTML).toEqual("<strong>M<em>o</em>rphology</strong><span>Example 2</span>");
+ expect(menu.shownItem(1).name()).toEqual("Morphology");
+ expect(menu.element().childNodes[1].innerHTML).toEqual("<strong>M<mark>o</mark>rph<mark>o</mark>l<mark>o</mark>gy</strong><span>Example 2</span>");
expect(menu.shownItem(1).active()).toBe(false);
expect(menu.shownItem(2)).toBe(undefined);
});
+
it('should be navigatable and filterable (prefix = "ex", "e")', function () {
- var menu = KorAP.Menu.create("cnx/", list);
+ var menu = KorAP.HintMenu.create("cnx/", list);
- KorAP.limit = 2;
-
+ menu.limit(2);
expect(menu.show("ex")).toBe(undefined);
- expect(menu.shownItem(0).name).toEqual("Constituency");
- expect(menu.element.childNodes[0].innerHTML).toEqual("<strong>Constituency</strong><span><em>Ex</em>ample 1</span>");
+ expect(menu.shownItem(0).name()).toEqual("Constituency");
+ expect(menu.element().childNodes[0].innerHTML).toEqual("<strong>Constituency</strong><span><mark>Ex</mark>ample 1</span>");
expect(menu.shownItem(0).active()).toBe(true);
- expect(menu.shownItem(1).name).toEqual("Morphology");
- expect(menu.element.childNodes[1].innerHTML).toEqual("<strong>Morphology</strong><span><em>Ex</em>ample 2</span>");
+ expect(menu.shownItem(1).name()).toEqual("Morphology");
+ expect(menu.element().childNodes[1].innerHTML).toEqual("<strong>Morphology</strong><span><mark>Ex</mark>ample 2</span>");
expect(menu.shownItem(1).active()).toBe(false);
expect(menu.shownItem(2)).toBe(undefined);
// Next (1)
menu.next();
- expect(menu.shownItem(0).name).toEqual("Constituency");
- expect(menu.element.childNodes[0].innerHTML).toEqual("<strong>Constituency</strong><span><em>Ex</em>ample 1</span>");
+ expect(menu.shownItem(0).name()).toEqual("Constituency");
+ expect(menu.element().childNodes[0].innerHTML).toEqual("<strong>Constituency</strong><span><mark>Ex</mark>ample 1</span>");
expect(menu.shownItem(0).active()).toBe(false);
- expect(menu.shownItem(1).name).toEqual("Morphology");
- expect(menu.element.childNodes[1].innerHTML).toEqual("<strong>Morphology</strong><span><em>Ex</em>ample 2</span>");
+ expect(menu.shownItem(1).name()).toEqual("Morphology");
+ expect(menu.element().childNodes[1].innerHTML).toEqual("<strong>Morphology</strong><span><mark>Ex</mark>ample 2</span>");
expect(menu.shownItem(1).active()).toBe(true);
expect(menu.shownItem(2)).toBe(undefined);
// Next (2)
menu.next();
- expect(menu.shownItem(0).name).toEqual("Constituency");
- expect(menu.element.childNodes[0].innerHTML).toEqual("<strong>Constituency</strong><span><em>Ex</em>ample 1</span>");
+ expect(menu.shownItem(0).name()).toEqual("Constituency");
+ expect(menu.element().childNodes[0].innerHTML).toEqual("<strong>Constituency</strong><span><mark>Ex</mark>ample 1</span>");
expect(menu.shownItem(0).active()).toBe(true);
- expect(menu.shownItem(1).name).toEqual("Morphology");
- expect(menu.element.childNodes[1].innerHTML).toEqual("<strong>Morphology</strong><span><em>Ex</em>ample 2</span>");
+ expect(menu.shownItem(1).name()).toEqual("Morphology");
+ expect(menu.element().childNodes[1].innerHTML).toEqual("<strong>Morphology</strong><span><mark>Ex</mark>ample 2</span>");
expect(menu.shownItem(1).active()).toBe(false);
expect(menu.shownItem(2)).toBe(undefined);
// Reset limit
- KorAP.limit = 5;
+ menu.limit(5);
// Change show
expect(menu.show("e")).toBe(undefined);
- expect(menu.shownItem(0).name).toEqual("Constituency");
- expect(menu.element.childNodes[0].innerHTML).toEqual("<strong>Constitu<em>e</em>ncy</strong><span><em>E</em>xample 1</span>");
+ expect(menu.shownItem(0).name()).toEqual("Constituency");
+ expect(menu.element().childNodes[0].innerHTML).toEqual("<strong>Constitu<mark>e</mark>ncy</strong><span><mark>E</mark>xampl<mark>e</mark> 1</span>");
expect(menu.shownItem(0).active()).toBe(true);
- expect(menu.shownItem(1).name).toEqual("Morphology");
- expect(menu.element.childNodes[1].innerHTML).toEqual("<strong>Morphology</strong><span><em>E</em>xample 2</span>");
+ expect(menu.shownItem(1).name()).toEqual("Morphology");
+ expect(menu.element().childNodes[1].innerHTML).toEqual("<strong>Morphology</strong><span><mark>E</mark>xampl<mark>e</mark> 2</span>");
expect(menu.shownItem(1).active()).toBe(false);
expect(menu.shownItem(2)).toBe(undefined);
// Next (1)
menu.next();
- expect(menu.shownItem(0).name).toEqual("Constituency");
- expect(menu.element.childNodes[0].innerHTML).toEqual("<strong>Constitu<em>e</em>ncy</strong><span><em>E</em>xample 1</span>");
+ expect(menu.shownItem(0).name()).toEqual("Constituency");
+ expect(menu.element().childNodes[0].innerHTML).toEqual("<strong>Constitu<mark>e</mark>ncy</strong><span><mark>E</mark>xampl<mark>e</mark> 1</span>");
expect(menu.shownItem(0).active()).toBe(false);
- expect(menu.shownItem(1).name).toEqual("Morphology");
- expect(menu.element.childNodes[1].innerHTML).toEqual("<strong>Morphology</strong><span><em>E</em>xample 2</span>");
+ expect(menu.shownItem(1).name()).toEqual("Morphology");
+ expect(menu.element().childNodes[1].innerHTML).toEqual("<strong>Morphology</strong><span><mark>E</mark>xampl<mark>e</mark> 2</span>");
expect(menu.shownItem(1).active()).toBe(true);
expect(menu.shownItem(2)).toBe(undefined);
// Next (2)
menu.next();
- expect(menu.shownItem(0).name).toEqual("Constituency");
- expect(menu.element.childNodes[0].innerHTML).toEqual("<strong>Constitu<em>e</em>ncy</strong><span><em>E</em>xample 1</span>");
+ expect(menu.shownItem(0).name()).toEqual("Constituency");
+ expect(menu.element().childNodes[0].innerHTML).toEqual("<strong>Constitu<mark>e</mark>ncy</strong><span><mark>E</mark>xampl<mark>e</mark> 1</span>");
expect(menu.shownItem(0).active()).toBe(true);
- expect(menu.shownItem(1).name).toEqual("Morphology");
- expect(menu.element.childNodes[1].innerHTML).toEqual("<strong>Morphology</strong><span><em>E</em>xample 2</span>");
+ expect(menu.shownItem(1).name()).toEqual("Morphology");
+ expect(menu.element().childNodes[1].innerHTML).toEqual("<strong>Morphology</strong><span><mark>E</mark>xampl<mark>e</mark> 2</span>");
expect(menu.shownItem(1).active()).toBe(false);
expect(menu.shownItem(2)).toBe(undefined);
});
});
-
-describe('KorAP.ContextAnalyzer', function () {
-
- it('should be initializable', function () {
- var analyzer = KorAP.ContextAnalyzer.create(")");
- expect(analyzer).toBe(undefined);
-
- analyzer = KorAP.ContextAnalyzer.create(".+?");
- expect(analyzer).not.toBe(undefined);
-
- });
-
- it('should check correctly', function () {
- analyzer = KorAP.ContextAnalyzer.create(KorAP.context);
- expect(analyzer.test("cnx/]cnx/c=")).toEqual("cnx/c=");
- expect(analyzer.test("cnx/c=")).toEqual("cnx/c=");
- expect(analyzer.test("cnx/c=np mate/m=mood:")).toEqual("mate/m=mood:");
- 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=");
- });
-});
-
-describe('KorAP.InputField', function () {
- var input;
-
- beforeAll(function () {
- input = document.createElement("input");
- input.setAttribute("type", "text");
- input.setAttribute("value", "abcdefghijklmno");
- input.style.position = 'absolute';
- input.style.top = "20px";
- input.style.left = "30px";
- input.focus();
- input.selectionStart = 5;
- });
-
- afterAll(function () {
- document.getElementsByTagName("body")[0].removeChild(input);
- document.getElementsByTagName("body")[0].removeChild(
- document.getElementById("searchMirror")
- );
- });
-
- it('should be initializable', function () {
- // Supports: context, searchField
- var inputField = KorAP.InputField.create(input);
- expect(inputField._element).not.toBe(undefined);
- });
-
- it('should have text', function () {
- var inputField = KorAP.InputField.create(input);
-
- expect(inputField.value).toEqual("abcdefghijklmno");
- expect(inputField.element.selectionStart).toEqual(5);
- expect(inputField.split()[0]).toEqual("abcde");
- expect(inputField.split()[1]).toEqual("fghijklmno");
-
- inputField.insert("xyz");
- expect(inputField.split()[0]).toEqual("abcdexyz");
- expect(inputField.split()[1]).toEqual("fghijklmno");
-
- });
-
- it('should be correctly positioned', function () {
- var inputField = KorAP.InputField.create(input);
- document.getElementsByTagName("body")[0].appendChild(input);
- inputField.reposition();
- expect(inputField.mirror.style.left).toEqual("30px");
- expect(inputField.mirror.style.top.match(/^(\d+)px$/)[1]).toBeGreaterThan(20);
- });
-});
-*/
diff --git a/public/js/spec/vcSpec.js b/public/js/spec/vcSpec.js
index 49e9275..1a24fb6 100644
--- a/public/js/spec/vcSpec.js
+++ b/public/js/spec/vcSpec.js
@@ -35,37 +35,37 @@
};
var demoFactory = buildFactory(KorAP.VirtualCollection, {
- "@type":"korap:docGroup",
+ "@type":"koral:docGroup",
"operation":"operation:or",
"operands":[
{
- "@type":"korap:docGroup",
+ "@type":"koral:docGroup",
"operation":"operation:and",
"operands":[
{
- "@type":"korap:doc",
+ "@type":"koral:doc",
"key":"Titel",
"value":"Baum",
"match":"match:eq"
},
{
- "@type":"korap:doc",
+ "@type":"koral:doc",
"key":"Veröffentlichungsort",
"value":"hihi",
"match":"match:eq"
},
{
- "@type":"korap:docGroup",
+ "@type":"koral:docGroup",
"operation":"operation:or",
"operands":[
{
- "@type":"korap:doc",
+ "@type":"koral:doc",
"key":"Titel",
"value":"Baum",
"match":"match:eq"
},
{
- "@type":"korap:doc",
+ "@type":"koral:doc",
"key":"Veröffentlichungsort",
"value":"hihi",
"match":"match:eq"
@@ -75,7 +75,7 @@
]
},
{
- "@type":"korap:doc",
+ "@type":"koral:doc",
"key":"Untertitel",
"value":"huhu",
"match":"match:eq"
@@ -90,7 +90,7 @@
var stringFactory = buildFactory(KorAP.Doc, {
"key" : "author",
"value" : "Max Birkendale",
- "@type" : "korap:doc"
+ "@type" : "koral:doc"
});
// Create example factories
@@ -99,7 +99,7 @@
"type" : "type:date",
"match" : "match:eq",
"value" : "2014-11-05",
- "@type" : "korap:doc"
+ "@type" : "koral:doc"
});
// Create example factories
@@ -107,7 +107,7 @@
"key" : "title",
"type" : "type:regex",
"value" : "[^b]ee.+?",
- "@type" : "korap:doc"
+ "@type" : "koral:doc"
});
it('should be initializable', function () {
@@ -251,7 +251,7 @@
// Serialize string
doc = stringFactory.create();
expect(doc.toJson()).toEqual(jasmine.objectContaining({
- "@type" : "korap:doc",
+ "@type" : "koral:doc",
"type" : "type:string",
"key" : "author",
"value" : "Max Birkendale",
@@ -261,7 +261,7 @@
// Serialize regex
doc = regexFactory.create();
expect(doc.toJson()).toEqual(jasmine.objectContaining({
- "@type" : "korap:doc",
+ "@type" : "koral:doc",
"type" : "type:regex",
"value" : "[^b]ee.+?",
"match" : "match:eq",
@@ -272,7 +272,7 @@
match: "match:ne"
});
expect(doc.toJson()).toEqual(jasmine.objectContaining({
- "@type" : "korap:doc",
+ "@type" : "koral:doc",
"type" : "type:regex",
"value" : "[^b]ee.+?",
"match" : "match:ne",
@@ -281,7 +281,7 @@
doc = dateFactory.create();
expect(doc.toJson()).toEqual(jasmine.objectContaining({
- "@type" : "korap:doc",
+ "@type" : "koral:doc",
"type" : "type:date",
"value" : "2014-11-05",
"match" : "match:eq",
@@ -292,7 +292,7 @@
value : "2014"
});
expect(doc.toJson()).toEqual(jasmine.objectContaining({
- "@type" : "korap:doc",
+ "@type" : "koral:doc",
"type" : "type:date",
"value" : "2014",
"match" : "match:eq",
@@ -339,7 +339,7 @@
var docFactory = buildFactory(
KorAP.Doc,
{
- "@type" : "korap:doc",
+ "@type" : "koral:doc",
"match":"match:eq",
"key" : "author",
"value" : "Max Birkendale"
@@ -348,7 +348,7 @@
var docGroupFactory = buildFactory(
KorAP.DocGroup, {
- "@type" : "korap:docGroup",
+ "@type" : "koral:docGroup",
"operation" : "operation:and",
"operands" : [
docFactory.create().toJson(),
@@ -455,18 +455,18 @@
var docGroup = docGroupFactory.create();
expect(docGroup.toJson()).toEqual(jasmine.objectContaining({
- "@type" : "korap:docGroup",
+ "@type" : "koral:docGroup",
"operation" : "operation:and",
"operands" : [
{
- "@type": 'korap:doc',
+ "@type": 'koral:doc',
"key" : 'author',
"match": 'match:eq',
"value": 'Max Birkendale',
"type": 'type:string'
},
{
- "@type": 'korap:doc',
+ "@type": 'koral:doc',
"key": 'pubDate',
"match": 'match:eq',
"value": '2014-12-05',
@@ -481,36 +481,36 @@
expect(docGroup.toQuery()).toEqual('author = "Max Birkendale" & pubDate in 2014-12-05');
docGroup = docGroupFactory.create({
- "@type" : "korap:docGroup",
+ "@type" : "koral:docGroup",
"operation" : "operation:or",
"operands" : [
{
- "@type": 'korap:doc',
+ "@type": 'koral:doc',
"key" : 'author',
"match": 'match:eq',
"value": 'Max Birkendale',
"type": 'type:string'
},
{
- "@type" : "korap:docGroup",
+ "@type" : "koral:docGroup",
"operation" : "operation:and",
"operands" : [
{
- "@type": 'korap:doc',
+ "@type": 'koral:doc',
"key": 'pubDate',
"match": 'match:geq',
"value": '2014-05-12',
"type": 'type:date'
},
{
- "@type": 'korap:doc',
+ "@type": 'koral:doc',
"key": 'pubDate',
"match": 'match:leq',
"value": '2014-12-05',
"type": 'type:date'
},
{
- "@type": 'korap:doc',
+ "@type": 'koral:doc',
"key": 'foo',
"match": 'match:ne',
"value": '[a]?bar',
@@ -545,7 +545,7 @@
expect(docGroup.operation()).toEqual('or');
docGroup.append({
- "@type": 'korap:doc',
+ "@type": 'koral:doc',
"key": 'pubDate',
"match": 'match:eq',
"value": '2014-12-05',
@@ -577,7 +577,7 @@
expect(docGroup.operation()).toEqual('or');
docGroup.append({
- "@type": 'korap:doc',
+ "@type": 'koral:doc',
"key": 'pubDate',
"match": 'match:eq',
"value": '2014-12-05',
@@ -643,7 +643,7 @@
describe('KorAP.Doc element', function () {
it('should be initializable', function () {
var docElement = KorAP.Doc.create(undefined, {
- "@type" : "korap:doc",
+ "@type" : "koral:doc",
"key":"Titel",
"value":"Baum",
"match":"match:eq"
@@ -660,7 +660,7 @@
expect(docE.children[2].getAttribute('data-type')).toEqual('string');
expect(docElement.toJson()).toEqual(jasmine.objectContaining({
- "@type" : "korap:doc",
+ "@type" : "koral:doc",
"key":"Titel",
"value":"Baum",
"match":"match:eq"
@@ -672,18 +672,18 @@
it('should be initializable', function () {
var docGroup = KorAP.DocGroup.create(undefined, {
- "@type" : "korap:docGroup",
+ "@type" : "koral:docGroup",
"operation" : "operation:and",
"operands" : [
{
- "@type": 'korap:doc',
+ "@type": 'koral:doc',
"key" : 'author',
"match": 'match:eq',
"value": 'Max Birkendale',
"type": 'type:string'
},
{
- "@type": 'korap:doc',
+ "@type": 'koral:doc',
"key": 'pubDate',
"match": 'match:eq',
"value": '2014-12-05',
@@ -721,29 +721,29 @@
it('should be deserializable with nested groups', function () {
var docGroup = KorAP.DocGroup.create(undefined, {
- "@type" : "korap:docGroup",
+ "@type" : "koral:docGroup",
"operation" : "operation:or",
"operands" : [
{
- "@type": 'korap:doc',
+ "@type": 'koral:doc',
"key" : 'author',
"match": 'match:eq',
"value": 'Max Birkendale',
"type": 'type:string'
},
{
- "@type" : "korap:docGroup",
+ "@type" : "koral:docGroup",
"operation" : "operation:and",
"operands" : [
{
- "@type": 'korap:doc',
+ "@type": 'koral:doc',
"key": 'pubDate',
"match": 'match:geq',
"value": '2014-05-12',
"type": 'type:date'
},
{
- "@type": 'korap:doc',
+ "@type": 'koral:doc',
"key": 'pubDate',
"match": 'match:leq',
"value": '2014-12-05',
@@ -787,18 +787,18 @@
describe('KorAP.VirtualCollection', function () {
var simpleGroupFactory = buildFactory(KorAP.DocGroup, {
- "@type" : "korap:docGroup",
+ "@type" : "koral:docGroup",
"operation" : "operation:and",
"operands" : [
{
- "@type": 'korap:doc',
+ "@type": 'koral:doc',
"key" : 'author',
"match": 'match:eq',
"value": 'Max Birkendale',
"type": 'type:string'
},
{
- "@type": 'korap:doc',
+ "@type": 'koral:doc',
"key": 'pubDate',
"match": 'match:eq',
"value": '2014-12-05',
@@ -808,29 +808,29 @@
});
var nestedGroupFactory = buildFactory(KorAP.VirtualCollection, {
- "@type" : "korap:docGroup",
+ "@type" : "koral:docGroup",
"operation" : "operation:or",
"operands" : [
{
- "@type": 'korap:doc',
+ "@type": 'koral:doc',
"key" : 'author',
"match": 'match:eq',
"value": 'Max Birkendale',
"type": 'type:string'
},
{
- "@type" : "korap:docGroup",
+ "@type" : "koral:docGroup",
"operation" : "operation:and",
"operands" : [
{
- "@type": 'korap:doc',
+ "@type": 'koral:doc',
"key": 'pubDate',
"match": 'match:geq',
"value": '2014-05-12',
"type": 'type:date'
},
{
- "@type": 'korap:doc',
+ "@type": 'koral:doc',
"key": 'pubDate',
"match": 'match:leq',
"value": '2014-12-05',
@@ -842,25 +842,25 @@
});
var flatGroupFactory = buildFactory(KorAP.VirtualCollection, {
- "@type" : "korap:docGroup",
+ "@type" : "koral:docGroup",
"operation" : "operation:and",
"operands" : [
{
- "@type": 'korap:doc',
+ "@type": 'koral:doc',
"key": 'pubDate',
"match": 'match:geq',
"value": '2014-05-12',
"type": 'type:date'
},
{
- "@type": 'korap:doc',
+ "@type": 'koral:doc',
"key": 'pubDate',
"match": 'match:leq',
"value": '2014-12-05',
"type": 'type:date'
},
{
- "@type": 'korap:doc',
+ "@type": 'koral:doc',
"key": 'foo',
"match": 'match:eq',
"value": 'bar',
@@ -880,7 +880,7 @@
it('should be based on a doc', function () {
var vc = KorAP.VirtualCollection.render({
- "@type" : "korap:doc",
+ "@type" : "koral:doc",
"key":"Titel",
"value":"Baum",
"match":"match:eq"
@@ -1115,37 +1115,37 @@
it('should flatten on import', function () {
var vc = KorAP.VirtualCollection.create().render({
- "@type":"korap:docGroup",
+ "@type":"koral:docGroup",
"operation":"operation:or",
"operands":[
{
- "@type":"korap:docGroup",
+ "@type":"koral:docGroup",
"operation":"operation:or",
"operands":[
{
- "@type":"korap:doc",
+ "@type":"koral:doc",
"key":"Titel",
"value":"Baum",
"match":"match:eq"
},
{
- "@type":"korap:doc",
+ "@type":"koral:doc",
"key":"Veröffentlichungsort",
"value":"hihi",
"match":"match:eq"
},
{
- "@type":"korap:docGroup",
+ "@type":"koral:docGroup",
"operation":"operation:or",
"operands":[
{
- "@type":"korap:doc",
+ "@type":"koral:doc",
"key":"Titel",
"value":"Baum",
"match":"match:eq"
},
{
- "@type":"korap:doc",
+ "@type":"koral:doc",
"key":"Veröffentlichungsort",
"value":"hihi",
"match":"match:eq"
@@ -1155,7 +1155,7 @@
]
},
{
- "@type":"korap:doc",
+ "@type":"koral:doc",
"key":"Untertitel",
"value":"huhu",
"match":"match:eq"
@@ -1211,27 +1211,27 @@
describe('KorAP._delete (event)', function () {
var complexVCFactory = buildFactory(KorAP.VirtualCollection,{
- "@type": 'korap:docGroup',
+ "@type": 'koral:docGroup',
'operation' : 'operation:and',
'operands' : [
{
- "@type": 'korap:doc',
+ "@type": 'koral:doc',
"key": 'pubDate',
"match": 'match:eq',
"value": '2014-12-05',
"type": 'type:date'
},
{
- "@type" : 'korap:docGroup',
+ "@type" : 'koral:docGroup',
'operation' : 'operation:or',
'operands' : [
{
- '@type' : 'korap:doc',
+ '@type' : 'koral:doc',
'key' : 'title',
'value' : 'Hello World!'
},
{
- '@type' : 'korap:doc',
+ '@type' : 'koral:doc',
'key' : 'foo',
'value' : 'bar'
}
@@ -1242,7 +1242,7 @@
it('should clean on root docs', function () {
var vc = KorAP.VirtualCollection.render({
- "@type": 'korap:doc',
+ "@type": 'koral:doc',
"key": 'pubDate',
"match": 'match:eq',
"value": '2014-12-05',
@@ -1261,18 +1261,18 @@
it ('should remove on nested docs', function () {
var vc = KorAP.VirtualCollection.render(
{
- "@type": 'korap:docGroup',
+ "@type": 'koral:docGroup',
'operation' : 'operation:and',
'operands' : [
{
- "@type": 'korap:doc',
+ "@type": 'koral:doc',
"key": 'pubDate',
"match": 'match:eq',
"value": '2014-12-05',
"type": 'type:date'
},
{
- "@type" : 'korap:doc',
+ "@type" : 'koral:doc',
'key' : 'foo',
'value' : 'bar'
}
@@ -1291,18 +1291,18 @@
it ('should clean on doc groups', function () {
var vc = KorAP.VirtualCollection.render(
{
- "@type": 'korap:docGroup',
+ "@type": 'koral:docGroup',
'operation' : 'operation:and',
'operands' : [
{
- "@type": 'korap:doc',
+ "@type": 'koral:doc',
"key": 'pubDate',
"match": 'match:eq',
"value": '2014-12-05',
"type": 'type:date'
},
{
- "@type" : 'korap:doc',
+ "@type" : 'koral:doc',
'key' : 'foo',
'value' : 'bar'
}
@@ -1364,43 +1364,43 @@
it ('should remove on nested doc groups (list flattening)', function () {
var vc = KorAP.VirtualCollection.render(
{
- "@type": 'korap:docGroup',
+ "@type": 'koral:docGroup',
'operation' : 'operation:or',
'operands' : [
{
- "@type": 'korap:doc',
+ "@type": 'koral:doc',
"key": 'pubDate',
"match": 'match:eq',
"value": '2014-12-05',
"type": 'type:date'
},
{
- "@type" : 'korap:doc',
+ "@type" : 'koral:doc',
'key' : 'foo',
'value' : 'bar'
},
{
- "@type": 'korap:docGroup',
+ "@type": 'koral:docGroup',
'operation' : 'operation:and',
'operands' : [
{
- "@type": 'korap:doc',
+ "@type": 'koral:doc',
"key": 'pubDate',
"match": 'match:eq',
"value": '2014-12-05',
"type": 'type:date'
},
{
- "@type" : 'korap:docGroup',
+ "@type" : 'koral:docGroup',
'operation' : 'operation:or',
'operands' : [
{
- '@type' : 'korap:doc',
+ '@type' : 'koral:doc',
'key' : 'title',
'value' : 'Hello World!'
},
{
- '@type' : 'korap:doc',
+ '@type' : 'koral:doc',
'key' : 'yeah',
'value' : 'juhu'
}
@@ -1443,27 +1443,27 @@
describe('KorAP._add (event)', function () {
var complexVCFactory = buildFactory(KorAP.VirtualCollection,{
- "@type": 'korap:docGroup',
+ "@type": 'koral:docGroup',
'operation' : 'operation:and',
'operands' : [
{
- "@type": 'korap:doc',
+ "@type": 'koral:doc',
"key": 'pubDate',
"match": 'match:eq',
"value": '2014-12-05',
"type": 'type:date'
},
{
- "@type" : 'korap:docGroup',
+ "@type" : 'koral:docGroup',
'operation' : 'operation:or',
'operands' : [
{
- '@type' : 'korap:doc',
+ '@type' : 'koral:doc',
'key' : 'title',
'value' : 'Hello World!'
},
{
- '@type' : 'korap:doc',
+ '@type' : 'koral:doc',
'key' : 'foo',
'value' : 'bar'
}
@@ -1475,18 +1475,18 @@
it ('should add new unspecified doc with "and"', function () {
var vc = KorAP.VirtualCollection.render(
{
- "@type": 'korap:docGroup',
+ "@type": 'koral:docGroup',
'operation' : 'operation:and',
'operands' : [
{
- "@type": 'korap:doc',
+ "@type": 'koral:doc',
"key": 'pubDate',
"match": 'match:eq',
"value": '2014-12-05',
"type": 'type:date'
},
{
- "@type" : 'korap:doc',
+ "@type" : 'koral:doc',
'key' : 'foo',
'value' : 'bar'
}
@@ -1520,18 +1520,18 @@
it ('should add new unspecified doc with "or"', function () {
var vc = KorAP.VirtualCollection.render(
{
- "@type": 'korap:docGroup',
+ "@type": 'koral:docGroup',
'operation' : 'operation:and',
'operands' : [
{
- "@type": 'korap:doc',
+ "@type": 'koral:doc',
"key": 'pubDate',
"match": 'match:eq',
"value": '2014-12-05',
"type": 'type:date'
},
{
- "@type" : 'korap:doc',
+ "@type" : 'koral:doc',
'key' : 'foo',
'value' : 'bar'
}
@@ -1710,18 +1710,18 @@
it ('should wrap on root', function () {
var vc = KorAP.VirtualCollection.render(
{
- "@type": 'korap:docGroup',
+ "@type": 'koral:docGroup',
'operation' : 'operation:and',
'operands' : [
{
- "@type": 'korap:doc',
+ "@type": 'koral:doc',
"key": 'pubDate',
"match": 'match:eq',
"value": '2014-12-05',
"type": 'type:date'
},
{
- "@type" : 'korap:doc',
+ "@type" : 'koral:doc',
'key' : 'foo',
'value' : 'bar'
}
@@ -1744,7 +1744,7 @@
it ('should add on root (case "and")', function () {
var vc = KorAP.VirtualCollection.render(
{
- "@type": 'korap:doc',
+ "@type": 'koral:doc',
"key": 'pubDate',
"match": 'match:eq',
"value": '2014-12-05',
@@ -1766,7 +1766,7 @@
it ('should add on root (case "or")', function () {
var vc = KorAP.VirtualCollection.render(
{
- "@type": 'korap:doc',
+ "@type": 'koral:doc',
"key": 'pubDate',
"match": 'match:eq',
"value": '2014-12-05',
@@ -1787,36 +1787,36 @@
it ('should support multiple sub groups per group', function () {
var vc = KorAP.VirtualCollection.render(
{
- "@type": 'korap:docGroup',
+ "@type": 'koral:docGroup',
'operation' : 'operation:or',
'operands' : [
{
- "@type": 'korap:docGroup',
+ "@type": 'koral:docGroup',
'operation' : 'operation:and',
'operands' : [
{
- "@type": 'korap:doc',
+ "@type": 'koral:doc',
"key": 'title',
"value": 't1',
},
{
- "@type" : 'korap:doc',
+ "@type" : 'koral:doc',
'key' : 'title',
'value' : 't2'
}
]
},
{
- "@type": 'korap:docGroup',
+ "@type": 'koral:docGroup',
'operation' : 'operation:and',
'operands' : [
{
- "@type": 'korap:doc',
+ "@type": 'koral:doc',
"key": 'title',
"value": 't3',
},
{
- "@type" : 'korap:doc',
+ "@type" : 'koral:doc',
'key' : 'title',
'value' : 't4'
}
@@ -1844,7 +1844,7 @@
it('should be initializable', function () {
var rewrite = KorAP.Rewrite.create({
- "@type" : "korap:rewrite",
+ "@type" : "koral:rewrite",
"operation" : "operation:modification",
"src" : "querySerializer",
"scope" : "tree"
@@ -1855,7 +1855,7 @@
it('should be deserialized by docs', function () {
var doc = KorAP.Doc.create(undefined,
{
- "@type":"korap:doc",
+ "@type":"koral:doc",
"key":"Titel",
"value":"Baum",
"match":"match:eq"
@@ -1866,13 +1866,13 @@
doc = KorAP.Doc.create(undefined,
{
- "@type":"korap:doc",
+ "@type":"koral:doc",
"key":"Titel",
"value":"Baum",
"match":"match:eq",
"rewrites" : [
{
- "@type" : "korap:rewrite",
+ "@type" : "koral:rewrite",
"operation" : "operation:modification",
"src" : "querySerializer",
"scope" : "tree"
@@ -1888,3 +1888,11 @@
});
*/
});
+/*
+describe('KorAP.DocKey', function () {
+ it('should be initializable', function () {
+ var docKey = KorAP.DocKey.create();
+ expect(docKey.toString()).toEqual('...');
+ });
+});
+*/
diff --git a/public/js/src/menu.js b/public/js/src/menu.js
index b251000..f0dd15d 100644
--- a/public/js/src/menu.js
+++ b/public/js/src/menu.js
@@ -1,5 +1,11 @@
var KorAP = KorAP || {};
+/**
+ * Create scrollable drop-down menus.
+ *
+ * @author Nils Diewald
+ */
+
(function (KorAP) {
"use strict";
@@ -25,39 +31,63 @@
return Object.create(KorAP.Menu)._init(params);
},
+ focus : function () {
+ this._element.focus();
+ },
+
+ // Initialize list
_init : function (itemClass, params) {
// this._element.addEventListener("click", chooseHint, false);
this._itemClass = itemClass;
this._element = document.createElement("ul");
this._element.style.opacity = 0;
+/*
+ this._listener = document.createElement('input');
+ this._listener.setAttribute('type', 'text');
+// this._listener.style.display = "none";
+*/
+ this._element.addEventListener(
+ "keydown",
+ function (e) {
+ console.log('+++');
+ },
+ false
+ );
+
this.active = false;
this._items = new Array();
var i;
+
+ // Initialize item list based on parameters
for (i in params) {
var obj = itemClass.create(params[i]);
- this._items.push(
- obj
- );
+ this._items.push(obj);
};
this._limit = KorAP.menuLimit;
this._position = 0; // position in the active list
this._active = -1; // active item in the item list
-
this._reset();
return this;
},
+ /**
+ * Get the instantiated HTML element
+ */
element : function () {
return this._element;
},
+ /**
+ * Get the creator object for items
+ */
itemClass : function () {
return this._itemClass;
},
/**
- * Get and set numerical value for limit
+ * Get and set numerical value for limit,
+ * i.e. the number of items visible.
*/
limit : function (limit) {
if (arguments.length === 1)
@@ -69,7 +99,7 @@
* Upgrade this object to another object,
* while private data stays intact.
*
- * @param {Object] An object with properties.
+ * @param {Object} An object with properties.
*/
upgradeTo : function (props) {
for (var prop in props) {
@@ -78,6 +108,7 @@
return this;
},
+ // Reset chosen item and prefix
_reset : function () {
this._offset = 0;
this._pos = 0;
@@ -96,30 +127,30 @@
if (!this._initList())
return;
- // show based on offset
+ // show based on initial offset
this._showItems(0);
// Set the first element to active
+ // Todo: Or the last element chosen
this.liveItem(0).active(true);
this._position = 0;
this._active = this._list[0];
+ this._element.style.opacity = 1;
+
// Add classes for rolling menus
this._boundary(true);
},
- /**
- * Get a specific item from the complete list
- *
- * @param {number} index of the list item
- */
- item : function (index) {
- return this._items[index]
+ hide : function () {
+ this._element.style.opacity = 0;
},
+ // Initialize the list
_initList : function () {
+ // Create a new list
if (this._list === undefined) {
this._list = [];
}
@@ -131,20 +162,27 @@
// Offset is initially zero
this._offset = 0;
+ // There is no prefix set
if (this.prefix().length <= 0) {
for (var i = 0; i < this._items.length; i++)
this._list.push(i);
return true;
};
+ // There is a prefix set, so filter the list
var pos;
var paddedPrefix = " " + this.prefix();
+ // Iterate over all items and choose preferred matching items
+ // i.e. the matching happens at the word start
for (pos = 0; pos < this._items.length; pos++) {
if ((this.item(pos).lcField().indexOf(paddedPrefix)) >= 0)
this._list.push(pos);
};
+ // The list is empty - so lower your expectations
+ // Iterate over all items and choose matching items
+ // i.e. the matching happens anywhere in the word
if (this._list.length == 0) {
for (pos = 0; pos < this._items.length; pos++) {
if ((this.item(pos).lcField().indexOf(this.prefix())) >= 0)
@@ -152,7 +190,7 @@
};
};
- // Filter was successful
+ // Filter was successful - yeah!
return this._list.length > 0 ? true : false;
},
@@ -164,12 +202,13 @@
/**
* Get the prefix for filtering,
- * e.g. "ve"" for "verb"
+ * e.g. "ve" for "verb"
*/
prefix : function () {
return this._prefix || '';
},
+ // Append Items that should be shown
_showItems : function (offset) {
this.delete();
@@ -194,12 +233,16 @@
*/
delete : function () {
var child;
+
+ // Iterate over all visible items
for (var i = 0; i <= this.limit(); i++) {
+ // there is a visible element - unhighlight!
if (child = this.shownItem(i))
child.lowlight();
};
+ // Remove all children
while (child = this._element.firstChild)
this._element.removeChild(child);
},
@@ -218,10 +261,38 @@
},
+ // Prepend item to the shown list based on index
+ _prepend : function (i) {
+ var item = this.item(i);
+
+ // Highlight based on prefix
+ if (this.prefix().length > 0)
+ item.highlight(this.prefix());
+
+ var e = this.element();
+ // Append element
+ e.insertBefore(
+ item.element(),
+ e.firstChild
+ );
+ },
+
+
+ /**
+ * Get a specific item from the complete list
+ *
+ * @param {number} index of the list item
+ */
+ item : function (index) {
+ return this._items[index]
+ },
+
+
/**
* Get a specific item from the filtered list
*
* @param {number} index of the list item
+ * in the filtered list
*/
liveItem : function (index) {
if (this._list === undefined)
@@ -231,15 +302,12 @@
return this._items[this._list[index]];
},
- length : function () {
- return this._items.length;
- },
-
/**
* Get a specific item from the visible list
*
* @param {number} index of the list item
+ * in the visible list
*/
shownItem : function (index) {
if (index >= this.limit())
@@ -248,8 +316,16 @@
},
- /*
- * Make the next item in the menu active
+ /**
+ * Get the length of the full list
+ */
+ length : function () {
+ return this._items.length;
+ },
+
+
+ /**
+ * Make the next item in the filtered menu active
*/
next : function () {
// No active element set
@@ -270,7 +346,7 @@
}
// The next element is outside the view - roll down
- else if (this._position >= (this.limit + this._offset)) {
+ else if (this._position >= (this.limit() + this._offset)) {
this._removeFirst();
this._offset++;
this._append(this._list[this._position]);
@@ -282,8 +358,8 @@
/*
* Make the previous item in the menu active
*/
-/*
prev : function () {
+ // No active element set
if (this._position == -1)
return;
@@ -294,9 +370,9 @@
// The previous element is undefined - roll to bottom
if (newItem === undefined) {
- this._position = this.liveLength - 1;
+ this._offset = this.liveLength() - this.limit();
+ this._position = this.liveLength() - 1;
newItem = this.liveItem(this._position);
- this._offset = this.liveLength - this.limit;
this._showItems(this._offset);
}
@@ -306,85 +382,33 @@
this._offset--;
this._prepend(this._list[this._position]);
};
+
newItem.active(true);
},
-*/
- /**
- * Get the context of the menue,
- * e.g. "tt/" for the tree tagger menu
- */
-/*
- get context () {
- return this._context;
- },
-*/
-/*
- get liveLength () {
- if (this._list === undefined)
- this._initList();
- return this._list.length;
- },
-*/
-/*
- chooseHint : function (e) {
- var element = e.target;
- while (element.nodeName == "STRONG" || element.nodeName == "SPAN")
- element = element.parentNode;
-
- if (element === undefined || element.nodeName != "LI")
- return;
-
- var action = element.getAttribute('data-action');
- hint.insertText(action);
- var menu = hint.menu();
- menu.hide();
-
- // Fill this with the correct value
- var show;
- if ((show = hint.analyzeContext()) != "-") {
- menu.show(show);
- menu.update(
- hint._search.getBoundingClientRect().right
- );
- };
-
- hint._search.focus();
- },
-
+ // Remove the HTML node from the first item
_removeFirst : function () {
this.item(this._list[this._offset]).lowlight();
this._element.removeChild(this._element.firstChild);
},
+
+ // Remove the HTML node from the last item
_removeLast : function () {
- this.item(this._list[this._offset + this.limit - 1]).lowlight();
+ this.item(this._list[this._offset + this.limit() - 1]).lowlight();
this._element.removeChild(this._element.lastChild);
},
-
- // Prepend item to the shown list based on index
- _prepend : function (i) {
- var item = this.item(i);
-
- // Highlight based on prefix
- if (this.prefix.length > 0)
- item.highlight(this.prefix);
-
- // Append element
- this.element.insertBefore(
- item.element,
- this.element.firstChild
- );
- },
-*/
-
+ // Length of the filtered list
+ liveLength : function () {
+ if (this._list === undefined)
+ this._initList();
+ return this._list.length;
+ }
};
-
-
/**
* Item in the Dropdown menu
*/
@@ -585,4 +609,10 @@
},
};
+/*
+ KorAP._updateKey : function (e) {
+ var code = this._codeFromEvent(e)
+ };
+*/
+
}(this.KorAP));
diff --git a/public/js/src/vc.js b/public/js/src/vc.js
index d226fc4..00528aa 100644
--- a/public/js/src/vc.js
+++ b/public/js/src/vc.js
@@ -3,9 +3,13 @@
*
* @author Nils Diewald
*/
-
+/*
+ * Replaces a previous version written by Mengfei Zhou
+ */
var KorAP = KorAP || {};
+// Requires menu.js
+
/*
TODO: Implement a working localization solution!
TODO: Disable "and" or "or" in case it's followed
@@ -50,7 +54,6 @@
loc.DEL = loc.DEL || '×';
loc.EMPTY = loc.EMPTY || '⋯'
-
// Utility for analysing boolean values
function _bool (bool) {
return (bool === undefined || bool === null || bool === false) ? false : true;
@@ -148,10 +151,10 @@
if (json !== undefined) {
// Root object
- if (json['@type'] == 'korap:doc') {
+ if (json['@type'] == 'koral:doc') {
obj._root = KorAP.Doc.create(obj, json);
}
- else if (json['@type'] == 'korap:docGroup') {
+ else if (json['@type'] == 'koral:docGroup') {
obj._root = KorAP.DocGroup.create(obj, json);
}
else {
@@ -343,7 +346,7 @@
// Set JSON-LD type
var newDoc = KorAP.Doc.create(this._parent, {
- "@type" : "korap:doc",
+ "@type" : "koral:doc",
"value" : "",
"key" : v
});
@@ -374,6 +377,9 @@
ellipsis.appendChild(document.createTextNode(loc.EMPTY));
this._element.appendChild(ellipsis);
+ // Set ref - TODO: Cleanup!
+ this._element.refTo = this;
+
// Set operators
if (this._parent !== undefined && this.parent().ldType() !== null) {
var op = this.operators(
@@ -430,6 +436,9 @@
// Get element
var e = this._element;
+ // Set ref - TODO: Cleanup!
+ e.refTo = this;
+
// Check if there is a change
if (this.__changed) {
@@ -441,6 +450,10 @@
// Added key
var key = document.createElement('span');
key.setAttribute('class', 'key');
+
+ // Change key
+ key.addEventListener('click', KorAP._changeKey, false);
+
if (this.key())
key.appendChild(document.createTextNode(this.key()));
@@ -676,7 +689,7 @@
return {};
return {
- "@type" : "korap:" + this.ldType(),
+ "@type" : "koral:" + this.ldType(),
"key" : this.key(),
"match" : "match:" + this.matchop(),
"value" : this.value() || '',
@@ -810,7 +823,7 @@
KorAP.log(701, "JSON-LD group has no @type attribute");
return;
- case "korap:doc":
+ case "koral:doc":
// Be aware of cyclic structures!
var doc = KorAP.Doc.create(this, operand);
if (doc === undefined)
@@ -822,7 +835,7 @@
};
return dupl;
- case "korap:docGroup":
+ case "koral:docGroup":
// Be aware of cyclic structures!
var docGroup = KorAP.DocGroup.create(this, operand);
if (docGroup === undefined)
@@ -1039,7 +1052,7 @@
opArray.push(this._operands[i].toJson());
};
return {
- "@type" : "korap:" + this.ldType(),
+ "@type" : "koral:" + this.ldType(),
"operation" : "operation:" + this.operation(),
"operands" : opArray
};
@@ -1301,7 +1314,7 @@
toJson : function () {
return {
// Unspecified object
- "@type" : "korap:" + this.ldType()
+ "@type" : "koral:" + this.ldType()
};
},
@@ -1309,5 +1322,65 @@
return '';
}
};
+
+
+ /**
+ * Criterion in a KorAP.Doc
+ */
+ KorAP._changeKey = function () {
+ var doc = this.parentNode.refTo;
+ console.log(doc.type());
+ // key, matchop, type, value
+ };
+
+
+ // Field menu
+ KorAP.FieldMenu = {
+ create : function (params) {
+ return Object.create(KorAP.Menu)
+ .upgradeTo(KorAP.FieldMenu)
+ ._init(KorAP.FieldMenuItem, params)
+ }
+ };
+
+
+ // Field menu item
+ KorAP.FieldMenuItem = {
+ create : function (params) {
+ return Object.create(KorAP.MenuItem)
+ .upgradeTo(KorAP.FieldMenuItem)
+ ._init(params);
+ },
+ _init : function (params) {
+ if (params[0] === undefined)
+ throw new Error("Missing parameters");
+
+ this._name = params[0];
+ this._value = params[1];
+ this._type = params[2];
+
+ this._lcField = ' ' + this._name.toLowerCase();
+
+ return this;
+ },
+ name : function () {
+ return this._name;
+ },
+ type : function () {
+ return this._type;
+ },
+ element : function () {
+ // already defined
+ if (this._element !== undefined)
+ return this._element;
+
+ // Create list item
+ var li = document.createElement("li");
+ li.setAttribute("data-type", this._type);
+ li.setAttribute("data-value", this._value);
+ li.appendChild(document.createTextNode(this._name));
+ return this._element = li;
+ }
+ };
}(this.KorAP));