blob: 66fc9806e19800b2890fd970fd8ad86b35603857 [file] [log] [blame]
Leo Repp56904d22021-04-26 15:53:22 +02001define(
2 ['alwaysmenu', 'menu/item', 'menu/prefix', 'menu/lengthField', 'alwaysentry'],
3 function (alwaysMenuClass, menuItemClass, prefixClass, lengthFieldClass, alwaysEntryClass) {
4
5 //These class definitions were taken from menuSpec for a guideline on how to procede
6
7 // The OwnAlwaysMenu item
8 const OwnAlwaysMenuItem = {
9 create : function (params) {
10 return Object.create(menuItemClass).upgradeTo(OwnAlwaysMenuItem)._init(params);
11 },
12 content : function (content) {
13 if (arguments.length === 1) {
14 this._content = content;
15 };
16 return this._content;
17 },
18 _init : function (params) {
19 if (params[0] === undefined)
20 throw new Error("Missing parameters");
21
22 this._content = document.createTextNode(params[0]);
23 this._lcField = ' ' + this.content().textContent.toLowerCase();
24
25 return this;
26 }
27 };
28
29 // The OwnAlwaysMenu
30 let OwnAlwaysMenu = {
31 create : function (list) {
32 return alwaysMenuClass.create(list, { itemClass : OwnAlwaysMenuItem } )
33 .upgradeTo(OwnAlwaysMenu);
34 }
35 };
36
37
38
39 // HintMenuItem
40 const HintMenuItem = {
41 create : function (params) {
42 return Object.create(menuItemClass)
43 .upgradeTo(HintMenuItem)
44 ._init(params);
45 },
46 content : function (content) {
47 if (arguments.length === 1) {
48 this._content = content;
49 };
50 return this._content;
51 },
52 _init : function (params) {
53 if (params[0] === undefined || params[1] === undefined)
54 throw new Error("Missing parameters");
55
56 this._name = params[0];
57 this._action = params[1];
58 this._lcField = ' ' + this._name.toLowerCase();
59
60 if (params.length > 2) {
61 this._desc = params[2];
62 this._lcField += " " + this._desc.toLowerCase();
63 };
64
65 return this;
66 },
67
68 name : function () {
69 return this._name;
70 },
71 action : function () {
72 return this._action;
73 },
74 desc : function () {
75 return this._desc;
76 },
77 element : function () {
78 // already defined
79 if (this._el !== undefined)
80 return this._el;
81
82 // Create list item
83 var li = document.createElement("li");
84 li.setAttribute("data-action", this._action);
85
86 // Create title
87 var name = document.createElement("strong");
88 name.appendChild(document.createTextNode(this._name));
89
90 li.appendChild(name);
91
92 // Create description
93 if (this._desc !== undefined) {
94 var desc = document.createElement("span");
95 desc.appendChild(document.createTextNode(this._desc));
96 li.appendChild(desc);
97 };
98 return this._el = li;
99 }
100 };
101
102
103 // HintMenu
104 const HintMenu = {
105 create : function (context, list) {
106 var obj = alwaysMenuClass.create(list, {itemClass : HintMenuItem} )
107 .upgradeTo(HintMenu);
108 obj._context = context;
109 return obj;
110 }
111 };
112
113
114 // The ComplexMenuItem
115 const ComplexMenuItem = {
116 create : function (params) {
117 return Object.create(menuItemClass)
118 .upgradeTo(ComplexMenuItem)
119 ._init(params);
120 },
121 content : function (content) {
122 if (arguments.length === 1) {
123 this._content = content;
124 };
125 return this._content;
126 },
127 _init : function (params) {
128 if (params[0] === undefined)
129 throw new Error("Missing parameters");
130
131 var r = document.createElement('div');
132 for (var i = 1; i <= params.length; i++) {
133 var h = document.createElement('h' + i);
134 h.appendChild(document.createTextNode(params[i-1]));
135 r.appendChild(h);
136 };
137
138 this._content = r;
139 this._lcField = ' ' + this.content().textContent.toLowerCase();
140
141 return this;
142 }
143 };
144
145
146 describe('KorAP.AlwaysMenu', function () {
147 var list = [
148 ["Constituency", "c=", "Example 1"],
149 ["Lemma", "l="],
150 ["Morphology", "m=", "Example 2"],
151 ["Part-of-Speech", "p="],
152 ["Syntax", "syn="]
153 ];
154
155 var listMultiPrefix = [
156 ["PP","PP ","Personal Pronoun"],
157 ["PPP","PPP ","Personal Pronoun, Plural"],
158 ["PPPA","PPPA ","Personal Pronoun, Plural, Acc."],
159 ["PPPD","PPPD ","Personal Pronoun, Plural, Dative"],
160 ["PPPR","PPPR ","Personal Pronoun, Plural, Direct"],
161 ["PPPO","PPPO ","Personal Pronoun, Plural, Oblique"],
162 ["PPS","PPS ","Personal Pronoun, Singular"],
163 ["PPSA","PPSA ","Personal Pronoun, Singular, Accusative"],
164 ["PPSD","PPSD ","Personal Pronoun, Singular, Dative"],
165 ["PPSR","PPSR ","Personal Pronoun, Singular, Direct"],
166 ["PPSN","PPSN ","Personal Pronoun, Singular, Nominative"],
167 ["PPSO","PPSO ","Personal Pronoun, Singular, Oblique"]
168 ];
169
170 var demolist = [
171 ['Titel', 'title'],
172 ['Untertitel', 'subTitle'],
173 ['Veröffentlichungsdatum', 'pubDate'],
174 ['Länge', 'length'],
175 ['Autor', 'author']
176 ];
177
178 var demolonglist = [
179 ['Titel', 'title'],
180 ['Untertitel', 'subTitle'],
181 ['Veröffentlichungsdatum', 'pubDate'],
182 ['Länge', 'length'],
183 ['Autor', 'author'],
184 ['Genre', 'genre'],
185 ['corpusID', 'corpusID'],
186 ['docID', 'docID'],
187 ['textID', 'textID'],
188 ];
189
190 it('should be initializable', function () {
191 var list = [
192 ["Constituency"],
193 ["Lemma"],
194 ["Morphology"],
195 ["Part-of-Speech"],
196 ["Syntax"]
197 ];
198
199 var menu = OwnAlwaysMenu.create(list);
200 menu._firstActive = true;
201 expect(menu.itemClass()).toEqual(OwnAlwaysMenuItem);
202 expect(menu._notItemElements).toEqual(4);
203 expect(menu.element().getElementsByClassName("pref").length).toEqual(2); //TODO: new scss = new class
204 expect(menu.element().getElementsByClassName("pref")[1].innerHTML).toEqual("Speichern");
205 expect(menu.alwaysEntry().element().innerHTML).toEqual("Speichern");
206 //expect(menu.element().childNodes[3].innerHTML).toEqual("Speichern"); //?
207 // getElementsByClassName funktioniert bei allen Kindern.
208
209
210 // view
211 menu.show();
212
213 expect(menu.alwaysEntry().active()).toBe(false);
214 });
215
216 it('should be visible', function () {
217 var menu = HintMenu.create("cnx/", list);
218 expect(menu.removeItems()).toBe(undefined);
219 menu.limit(3);
220
221 expect(menu.show()).toBe(true);
222
Leo Reppdedcf1a2021-08-18 18:57:47 +0200223 expect(directElementChildrenByTagName(menu.element(),"li")[0].innerHTML).toEqual("<strong>Constituency</strong><span>Example 1</span>");
224 expect(directElementChildrenByTagName(menu.element(),"li")[1].innerHTML).toEqual("<strong>Lemma</strong>");
225 expect(directElementChildrenByTagName(menu.element(),"li")[1].getAttribute("data-action")).toEqual("l=");
226 expect(directElementChildrenByTagName(menu.element(),"li")[2].innerHTML).toEqual("<strong>Morphology</strong><span>Example 2</span>");
227 expect(directElementChildrenByTagName(menu.element(),"li")[3]).toBe(undefined);
Leo Repp56904d22021-04-26 15:53:22 +0200228
229 // Check boundaries
Leo Reppdedcf1a2021-08-18 18:57:47 +0200230 expect(directElementChildrenByTagName(menu.element(),"li")[0].classList.contains("no-more")).toBe(true);
231 expect(directElementChildrenByTagName(menu.element(),"li")[1].classList.contains("no-more")).toBe(false);
232 expect(directElementChildrenByTagName(menu.element(),"li")[2].classList.contains("no-more")).toBe(false);
Leo Repp56904d22021-04-26 15:53:22 +0200233 });
234
235 it('should be filterable', function () {
236 var menu = HintMenu.create("cnx/", list);
237 menu.limit(3);
238 expect(menu.prefix("o").show()).toBe(true);
239 expect(menu.alwaysEntryValue("o").alwaysEntryValue()).toEqual("o");
240 expect(menu.element().getElementsByClassName("pref")[0].innerHTML).toEqual("o");
241 expect(menu.alwaysEntry().element().innerHTML).toEqual("Speichern");
Leo Reppdedcf1a2021-08-18 18:57:47 +0200242 expect(directElementChildrenByTagName(menu.element(),"li")[0].innerHTML).toEqual("<strong>C<mark>o</mark>nstituency</strong><span>Example 1</span>");
243 expect(directElementChildrenByTagName(menu.element(),"li")[1].innerHTML).toEqual("<strong>M<mark>o</mark>rph<mark>o</mark>l<mark>o</mark>gy</strong><span>Example 2</span>");
244 expect(directElementChildrenByTagName(menu.element(),"li")[2].innerHTML).toEqual("<strong>Part-<mark>o</mark>f-Speech</strong>");
245 expect(directElementChildrenByTagName(menu.element(),"li")[3]).toBe(undefined);
Leo Repp56904d22021-04-26 15:53:22 +0200246
247 // Check boundaries
Leo Reppdedcf1a2021-08-18 18:57:47 +0200248 expect(directElementChildrenByTagName(menu.element(),"li")[0].classList.contains("no-more")).toBe(true);
249 expect(directElementChildrenByTagName(menu.element(),"li")[1].classList.contains("no-more")).toBe(false);
250 expect(directElementChildrenByTagName(menu.element(),"li")[2].classList.contains("no-more")).toBe(true);
Leo Repp56904d22021-04-26 15:53:22 +0200251
252 menu.limit(2);
253
254 expect(menu.prefix("o").show()).toBe(true);
255 expect(menu.alwaysEntryValue("o").alwaysEntryValue()).toEqual("o");
256 expect(menu.element().getElementsByClassName("pref")[0].innerHTML).toEqual("o");
257 expect(menu.alwaysEntry().element().innerHTML).toEqual("Speichern");
Leo Reppdedcf1a2021-08-18 18:57:47 +0200258 expect(directElementChildrenByTagName(menu.element(),"li")[0].innerHTML).toEqual("<strong>C<mark>o</mark>nstituency</strong><span>Example 1</span>");
259 expect(directElementChildrenByTagName(menu.element(),"li")[1].innerHTML).toEqual("<strong>M<mark>o</mark>rph<mark>o</mark>l<mark>o</mark>gy</strong><span>Example 2</span>");
260 expect(directElementChildrenByTagName(menu.element(),"li")[2]).toBe(undefined);
Leo Repp56904d22021-04-26 15:53:22 +0200261
262 // Check boundaries
Leo Reppdedcf1a2021-08-18 18:57:47 +0200263 expect(directElementChildrenByTagName(menu.element(),"li")[0].classList.contains("no-more")).toBe(true);
264 expect(directElementChildrenByTagName(menu.element(),"li")[1].classList.contains("no-more")).toBe(false);
265 expect(directElementChildrenByTagName(menu.element(),"li")[2]).toBe(undefined);
Leo Repp56904d22021-04-26 15:53:22 +0200266
267 expect(menu.prefix("e").show()).toBe(true);
268 expect(menu.alwaysEntryValue("e").alwaysEntryValue()).toEqual("e");
269 expect(menu.element().getElementsByClassName("pref")[0].innerHTML).toEqual("e");
270 expect(menu.alwaysEntry().element().innerHTML).toEqual("Speichern");
Leo Reppdedcf1a2021-08-18 18:57:47 +0200271 expect(directElementChildrenByTagName(menu.element(),"li")[0].innerHTML).toEqual("<strong>Constitu<mark>e</mark>ncy</strong><span><mark>E</mark>xampl<mark>e</mark> 1</span>");
272 expect(directElementChildrenByTagName(menu.element(),"li")[1].innerHTML).toEqual("<strong>Morphology</strong><span><mark>E</mark>xampl<mark>e</mark> 2</span>");
273 expect(directElementChildrenByTagName(menu.element(),"li")[2]).toBe(undefined);
Leo Repp56904d22021-04-26 15:53:22 +0200274
275 menu.limit(5);
276 expect(menu.prefix("a").show()).toBe(true);
277 expect(menu.alwaysEntryValue("a").alwaysEntryValue()).toEqual("a");
278 expect(menu.element().getElementsByClassName("pref")[0].innerHTML).toEqual("a");
279 expect(menu.alwaysEntry().element().innerHTML).toEqual("Speichern");
Leo Reppdedcf1a2021-08-18 18:57:47 +0200280 expect(directElementChildrenByTagName(menu.element(),"li")[0].innerHTML).toEqual("<strong>Constituency</strong><span>Ex<mark>a</mark>mple 1</span>");
281 expect(directElementChildrenByTagName(menu.element(),"li")[1].innerHTML).toEqual("<strong>Lemm<mark>a</mark></strong>");
282 expect(directElementChildrenByTagName(menu.element(),"li")[2].innerHTML).toEqual("<strong>Morphology</strong><span>Ex<mark>a</mark>mple 2</span>");
283 expect(directElementChildrenByTagName(menu.element(),"li")[3].innerHTML).toEqual("<strong>P<mark>a</mark>rt-of-Speech</strong>");
284 expect(directElementChildrenByTagName(menu.element(),"li")[4].innerHTML).toEqual("<strong>Synt<mark>a</mark>x</strong>");
285 expect(directElementChildrenByTagName(menu.element(),"li")[5]).toBe(undefined);
Leo Repp56904d22021-04-26 15:53:22 +0200286 });
287
288
289 it('should be nextable', function () {
290 var menu = HintMenu.create("cnx/", list);
291 menu._firstActive = true;
292
293 expect(menu._prefix.active()).toBe(false);
294
295 // Show only 3 items
296 menu.limit(3);
297 expect(menu.show()).toBe(true);
Leo Reppdedcf1a2021-08-18 18:57:47 +0200298 expect(directElementChildrenByTagName(menu.element(),"li")[0].innerHTML).toEqual("<strong>Constituency</strong><span>Example 1</span>");
Leo Repp56904d22021-04-26 15:53:22 +0200299 expect(menu.shownItem(0).active()).toBe(true);
Leo Reppdedcf1a2021-08-18 18:57:47 +0200300 expect(directElementChildrenByTagName(menu.element(),"li")[1].innerHTML).toEqual("<strong>Lemma</strong>");
Leo Repp56904d22021-04-26 15:53:22 +0200301 expect(menu.shownItem(1).active()).toBe(false);
Leo Reppdedcf1a2021-08-18 18:57:47 +0200302 expect(directElementChildrenByTagName(menu.element(),"li")[2].innerHTML).toEqual("<strong>Morphology</strong><span>Example 2</span>");
Leo Repp56904d22021-04-26 15:53:22 +0200303 expect(menu.shownItem(2).active()).toBe(false);
Leo Reppdedcf1a2021-08-18 18:57:47 +0200304 expect(directElementChildrenByTagName(menu.element(),"li")[3]).toBe(undefined);
Leo Repp56904d22021-04-26 15:53:22 +0200305 expect(menu.alwaysEntry().active()).toBe(false);
306
307 // Activate next (1)
308 menu.next();
Leo Reppdedcf1a2021-08-18 18:57:47 +0200309 expect(directElementChildrenByTagName(menu.element(),"li")[0].innerHTML).toEqual("<strong>Constituency</strong><span>Example 1</span>");
Leo Repp56904d22021-04-26 15:53:22 +0200310 expect(menu.shownItem(0).active()).toBe(false);
Leo Reppdedcf1a2021-08-18 18:57:47 +0200311 expect(directElementChildrenByTagName(menu.element(),"li")[1].innerHTML).toEqual("<strong>Lemma</strong>");
Leo Repp56904d22021-04-26 15:53:22 +0200312 expect(menu.shownItem(1).active()).toBe(true);
Leo Reppdedcf1a2021-08-18 18:57:47 +0200313 expect(directElementChildrenByTagName(menu.element(),"li")[2].innerHTML).toEqual("<strong>Morphology</strong><span>Example 2</span>");
Leo Repp56904d22021-04-26 15:53:22 +0200314 expect(menu.shownItem(2).active()).toBe(false);
Leo Reppdedcf1a2021-08-18 18:57:47 +0200315 expect(directElementChildrenByTagName(menu.element(),"li")[3]).toBe(undefined);
Leo Repp56904d22021-04-26 15:53:22 +0200316 expect(menu.alwaysEntry().active()).toBe(false);
317
318 // Activate next (2)
319 menu.next();
Leo Reppdedcf1a2021-08-18 18:57:47 +0200320 expect(directElementChildrenByTagName(menu.element(),"li")[0].innerHTML).toEqual("<strong>Constituency</strong><span>Example 1</span>");
Leo Repp56904d22021-04-26 15:53:22 +0200321 expect(menu.shownItem(0).active()).toBe(false);
Leo Reppdedcf1a2021-08-18 18:57:47 +0200322 expect(directElementChildrenByTagName(menu.element(),"li")[1].innerHTML).toEqual("<strong>Lemma</strong>");
Leo Repp56904d22021-04-26 15:53:22 +0200323 expect(menu.shownItem(1).active()).toBe(false);
Leo Reppdedcf1a2021-08-18 18:57:47 +0200324 expect(directElementChildrenByTagName(menu.element(),"li")[2].innerHTML).toEqual("<strong>Morphology</strong><span>Example 2</span>");
Leo Repp56904d22021-04-26 15:53:22 +0200325 expect(menu.shownItem(2).active()).toBe(true);
Leo Reppdedcf1a2021-08-18 18:57:47 +0200326 expect(directElementChildrenByTagName(menu.element(),"li")[3]).toBe(undefined);
Leo Repp56904d22021-04-26 15:53:22 +0200327 expect(menu.alwaysEntry().active()).toBe(false);
328
329 // Activate next (3)
330 // scroll!
331 menu.next();
Leo Reppdedcf1a2021-08-18 18:57:47 +0200332 expect(directElementChildrenByTagName(menu.element(),"li")[0].innerHTML).toEqual("<strong>Lemma</strong>");
Leo Repp56904d22021-04-26 15:53:22 +0200333 expect(menu.shownItem(0).active()).toBe(false);
Leo Reppdedcf1a2021-08-18 18:57:47 +0200334 expect(directElementChildrenByTagName(menu.element(),"li")[1].innerHTML).toEqual("<strong>Morphology</strong><span>Example 2</span>");
Leo Repp56904d22021-04-26 15:53:22 +0200335 expect(menu.shownItem(1).active()).toBe(false);
Leo Reppdedcf1a2021-08-18 18:57:47 +0200336 expect(directElementChildrenByTagName(menu.element(),"li")[2].innerHTML).toEqual("<strong>Part-of-Speech</strong>");
Leo Repp56904d22021-04-26 15:53:22 +0200337 expect(menu.shownItem(2).active()).toBe(true);
Leo Reppdedcf1a2021-08-18 18:57:47 +0200338 expect(directElementChildrenByTagName(menu.element(),"li")[3]).toBe(undefined);
Leo Repp56904d22021-04-26 15:53:22 +0200339 expect(menu.alwaysEntry().active()).toBe(false);
340
341 // Activate next (4)
342 menu.next();
Leo Reppdedcf1a2021-08-18 18:57:47 +0200343 expect(directElementChildrenByTagName(menu.element(),"li")[0].innerHTML).toEqual("<strong>Morphology</strong><span>Example 2</span>");
Leo Repp56904d22021-04-26 15:53:22 +0200344 expect(menu.shownItem(0).active()).toBe(false);
Leo Reppdedcf1a2021-08-18 18:57:47 +0200345 expect(directElementChildrenByTagName(menu.element(),"li")[1].innerHTML).toEqual("<strong>Part-of-Speech</strong>");
Leo Repp56904d22021-04-26 15:53:22 +0200346 expect(menu.shownItem(1).active()).toBe(false);
Leo Reppdedcf1a2021-08-18 18:57:47 +0200347 expect(directElementChildrenByTagName(menu.element(),"li")[2].innerHTML).toEqual("<strong>Syntax</strong>");
Leo Repp56904d22021-04-26 15:53:22 +0200348 expect(menu.shownItem(2).active()).toBe(true);
Leo Reppdedcf1a2021-08-18 18:57:47 +0200349 expect(directElementChildrenByTagName(menu.element(),"li")[3]).toBe(undefined);
Leo Repp56904d22021-04-26 15:53:22 +0200350 expect(menu.alwaysEntry().active()).toBe(false);
351
352 // Activate next (5) - Entry / Speichern
353 menu.next();
Leo Reppdedcf1a2021-08-18 18:57:47 +0200354 expect(directElementChildrenByTagName(menu.element(),"li")[0].innerHTML).toEqual("<strong>Morphology</strong><span>Example 2</span>");
Leo Repp56904d22021-04-26 15:53:22 +0200355 expect(menu.shownItem(0).active()).toBe(false);
Leo Reppdedcf1a2021-08-18 18:57:47 +0200356 expect(directElementChildrenByTagName(menu.element(),"li")[1].innerHTML).toEqual("<strong>Part-of-Speech</strong>");
Leo Repp56904d22021-04-26 15:53:22 +0200357 expect(menu.shownItem(1).active()).toBe(false);
Leo Reppdedcf1a2021-08-18 18:57:47 +0200358 expect(directElementChildrenByTagName(menu.element(),"li")[2].innerHTML).toEqual("<strong>Syntax</strong>");
Leo Repp56904d22021-04-26 15:53:22 +0200359 expect(menu.shownItem(2).active()).toBe(false);
Leo Reppdedcf1a2021-08-18 18:57:47 +0200360 expect(directElementChildrenByTagName(menu.element(),"li")[3]).toBe(undefined);
Leo Repp56904d22021-04-26 15:53:22 +0200361 expect(menu.alwaysEntry().active()).toBe(true);
362
363 // Activate next (6) - ROLL
364 menu.next();
Leo Reppdedcf1a2021-08-18 18:57:47 +0200365 expect(directElementChildrenByTagName(menu.element(),"li")[0].innerHTML).toEqual("<strong>Constituency</strong><span>Example 1</span>");
Leo Repp56904d22021-04-26 15:53:22 +0200366 expect(menu.shownItem(0).active()).toBe(true);
Leo Reppdedcf1a2021-08-18 18:57:47 +0200367 expect(directElementChildrenByTagName(menu.element(),"li")[1].innerHTML).toEqual("<strong>Lemma</strong>");
Leo Repp56904d22021-04-26 15:53:22 +0200368 expect(menu.shownItem(1).active()).toBe(false);
Leo Reppdedcf1a2021-08-18 18:57:47 +0200369 expect(directElementChildrenByTagName(menu.element(),"li")[2].innerHTML).toEqual("<strong>Morphology</strong><span>Example 2</span>");
Leo Repp56904d22021-04-26 15:53:22 +0200370 expect(menu.shownItem(2).active()).toBe(false);
Leo Reppdedcf1a2021-08-18 18:57:47 +0200371 expect(directElementChildrenByTagName(menu.element(),"li")[3]).toBe(undefined);
Leo Repp56904d22021-04-26 15:53:22 +0200372 expect(menu.alwaysEntry().active()).toBe(false);
373
374 // Active next (7)
375 menu.next();
Leo Reppdedcf1a2021-08-18 18:57:47 +0200376 expect(directElementChildrenByTagName(menu.element(),"li")[0].innerHTML).toEqual("<strong>Constituency</strong><span>Example 1</span>");
Leo Repp56904d22021-04-26 15:53:22 +0200377 expect(menu.shownItem(0).active()).toBe(false);
Leo Reppdedcf1a2021-08-18 18:57:47 +0200378 expect(directElementChildrenByTagName(menu.element(),"li")[1].innerHTML).toEqual("<strong>Lemma</strong>");
Leo Repp56904d22021-04-26 15:53:22 +0200379 expect(menu.shownItem(1).active()).toBe(true);
Leo Reppdedcf1a2021-08-18 18:57:47 +0200380 expect(directElementChildrenByTagName(menu.element(),"li")[2].innerHTML).toEqual("<strong>Morphology</strong><span>Example 2</span>");
Leo Repp56904d22021-04-26 15:53:22 +0200381 expect(menu.shownItem(2).active()).toBe(false);
Leo Reppdedcf1a2021-08-18 18:57:47 +0200382 expect(directElementChildrenByTagName(menu.element(),"li")[3]).toBe(undefined);
Leo Repp56904d22021-04-26 15:53:22 +0200383 expect(menu.alwaysEntry().active()).toBe(false);
384
385 expect(menu._prefix.active()).toBe(false);
386 });
387
388 it('should be nextable without active field', function () {
389 var menu = HintMenu.create("cnx/", list);
390 menu.limit(3);
391 expect(menu.show()).toBe(true);
392 menu.next();
393 expect(menu.shownItem(0).active()).toEqual(true);
394 });
395
396
397 it('should be prevable', function () {
398 var menu = HintMenu.create("cnx/", list);
399 menu._firstActive = true;
400 menu.limit(3);
401 expect(menu.show()).toBe(true);
402 expect(menu._prefix.active()).toBe(false);
403 expect(menu.alwaysEntryValue()).toBe("");
404
Leo Reppdedcf1a2021-08-18 18:57:47 +0200405 expect(directElementChildrenByTagName(menu.element(),"li")[0].innerHTML).toEqual("<strong>Constituency</strong><span>Example 1</span>");
Leo Repp56904d22021-04-26 15:53:22 +0200406 expect(menu.shownItem(0).active()).toBe(true);
Leo Reppdedcf1a2021-08-18 18:57:47 +0200407 expect(directElementChildrenByTagName(menu.element(),"li")[1].innerHTML).toEqual("<strong>Lemma</strong>");
Leo Repp56904d22021-04-26 15:53:22 +0200408 expect(menu.shownItem(1).active()).toBe(false);
Leo Reppdedcf1a2021-08-18 18:57:47 +0200409 expect(directElementChildrenByTagName(menu.element(),"li")[2].innerHTML).toEqual("<strong>Morphology</strong><span>Example 2</span>");
Leo Repp56904d22021-04-26 15:53:22 +0200410 expect(menu.shownItem(2).active()).toBe(false);
Leo Reppdedcf1a2021-08-18 18:57:47 +0200411 expect(directElementChildrenByTagName(menu.element(),"li")[3]).toBe(undefined);
Leo Repp56904d22021-04-26 15:53:22 +0200412 expect(menu.alwaysEntry().active()).toBe(false);
413
414
415 // Activate prev (1) - roll to bottom
416 menu.prev();
Leo Reppdedcf1a2021-08-18 18:57:47 +0200417 expect(directElementChildrenByTagName(menu.element(),"li")[0].innerHTML).toEqual("<strong>Constituency</strong><span>Example 1</span>");
Leo Repp56904d22021-04-26 15:53:22 +0200418 expect(menu.shownItem(0).active()).toBe(false);
Leo Reppdedcf1a2021-08-18 18:57:47 +0200419 expect(directElementChildrenByTagName(menu.element(),"li")[1].innerHTML).toEqual("<strong>Lemma</strong>");
Leo Repp56904d22021-04-26 15:53:22 +0200420 expect(menu.shownItem(1).active()).toBe(false);
Leo Reppdedcf1a2021-08-18 18:57:47 +0200421 expect(directElementChildrenByTagName(menu.element(),"li")[2].innerHTML).toEqual("<strong>Morphology</strong><span>Example 2</span>");
Leo Repp56904d22021-04-26 15:53:22 +0200422 expect(menu.shownItem(2).active()).toBe(false);
Leo Reppdedcf1a2021-08-18 18:57:47 +0200423 expect(directElementChildrenByTagName(menu.element(),"li")[3]).toBe(undefined);
Leo Repp56904d22021-04-26 15:53:22 +0200424 expect(menu.alwaysEntry().active()).toBe(true);
425
426 // Activate prev (2)
427 menu.prev();
Leo Reppdedcf1a2021-08-18 18:57:47 +0200428 expect(directElementChildrenByTagName(menu.element(),"li")[0].innerHTML).toEqual("<strong>Morphology</strong><span>Example 2</span>");
Leo Repp56904d22021-04-26 15:53:22 +0200429 expect(menu.shownItem(0).active()).toBe(false);
Leo Reppdedcf1a2021-08-18 18:57:47 +0200430 expect(directElementChildrenByTagName(menu.element(),"li")[1].innerHTML).toEqual("<strong>Part-of-Speech</strong>");
Leo Repp56904d22021-04-26 15:53:22 +0200431 expect(menu.shownItem(1).active()).toBe(false);
Leo Reppdedcf1a2021-08-18 18:57:47 +0200432 expect(directElementChildrenByTagName(menu.element(),"li")[2].innerHTML).toEqual("<strong>Syntax</strong>");
Leo Repp56904d22021-04-26 15:53:22 +0200433 expect(menu.shownItem(2).active()).toBe(true);
Leo Reppdedcf1a2021-08-18 18:57:47 +0200434 expect(directElementChildrenByTagName(menu.element(),"li")[3]).toBe(undefined);
Leo Repp56904d22021-04-26 15:53:22 +0200435 expect(menu.alwaysEntry().active()).toBe(false);
436
437 // Activate prev (3)
438 menu.prev();
Leo Reppdedcf1a2021-08-18 18:57:47 +0200439 expect(directElementChildrenByTagName(menu.element(),"li")[0].innerHTML).toEqual("<strong>Morphology</strong><span>Example 2</span>");
Leo Repp56904d22021-04-26 15:53:22 +0200440 expect(menu.shownItem(0).active()).toBe(false);
Leo Reppdedcf1a2021-08-18 18:57:47 +0200441 expect(directElementChildrenByTagName(menu.element(),"li")[1].innerHTML).toEqual("<strong>Part-of-Speech</strong>");
Leo Repp56904d22021-04-26 15:53:22 +0200442 expect(menu.shownItem(1).active()).toBe(true);
Leo Reppdedcf1a2021-08-18 18:57:47 +0200443 expect(directElementChildrenByTagName(menu.element(),"li")[2].innerHTML).toEqual("<strong>Syntax</strong>");
Leo Repp56904d22021-04-26 15:53:22 +0200444 expect(menu.shownItem(2).active()).toBe(false);
Leo Reppdedcf1a2021-08-18 18:57:47 +0200445 expect(directElementChildrenByTagName(menu.element(),"li")[3]).toBe(undefined);
Leo Repp56904d22021-04-26 15:53:22 +0200446 expect(menu.alwaysEntry().active()).toBe(false);
447
448 // Activate prev (4)
449 menu.prev();
450 expect(menu.shownItem(0).name()).toEqual("Morphology");
451 expect(menu.shownItem(0).active()).toBe(true);
452 expect(menu.shownItem(1).name()).toEqual("Part-of-Speech");
453 expect(menu.shownItem(1).active()).toBe(false);
454 expect(menu.shownItem(2).name()).toEqual("Syntax");
455 expect(menu.shownItem(2).active()).toBe(false);
Leo Reppdedcf1a2021-08-18 18:57:47 +0200456 expect(directElementChildrenByTagName(menu.element(),"li")[3]).toBe(undefined);
Leo Repp56904d22021-04-26 15:53:22 +0200457 expect(menu.alwaysEntry().active()).toBe(false);
458
459 // Activate prev (5)
460 menu.prev();
461 expect(menu.shownItem(0).name()).toEqual("Lemma");
462 expect(menu.shownItem(0).active()).toBe(true);
463 expect(menu.shownItem(1).name()).toEqual("Morphology");
464 expect(menu.shownItem(1).active()).toBe(false);
465 expect(menu.shownItem(2).name()).toEqual("Part-of-Speech");
466 expect(menu.shownItem(2).active()).toBe(false);
Leo Reppdedcf1a2021-08-18 18:57:47 +0200467 expect(directElementChildrenByTagName(menu.element(),"li")[3]).toBe(undefined);
Leo Repp56904d22021-04-26 15:53:22 +0200468 expect(menu.alwaysEntry().active()).toBe(false);
469
470 // Activate prev (6)
471 menu.prev();
472 expect(menu.shownItem(0).name()).toEqual("Constituency");
473 expect(menu.shownItem(0).active()).toBe(true);
474 expect(menu.shownItem(1).name()).toEqual("Lemma");
475 expect(menu.shownItem(1).active()).toBe(false);
476 expect(menu.shownItem(2).name()).toEqual("Morphology");
477 expect(menu.shownItem(2).active()).toBe(false);
Leo Reppdedcf1a2021-08-18 18:57:47 +0200478 expect(directElementChildrenByTagName(menu.element(),"li")[3]).toBe(undefined);
Leo Repp56904d22021-04-26 15:53:22 +0200479 expect(menu.alwaysEntry().active()).toBe(false);
480
481 // Activate next (7)
482 menu.next();
483 expect(menu.shownItem(0).name()).toEqual("Constituency");
484 expect(menu.shownItem(0).active()).toBe(false);
485 expect(menu.shownItem(1).name()).toEqual("Lemma");
486 expect(menu.shownItem(1).active()).toBe(true);
487 expect(menu.shownItem(2).name()).toEqual("Morphology");
488 expect(menu.shownItem(2).active()).toBe(false);
Leo Reppdedcf1a2021-08-18 18:57:47 +0200489 expect(directElementChildrenByTagName(menu.element(),"li")[3]).toBe(undefined);
Leo Repp56904d22021-04-26 15:53:22 +0200490 expect(menu.alwaysEntry().active()).toBe(false);
491
492 // Activate prev (8)
493 menu.prev();
494
495 // Activate prev (9) - Roll again
496 menu.prev();
497 expect(menu.shownItem(0).name()).toEqual("Constituency");
498 expect(menu.shownItem(0).active()).toBe(false);
499 expect(menu.shownItem(1).name()).toEqual("Lemma");
500 expect(menu.shownItem(1).active()).toBe(false);
501 expect(menu.shownItem(2).name()).toEqual("Morphology");
502 expect(menu.shownItem(2).active()).toBe(false);
Leo Reppdedcf1a2021-08-18 18:57:47 +0200503 expect(directElementChildrenByTagName(menu.element(),"li")[3]).toBe(undefined);
Leo Repp56904d22021-04-26 15:53:22 +0200504 expect(menu.alwaysEntry().active()).toBe(true);
505
506 // Activate prev (10)
507 menu.prev()
508 expect(menu.shownItem(0).name()).toEqual("Morphology");
509 expect(menu.shownItem(0).active()).toBe(false);
510 expect(menu.shownItem(1).name()).toEqual("Part-of-Speech");
511 expect(menu.shownItem(1).active()).toBe(false);
512 expect(menu.shownItem(2).name()).toEqual("Syntax");
513 expect(menu.shownItem(2).active()).toBe(true);
Leo Reppdedcf1a2021-08-18 18:57:47 +0200514 expect(directElementChildrenByTagName(menu.element(),"li")[3]).toBe(undefined);
Leo Repp56904d22021-04-26 15:53:22 +0200515 expect(menu.alwaysEntry().active()).toBe(false);
516 expect(menu._prefix.active()).toBe(false);
517 expect(menu.alwaysEntryValue()).toBe("");
518 expect(menu.alwaysEntry().element().innerHTML).toBe("Speichern");
519
520 });
521
522 it('should be prevable without active field', function () {
523 var menu = HintMenu.create("cnx/", list);
524 menu.limit(3);
525 expect(menu.show()).toBe(true);
526 menu.prev();
527 expect(menu.alwaysEntry().active()).toBe(true);
528 expect(menu.shownItem(2).active()).toEqual(false);
529 expect(menu.shownItem(2).lcField()).toEqual(' morphology example 2');
530 menu.prev()
531 expect(menu.shownItem(2).active()).toEqual(true);
532 expect(menu.shownItem(2).lcField()).toEqual(' syntax');
533 });
534
535 it('should be navigatable and filterable (prefix = "o")', function () {
536 var menu = HintMenu.create("cnx/", list);
537 menu._firstActive = true;
538 menu.limit(2);
539
540 expect(menu.prefix("o").show()).toBe(true);
541 expect(menu.alwaysEntryValue("o").alwaysEntryValue()).toBe("o");
542 expect(menu._prefix.active()).toBe(false);
543 expect(menu.alwaysEntry().active()).toBe(false);
544
545 expect(menu.shownItem(0).name()).toEqual("Constituency");
Leo Reppdedcf1a2021-08-18 18:57:47 +0200546 expect(directElementChildrenByTagName(menu.element(),"li")[0].innerHTML).toEqual("<strong>C<mark>o</mark>nstituency</strong><span>Example 1</span>");
Leo Repp56904d22021-04-26 15:53:22 +0200547 expect(menu.shownItem(0).active()).toBe(true);
548 expect(menu.shownItem(1).name()).toEqual("Morphology");
Leo Reppdedcf1a2021-08-18 18:57:47 +0200549 expect(directElementChildrenByTagName(menu.element(),"li")[1].innerHTML).toEqual("<strong>M<mark>o</mark>rph<mark>o</mark>l<mark>o</mark>gy</strong><span>Example 2</span>");
Leo Repp56904d22021-04-26 15:53:22 +0200550 expect(menu.shownItem(1).active()).toBe(false);
551 expect(menu.shownItem(2)).toBe(undefined);
552
553 // Next (1)
554 menu.next();
555 expect(menu.shownItem(0).name()).toEqual("Constituency");
Leo Reppdedcf1a2021-08-18 18:57:47 +0200556 expect(directElementChildrenByTagName(menu.element(),"li")[0].innerHTML).toEqual("<strong>C<mark>o</mark>nstituency</strong><span>Example 1</span>");
Leo Repp56904d22021-04-26 15:53:22 +0200557 expect(menu.shownItem(0).active()).toBe(false);
558 expect(menu.shownItem(1).name()).toEqual("Morphology");
Leo Reppdedcf1a2021-08-18 18:57:47 +0200559 expect(directElementChildrenByTagName(menu.element(),"li")[1].innerHTML).toEqual("<strong>M<mark>o</mark>rph<mark>o</mark>l<mark>o</mark>gy</strong><span>Example 2</span>");
Leo Repp56904d22021-04-26 15:53:22 +0200560 expect(menu.shownItem(1).active()).toBe(true);
561 expect(menu.shownItem(2)).toBe(undefined);
562
563 // Next (2)
564 menu.next();
565 expect(menu.shownItem(0).name()).toEqual("Morphology");
Leo Reppdedcf1a2021-08-18 18:57:47 +0200566 expect(directElementChildrenByTagName(menu.element(),"li")[0].innerHTML).toEqual("<strong>M<mark>o</mark>rph<mark>o</mark>l<mark>o</mark>gy</strong><span>Example 2</span>");
Leo Repp56904d22021-04-26 15:53:22 +0200567 expect(menu.shownItem(0).active()).toBe(false);
568 expect(menu.shownItem(1).name()).toEqual("Part-of-Speech");
Leo Reppdedcf1a2021-08-18 18:57:47 +0200569 expect(directElementChildrenByTagName(menu.element(),"li")[1].innerHTML).toEqual("<strong>Part-<mark>o</mark>f-Speech</strong>");
Leo Repp56904d22021-04-26 15:53:22 +0200570 expect(menu.shownItem(1).active()).toBe(true);
571 expect(menu.shownItem(2)).toBe(undefined);
572
573 // Next (3) - to prefix
574 menu.next();
575 expect(menu.shownItem(0).name()).toEqual("Morphology");
Leo Reppdedcf1a2021-08-18 18:57:47 +0200576 expect(directElementChildrenByTagName(menu.element(),"li")[0].innerHTML).toEqual("<strong>M<mark>o</mark>rph<mark>o</mark>l<mark>o</mark>gy</strong><span>Example 2</span>");
Leo Repp56904d22021-04-26 15:53:22 +0200577 expect(menu.shownItem(0).active()).toBe(false);
578 expect(menu.shownItem(1).name()).toEqual("Part-of-Speech");
Leo Reppdedcf1a2021-08-18 18:57:47 +0200579 expect(directElementChildrenByTagName(menu.element(),"li")[1].innerHTML).toEqual("<strong>Part-<mark>o</mark>f-Speech</strong>");
Leo Repp56904d22021-04-26 15:53:22 +0200580 expect(menu.shownItem(1).active()).toBe(false);
581 expect(menu.shownItem(2)).toBe(undefined);
582 expect(menu._prefix.active()).toBe(true);
583 expect(menu.alwaysEntry().active()).toBe(false);
584
585 // Next (4) - to entry
586 menu.next();
587 expect(menu.shownItem(0).name()).toEqual("Morphology");
Leo Reppdedcf1a2021-08-18 18:57:47 +0200588 expect(directElementChildrenByTagName(menu.element(),"li")[0].innerHTML).toEqual("<strong>M<mark>o</mark>rph<mark>o</mark>l<mark>o</mark>gy</strong><span>Example 2</span>");
Leo Repp56904d22021-04-26 15:53:22 +0200589 expect(menu.shownItem(0).active()).toBe(false);
590 expect(menu.shownItem(1).name()).toEqual("Part-of-Speech");
Leo Reppdedcf1a2021-08-18 18:57:47 +0200591 expect(directElementChildrenByTagName(menu.element(),"li")[1].innerHTML).toEqual("<strong>Part-<mark>o</mark>f-Speech</strong>");
Leo Repp56904d22021-04-26 15:53:22 +0200592 expect(menu.shownItem(1).active()).toBe(false);
593 expect(menu.shownItem(2)).toBe(undefined);
594 expect(menu._prefix.active()).toBe(false);
595 expect(menu.alwaysEntry().active()).toBe(true);
596
597 menu.next();
598 expect(menu.shownItem(0).name()).toEqual("Constituency");
Leo Reppdedcf1a2021-08-18 18:57:47 +0200599 expect(directElementChildrenByTagName(menu.element(),"li")[0].innerHTML).toEqual("<strong>C<mark>o</mark>nstituency</strong><span>Example 1</span>");
Leo Repp56904d22021-04-26 15:53:22 +0200600 expect(menu.shownItem(0).active()).toBe(true);
601 expect(menu.shownItem(1).name()).toEqual("Morphology");
Leo Reppdedcf1a2021-08-18 18:57:47 +0200602 expect(directElementChildrenByTagName(menu.element(),"li")[1].innerHTML).toEqual("<strong>M<mark>o</mark>rph<mark>o</mark>l<mark>o</mark>gy</strong><span>Example 2</span>");
Leo Repp56904d22021-04-26 15:53:22 +0200603 expect(menu.shownItem(1).active()).toBe(false);
604 expect(menu.shownItem(2)).toBe(undefined);
605
606 expect(menu.prefix("o").show()).toBe(true);
607 expect(menu.alwaysEntryValue("o").alwaysEntryValue()).toBe("o");
608 expect(menu._prefix.active()).toBe(false);
609 expect(menu.alwaysEntry().active()).toBe(false);
610 });
611
612
613 it('should be navigatable and filterable (prefix = "ex", "e")', function () {
614 var menu = HintMenu.create("cnx/", list);
615 menu._firstActive = true;
616
617 menu.limit(2);
618 expect(menu.prefix("ex").show()).toBe(true);
619 expect(menu.alwaysEntryValue("ex").alwaysEntryValue()).toBe("ex");
620 expect(menu._prefix.active()).toBe(false);
621 expect(menu.alwaysEntry().active()).toBe(false);
622
623 expect(menu.shownItem(0).name()).toEqual("Constituency");
Leo Reppdedcf1a2021-08-18 18:57:47 +0200624 expect(directElementChildrenByTagName(menu.element(),"li")[0].innerHTML).toEqual("<strong>Constituency</strong><span><mark>Ex</mark>ample 1</span>");
Leo Repp56904d22021-04-26 15:53:22 +0200625 expect(menu.shownItem(0).active()).toBe(true);
626 expect(menu.shownItem(1).name()).toEqual("Morphology");
Leo Reppdedcf1a2021-08-18 18:57:47 +0200627 expect(directElementChildrenByTagName(menu.element(),"li")[1].innerHTML).toEqual("<strong>Morphology</strong><span><mark>Ex</mark>ample 2</span>");
Leo Repp56904d22021-04-26 15:53:22 +0200628 expect(menu.shownItem(1).active()).toBe(false);
629 expect(menu.shownItem(2)).toBe(undefined);
630
631 // Next (1)
632 menu.next();
633 expect(menu.shownItem(0).name()).toEqual("Constituency");
Leo Reppdedcf1a2021-08-18 18:57:47 +0200634 expect(directElementChildrenByTagName(menu.element(),"li")[0].innerHTML).toEqual("<strong>Constituency</strong><span><mark>Ex</mark>ample 1</span>");
Leo Repp56904d22021-04-26 15:53:22 +0200635 expect(menu.shownItem(0).active()).toBe(false);
636 expect(menu.shownItem(1).name()).toEqual("Morphology");
Leo Reppdedcf1a2021-08-18 18:57:47 +0200637 expect(directElementChildrenByTagName(menu.element(),"li")[1].innerHTML).toEqual("<strong>Morphology</strong><span><mark>Ex</mark>ample 2</span>");
Leo Repp56904d22021-04-26 15:53:22 +0200638 expect(menu.shownItem(1).active()).toBe(true);
639 expect(menu.shownItem(2)).toBe(undefined);
640 expect(menu.alwaysEntryValue()).toBe("ex");
641 expect(menu._prefix.active()).toBe(false);
642 expect(menu.alwaysEntry().active()).toBe(false);
643
644 // Next (2)
645 menu.next();
646
647 expect(menu.prefix()).toEqual('ex');
648 expect(menu.shownItem(0).name()).toEqual("Constituency");
Leo Reppdedcf1a2021-08-18 18:57:47 +0200649 expect(directElementChildrenByTagName(menu.element(),"li")[0].innerHTML).toEqual("<strong>Constituency</strong><span><mark>Ex</mark>ample 1</span>");
Leo Repp56904d22021-04-26 15:53:22 +0200650 expect(menu.shownItem(0).active()).toBe(false);
651
652 expect(menu.shownItem(1).name()).toEqual("Morphology");
Leo Reppdedcf1a2021-08-18 18:57:47 +0200653 expect(directElementChildrenByTagName(menu.element(),"li")[1].innerHTML).toEqual("<strong>Morphology</strong><span><mark>Ex</mark>ample 2</span>");
Leo Repp56904d22021-04-26 15:53:22 +0200654 expect(menu.shownItem(1).active()).toBe(false);
655 expect(menu.shownItem(2)).toBe(undefined);
656 expect(menu.alwaysEntryValue()).toBe("ex");
657 expect(menu._prefix.active()).toBe(true);
658 expect(menu.alwaysEntry().active()).toBe(false);
659
660 // Reset limit
661 menu.limit(5);
662
663 // Change show
664 expect(menu.prefix("e").show()).toBe(true);
665 expect(menu.alwaysEntryValue("e").alwaysEntryValue()).toBe("e");
666 expect(menu._prefix.active()).toBe(false);
667 expect(menu.alwaysEntry().active()).toBe(false);
668 expect(menu.shownItem(0).name()).toEqual("Constituency");
Leo Reppdedcf1a2021-08-18 18:57:47 +0200669 expect(directElementChildrenByTagName(menu.element(),"li")[0].innerHTML).toEqual("<strong>Constitu<mark>e</mark>ncy</strong><span><mark>E</mark>xampl<mark>e</mark> 1</span>");
Leo Repp56904d22021-04-26 15:53:22 +0200670 expect(menu.shownItem(0).active()).toBe(true);
671 expect(menu.shownItem(1).name()).toEqual("Morphology");
Leo Reppdedcf1a2021-08-18 18:57:47 +0200672 expect(directElementChildrenByTagName(menu.element(),"li")[1].innerHTML).toEqual("<strong>Morphology</strong><span><mark>E</mark>xampl<mark>e</mark> 2</span>");
Leo Repp56904d22021-04-26 15:53:22 +0200673 expect(menu.shownItem(1).active()).toBe(false);
674 expect(menu.shownItem(2)).toBe(undefined);
675
676 // Next (1)
677 menu.next();
678 expect(menu._prefix.active()).toBe(false);
679 expect(menu.prefix()).toEqual('e');
680 expect(menu.shownItem(0).name()).toEqual("Constituency");
Leo Reppdedcf1a2021-08-18 18:57:47 +0200681 expect(directElementChildrenByTagName(menu.element(),"li")[0].innerHTML).toEqual("<strong>Constitu<mark>e</mark>ncy</strong><span><mark>E</mark>xampl<mark>e</mark> 1</span>");
Leo Repp56904d22021-04-26 15:53:22 +0200682 expect(menu.shownItem(0).active()).toBe(false);
683 expect(menu.shownItem(1).name()).toEqual("Morphology");
Leo Reppdedcf1a2021-08-18 18:57:47 +0200684 expect(directElementChildrenByTagName(menu.element(),"li")[1].innerHTML).toEqual("<strong>Morphology</strong><span><mark>E</mark>xampl<mark>e</mark> 2</span>");
Leo Repp56904d22021-04-26 15:53:22 +0200685 expect(menu.shownItem(1).active()).toBe(true);
686 expect(menu.shownItem(2)).toBe(undefined);
687 expect(menu._prefix.active()).toBe(false);
688 expect(menu.alwaysEntry().active()).toBe(false);
689
690 // Next (2)
691 menu.next();
692 expect(menu._prefix.active()).toBe(true);
693 expect(menu.shownItem(0).name()).toEqual("Constituency");
Leo Reppdedcf1a2021-08-18 18:57:47 +0200694 expect(directElementChildrenByTagName(menu.element(),"li")[0].innerHTML).toEqual("<strong>Constitu<mark>e</mark>ncy</strong><span><mark>E</mark>xampl<mark>e</mark> 1</span>");
Leo Repp56904d22021-04-26 15:53:22 +0200695 expect(menu.shownItem(0).active()).toBe(false);
696 expect(menu.shownItem(1).name()).toEqual("Morphology");
Leo Reppdedcf1a2021-08-18 18:57:47 +0200697 expect(directElementChildrenByTagName(menu.element(),"li")[1].innerHTML).toEqual("<strong>Morphology</strong><span><mark>E</mark>xampl<mark>e</mark> 2</span>");
Leo Repp56904d22021-04-26 15:53:22 +0200698 expect(menu.shownItem(1).active()).toBe(false);
699 expect(menu.shownItem(2)).toBe(undefined);
700 expect(menu._prefix.active()).toBe(true);
701 expect(menu.alwaysEntry().active()).toBe(false);
702
703 // Next (2.5)
704 menu.next();
705 expect(menu._prefix.active()).toBe(false);
706 expect(menu.shownItem(0).name()).toEqual("Constituency");
Leo Reppdedcf1a2021-08-18 18:57:47 +0200707 expect(directElementChildrenByTagName(menu.element(),"li")[0].innerHTML).toEqual("<strong>Constitu<mark>e</mark>ncy</strong><span><mark>E</mark>xampl<mark>e</mark> 1</span>");
Leo Repp56904d22021-04-26 15:53:22 +0200708 expect(menu.shownItem(0).active()).toBe(false);
709 expect(menu.shownItem(1).name()).toEqual("Morphology");
Leo Reppdedcf1a2021-08-18 18:57:47 +0200710 expect(directElementChildrenByTagName(menu.element(),"li")[1].innerHTML).toEqual("<strong>Morphology</strong><span><mark>E</mark>xampl<mark>e</mark> 2</span>");
Leo Repp56904d22021-04-26 15:53:22 +0200711 expect(menu.shownItem(1).active()).toBe(false);
712 expect(menu.shownItem(2)).toBe(undefined);
713 expect(menu._prefix.active()).toBe(false);
714 expect(menu.alwaysEntry().active()).toBe(true);
715
716 // Next (3)
717 menu.next();
718 expect(menu._prefix.active()).toBe(false);
719 expect(menu.shownItem(0).name()).toEqual("Constituency");
Leo Reppdedcf1a2021-08-18 18:57:47 +0200720 expect(directElementChildrenByTagName(menu.element(),"li")[0].innerHTML).toEqual("<strong>Constitu<mark>e</mark>ncy</strong><span><mark>E</mark>xampl<mark>e</mark> 1</span>");
Leo Repp56904d22021-04-26 15:53:22 +0200721 expect(menu.shownItem(0).active()).toBe(true);
722 expect(menu.shownItem(1).name()).toEqual("Morphology");
Leo Reppdedcf1a2021-08-18 18:57:47 +0200723 expect(directElementChildrenByTagName(menu.element(),"li")[1].innerHTML).toEqual("<strong>Morphology</strong><span><mark>E</mark>xampl<mark>e</mark> 2</span>");
Leo Repp56904d22021-04-26 15:53:22 +0200724 expect(menu.shownItem(1).active()).toBe(false);
725 expect(menu.shownItem(2)).toBe(undefined);
726
727 expect(menu.alwaysEntryValue()).toBe("e");
728 expect(menu._prefix.active()).toBe(false);
729 expect(menu.alwaysEntry().active()).toBe(false);
730 });
731
732 it('should be filterable (multiple prefix = "pro sin")', function () {
733 var menu = HintMenu.create("drukola/p=", listMultiPrefix);
734 menu._firstActive = true;
735
736 menu.limit(2);
737 expect(menu.prefix("pro sin").show()).toBe(true);
738 expect(menu.alwaysEntryValue("pro sin").alwaysEntryValue()).toBe("pro sin");
739 expect(menu._prefix.active()).toBe(false);
740 expect(menu.alwaysEntry().active()).toBe(false);
741 expect(menu.shownItem(0).name()).toEqual("PPS");
Leo Reppdedcf1a2021-08-18 18:57:47 +0200742 expect(directElementChildrenByTagName(menu.element(),"li")[0].innerHTML).toEqual(
Leo Repp56904d22021-04-26 15:53:22 +0200743 "<strong>PPS</strong><span>Personal <mark>Pro</mark>noun, <mark>Sin</mark>gular</span>"
744 );
745
746 expect(menu.shownItem(0).active()).toBe(true);
747 expect(menu.shownItem(1).name()).toEqual("PPSA");
Leo Reppdedcf1a2021-08-18 18:57:47 +0200748 expect(directElementChildrenByTagName(menu.element(),"li")[1].innerHTML).toEqual("<strong>PPSA</strong><span>Personal <mark>Pro</mark>noun, <mark>Sin</mark>gular, Accusative</span>");
Leo Repp56904d22021-04-26 15:53:22 +0200749 expect(menu.shownItem(1).active()).toBe(false);
750
751 expect(menu.shownItem(2)).toBe(undefined);
752 });
753
754 it('should be filterable (trimming = " p")', function () {
755 var menu = HintMenu.create("/p=", listMultiPrefix);
756 // menu._firstActive = true;
757
758 menu.limit(2);
759 expect(menu.show()).toBe(true);
760 menu._prefix.add(" ");
761 menu._entry.add(" ")
762 expect(menu.show()).toBe(true);
763 menu._prefix.add("p")
764 menu._entry.add("p")
765 expect(menu.alwaysEntryValue()).toBe(" p");
766 expect(menu.show()).toBe(true);
767 expect(menu.shownItem(0).name()).toEqual("PP");
Leo Reppdedcf1a2021-08-18 18:57:47 +0200768 expect(directElementChildrenByTagName(menu.element(),"li")[0].innerHTML).toEqual(
Leo Repp56904d22021-04-26 15:53:22 +0200769 "<strong><mark>P</mark><mark>P</mark></strong>"+
770 "<span><mark>P</mark>ersonal <mark>P</mark>ronoun</span>"
771 );
772 });
773
774
775
776 it('should ignore navigation with failing prefix', function () {
777 var menu = HintMenu.create("cnx/", list);
778 menu.limit(2);
779 expect(menu.show()).toBe(true);
780
781 menu.next();
782
783 expect(menu.prefix("exit").show()).toBe(true);
784 expect(menu.element().querySelector('li')).toBe(null);
785 expect(menu.shownItem(0)).toBeUndefined();
786 expect(menu._prefix.active()).toBe(true);
787
788 menu.next();
789 expect(menu._prefix.active()).toBe(false);
790 expect(menu._entry.active()).toBe(true);
791
792 menu.next();
793 expect(menu._prefix.active()).toBe(true);
794 expect(menu._entry.active()).toBe(false);
795
796 menu.prev();
797 expect(menu._prefix.active()).toBe(false);
798 expect(menu._entry.active()).toBe(true);
799
800 menu.prev();
801 expect(menu._prefix.active()).toBe(true);
802 expect(menu._entry.active()).toBe(false);
803
804 });
805
806 it('should be navigatable with prefix', function () {
807 var menu = HintMenu.create("cnx/", demolist);
808 menu._firstActive = true;
809
810 menu.limit(3);
811
812 expect(menu.show()).toBe(true);
813 expect(menu.prefix()).toEqual("");
814 expect(menu.alwaysEntryValue()).toEqual("");
815 expect(menu._prefix.active()).toEqual(false);
816 expect(menu._entry.active()).toEqual(false);
817
818 expect(menu.shownItem(0).name()).toEqual("Titel");
Leo Reppdedcf1a2021-08-18 18:57:47 +0200819 expect(directElementChildrenByTagName(menu.element(),"li")[0].innerHTML).toEqual("<strong>Titel</strong>");
Leo Repp56904d22021-04-26 15:53:22 +0200820 expect(menu.shownItem(0).active()).toBe(true);
821 expect(menu.shownItem(1).name()).toEqual("Untertitel");
Leo Reppdedcf1a2021-08-18 18:57:47 +0200822 expect(directElementChildrenByTagName(menu.element(),"li")[1].innerHTML).toEqual("<strong>Untertitel</strong>");
Leo Repp56904d22021-04-26 15:53:22 +0200823 expect(menu.shownItem(1).active()).toBe(false);
824 expect(menu.shownItem(2).name()).toEqual("Veröffentlichungsdatum");
Leo Reppdedcf1a2021-08-18 18:57:47 +0200825 expect(directElementChildrenByTagName(menu.element(),"li")[2].innerHTML).toEqual("<strong>Veröffentlichungsdatum</strong>");
Leo Repp56904d22021-04-26 15:53:22 +0200826 expect(menu.shownItem(2).active()).toBe(false);
827 expect(menu.shownItem(3)).toBe(undefined);
828 expect(menu._prefix.active()).toEqual(false);
829 expect(menu._entry.active()).toEqual(false);
830
831 menu._prefix.add('a');
832 menu._entry.add('a');
833 expect(menu._prefix.active()).toEqual(false);
834 expect(menu._entry.active()).toEqual(false);
835 expect(menu.show()).toBe(true);
836 expect(menu.prefix()).toEqual("a");
837 expect(menu.alwaysEntryValue()).toEqual("a");
838 expect(menu.shownItem(0).name()).toEqual("Autor");
Leo Reppdedcf1a2021-08-18 18:57:47 +0200839 expect(directElementChildrenByTagName(menu.element(),"li")[0].innerHTML).toEqual("<strong><mark>A</mark>utor</strong>");
Leo Repp56904d22021-04-26 15:53:22 +0200840
841 menu._prefix.add('u');
842 menu._entry.add('u');
843 expect(menu.show()).toBe(true);
844 expect(menu.prefix()).toEqual("au");
845 expect(menu.alwaysEntryValue()).toEqual("au");
846 expect(menu.shownItem(0).name()).toEqual("Autor");
847 expect(menu._prefix.active()).toEqual(false);
848 expect(menu._entry.active()).toEqual(false);
Leo Reppdedcf1a2021-08-18 18:57:47 +0200849 expect(directElementChildrenByTagName(menu.element(),"li")[0].innerHTML).toEqual("<strong><mark>Au</mark>tor</strong>");
Leo Repp56904d22021-04-26 15:53:22 +0200850
851 menu._prefix.chop();
852 menu._entry.chop();
853 expect(menu.show()).toBe(true);
854 expect(menu.prefix()).toEqual("a");
855 expect(menu.alwaysEntryValue()).toEqual("a");
856 expect(menu.shownItem(0).name()).toEqual("Autor");
Leo Reppdedcf1a2021-08-18 18:57:47 +0200857 expect(directElementChildrenByTagName(menu.element(),"li")[0].innerHTML).toEqual("<strong><mark>A</mark>utor</strong>");
Leo Repp56904d22021-04-26 15:53:22 +0200858
859 menu._prefix.chop();
860 menu._entry.chop();
861 expect(menu.show()).toBe(true);
862 expect(menu.prefix()).toEqual("");
863 expect(menu.alwaysEntryValue()).toEqual("");
864 expect(menu._prefix.active()).toEqual(false);
865 expect(menu._entry.active()).toEqual(false);
866 expect(menu.shownItem(0).name()).toEqual("Titel");
Leo Reppdedcf1a2021-08-18 18:57:47 +0200867 expect(directElementChildrenByTagName(menu.element(),"li")[0].innerHTML).toEqual("<strong>Titel</strong>");
Leo Repp56904d22021-04-26 15:53:22 +0200868 expect(menu.shownItem(0).active()).toBe(true);
869 expect(menu.shownItem(1).name()).toEqual("Untertitel");
Leo Reppdedcf1a2021-08-18 18:57:47 +0200870 expect(directElementChildrenByTagName(menu.element(),"li")[1].innerHTML).toEqual("<strong>Untertitel</strong>");
Leo Repp56904d22021-04-26 15:53:22 +0200871 expect(menu.shownItem(1).active()).toBe(false);
872 expect(menu.shownItem(2).name()).toEqual("Veröffentlichungsdatum");
Leo Reppdedcf1a2021-08-18 18:57:47 +0200873 expect(directElementChildrenByTagName(menu.element(),"li")[2].innerHTML).toEqual("<strong>Veröffentlichungsdatum</strong>");
Leo Repp56904d22021-04-26 15:53:22 +0200874 expect(menu.shownItem(2).active()).toBe(false);
875 expect(menu.shownItem(3)).toBe(undefined);
876
877 // Forward
878 menu._prefix.chop();
879 menu._entry.chop();
880 expect(menu.show()).toBe(true);
881 expect(menu.prefix()).toEqual("");
882 expect(menu._prefix.active()).toEqual(false);
883 expect(menu._entry.active()).toEqual(false);
884 expect(menu.alwaysEntryValue()).toEqual("");
885 expect(menu.shownItem(0).name()).toEqual("Titel");
Leo Reppdedcf1a2021-08-18 18:57:47 +0200886 expect(directElementChildrenByTagName(menu.element(),"li")[0].innerHTML).toEqual("<strong>Titel</strong>");
Leo Repp56904d22021-04-26 15:53:22 +0200887 expect(menu.shownItem(0).active()).toBe(true);
888 expect(menu.shownItem(1).name()).toEqual("Untertitel");
Leo Reppdedcf1a2021-08-18 18:57:47 +0200889 expect(directElementChildrenByTagName(menu.element(),"li")[1].innerHTML).toEqual("<strong>Untertitel</strong>");
Leo Repp56904d22021-04-26 15:53:22 +0200890 expect(menu.shownItem(1).active()).toBe(false);
891 expect(menu.shownItem(2).name()).toEqual("Veröffentlichungsdatum");
Leo Reppdedcf1a2021-08-18 18:57:47 +0200892 expect(directElementChildrenByTagName(menu.element(),"li")[2].innerHTML).toEqual("<strong>Veröffentlichungsdatum</strong>");
Leo Repp56904d22021-04-26 15:53:22 +0200893 expect(menu.shownItem(2).active()).toBe(false);
894
895 // Forward
896 menu.next();
897 expect(menu.prefix()).toEqual("");
898 expect(menu.alwaysEntryValue()).toEqual("");
899 expect(menu._prefix.active()).toEqual(false);
900 expect(menu._entry.active()).toEqual(false);
901 expect(menu.shownItem(0).name()).toEqual("Titel");
Leo Reppdedcf1a2021-08-18 18:57:47 +0200902 expect(directElementChildrenByTagName(menu.element(),"li")[0].innerHTML).toEqual("<strong>Titel</strong>");
Leo Repp56904d22021-04-26 15:53:22 +0200903 expect(menu.shownItem(0).active()).toBe(false);
904 expect(menu.shownItem(1).name()).toEqual("Untertitel");
Leo Reppdedcf1a2021-08-18 18:57:47 +0200905 expect(directElementChildrenByTagName(menu.element(),"li")[1].innerHTML).toEqual("<strong>Untertitel</strong>");
Leo Repp56904d22021-04-26 15:53:22 +0200906 expect(menu.shownItem(1).active()).toBe(true);
907 expect(menu.shownItem(2).name()).toEqual("Veröffentlichungsdatum");
Leo Reppdedcf1a2021-08-18 18:57:47 +0200908 expect(directElementChildrenByTagName(menu.element(),"li")[2].innerHTML).toEqual("<strong>Veröffentlichungsdatum</strong>");
Leo Repp56904d22021-04-26 15:53:22 +0200909 expect(menu.shownItem(2).active()).toBe(false);
910 expect(menu.shownItem(3)).toBe(undefined);
911
912 // Forward
913 menu.next();
914 expect(menu.prefix()).toEqual("");
915 expect(menu.alwaysEntryValue()).toEqual("");
916 expect(menu._prefix.active()).toEqual(false);
917 expect(menu._entry.active()).toEqual(false);
918 expect(menu.shownItem(0).name()).toEqual("Titel");
Leo Reppdedcf1a2021-08-18 18:57:47 +0200919 expect(directElementChildrenByTagName(menu.element(),"li")[0].innerHTML).toEqual("<strong>Titel</strong>");
Leo Repp56904d22021-04-26 15:53:22 +0200920 expect(menu.shownItem(0).active()).toBe(false);
921 expect(menu.shownItem(1).name()).toEqual("Untertitel");
Leo Reppdedcf1a2021-08-18 18:57:47 +0200922 expect(directElementChildrenByTagName(menu.element(),"li")[1].innerHTML).toEqual("<strong>Untertitel</strong>");
Leo Repp56904d22021-04-26 15:53:22 +0200923 expect(menu.shownItem(1).active()).toBe(false);
924 expect(menu.shownItem(2).name()).toEqual("Veröffentlichungsdatum");
Leo Reppdedcf1a2021-08-18 18:57:47 +0200925 expect(directElementChildrenByTagName(menu.element(),"li")[2].innerHTML).toEqual("<strong>Veröffentlichungsdatum</strong>");
Leo Repp56904d22021-04-26 15:53:22 +0200926 expect(menu.shownItem(2).active()).toBe(true);
927 expect(menu.shownItem(3)).toBe(undefined);
928
929 // Forward
930 menu.next();
931 expect(menu.prefix()).toEqual("");
932 expect(menu.alwaysEntryValue()).toEqual("");
933 expect(menu.shownItem(0).name()).toEqual("Untertitel");
Leo Reppdedcf1a2021-08-18 18:57:47 +0200934 expect(directElementChildrenByTagName(menu.element(),"li")[0].innerHTML).toEqual("<strong>Untertitel</strong>");
Leo Repp56904d22021-04-26 15:53:22 +0200935 expect(menu.shownItem(0).active()).toBe(false);
936 expect(menu.shownItem(1).name()).toEqual("Veröffentlichungsdatum");
Leo Reppdedcf1a2021-08-18 18:57:47 +0200937 expect(directElementChildrenByTagName(menu.element(),"li")[1].innerHTML).toEqual("<strong>Veröffentlichungsdatum</strong>");
Leo Repp56904d22021-04-26 15:53:22 +0200938 expect(menu.shownItem(1).active()).toBe(false);
939 expect(menu.shownItem(2).name()).toEqual("Länge");
Leo Reppdedcf1a2021-08-18 18:57:47 +0200940 expect(directElementChildrenByTagName(menu.element(),"li")[2].innerHTML).toEqual("<strong>Länge</strong>");
Leo Repp56904d22021-04-26 15:53:22 +0200941 expect(menu.shownItem(2).active()).toBe(true);
942 expect(menu.shownItem(3)).toBe(undefined);
943 expect(menu._prefix.active()).toEqual(false);
944 expect(menu._entry.active()).toEqual(false);
945
946 // Forward
947 menu.next();
948 expect(menu.prefix()).toEqual("");
949 expect(menu.alwaysEntryValue()).toEqual("");
950 expect(menu.shownItem(0).name()).toEqual("Veröffentlichungsdatum");
Leo Reppdedcf1a2021-08-18 18:57:47 +0200951 expect(directElementChildrenByTagName(menu.element(),"li")[0].innerHTML).toEqual("<strong>Veröffentlichungsdatum</strong>");
Leo Repp56904d22021-04-26 15:53:22 +0200952 expect(menu.shownItem(0).active()).toBe(false);
953 expect(menu.shownItem(1).name()).toEqual("Länge");
Leo Reppdedcf1a2021-08-18 18:57:47 +0200954 expect(directElementChildrenByTagName(menu.element(),"li")[1].innerHTML).toEqual("<strong>Länge</strong>");
Leo Repp56904d22021-04-26 15:53:22 +0200955 expect(menu.shownItem(1).active()).toBe(false);
956 expect(menu.shownItem(2).name()).toEqual("Autor");
Leo Reppdedcf1a2021-08-18 18:57:47 +0200957 expect(directElementChildrenByTagName(menu.element(),"li")[2].innerHTML).toEqual("<strong>Autor</strong>");
Leo Repp56904d22021-04-26 15:53:22 +0200958 expect(menu.shownItem(2).active()).toBe(true);
959 expect(menu.shownItem(3)).toBe(undefined);
960 expect(menu._prefix.active()).toEqual(false);
961 expect(menu._entry.active()).toEqual(false);
962
963 // Forward
964 menu.next();
965 expect(menu.prefix()).toEqual("");
966 expect(menu.alwaysEntryValue()).toEqual("");
967 expect(menu.shownItem(0).name()).toEqual("Veröffentlichungsdatum");
Leo Reppdedcf1a2021-08-18 18:57:47 +0200968 expect(directElementChildrenByTagName(menu.element(),"li")[0].innerHTML).toEqual("<strong>Veröffentlichungsdatum</strong>");
Leo Repp56904d22021-04-26 15:53:22 +0200969 expect(menu.shownItem(0).active()).toBe(false);
970 expect(menu.shownItem(1).name()).toEqual("Länge");
Leo Reppdedcf1a2021-08-18 18:57:47 +0200971 expect(directElementChildrenByTagName(menu.element(),"li")[1].innerHTML).toEqual("<strong>Länge</strong>");
Leo Repp56904d22021-04-26 15:53:22 +0200972 expect(menu.shownItem(1).active()).toBe(false);
973 expect(menu.shownItem(2).name()).toEqual("Autor");
Leo Reppdedcf1a2021-08-18 18:57:47 +0200974 expect(directElementChildrenByTagName(menu.element(),"li")[2].innerHTML).toEqual("<strong>Autor</strong>");
Leo Repp56904d22021-04-26 15:53:22 +0200975 expect(menu.shownItem(2).active()).toBe(false);
976 expect(menu.shownItem(3)).toBe(undefined);
977 expect(menu._prefix.active()).toEqual(false);
978 expect(menu._entry.active()).toEqual(true);
979
980 // Forward
981 menu.next();
982 expect(menu.prefix()).toEqual("");
983 expect(menu.alwaysEntryValue()).toEqual("");
984 expect(menu.shownItem(0).name()).toEqual("Titel");
Leo Reppdedcf1a2021-08-18 18:57:47 +0200985 expect(directElementChildrenByTagName(menu.element(),"li")[0].innerHTML).toEqual("<strong>Titel</strong>");
Leo Repp56904d22021-04-26 15:53:22 +0200986 expect(menu.shownItem(0).active()).toBe(true);
987 expect(menu.shownItem(1).name()).toEqual("Untertitel");
Leo Reppdedcf1a2021-08-18 18:57:47 +0200988 expect(directElementChildrenByTagName(menu.element(),"li")[1].innerHTML).toEqual("<strong>Untertitel</strong>");
Leo Repp56904d22021-04-26 15:53:22 +0200989 expect(menu.shownItem(1).active()).toBe(false);
990 expect(menu.shownItem(2).name()).toEqual("Veröffentlichungsdatum");
Leo Reppdedcf1a2021-08-18 18:57:47 +0200991 expect(directElementChildrenByTagName(menu.element(),"li")[2].innerHTML).toEqual("<strong>Veröffentlichungsdatum</strong>");
Leo Repp56904d22021-04-26 15:53:22 +0200992 expect(menu.shownItem(2).active()).toBe(false);
993 });
994
995
996 it('should be navigatable with a prefix (1)', function () {
997 var menu = HintMenu.create("cnx/", demolist);
998 menu._firstActive = true;
999
1000 menu.limit(3);
1001
1002 expect(menu.show()).toBe(true);
1003 expect(menu.prefix()).toEqual("");
1004 expect(menu.alwaysEntryValue()).toEqual("");
1005
1006 // Add prefix in uppercase - but check in lowercase
1007 menu.prefix('El');
1008 menu.alwaysEntryValue('El');
1009 expect(menu.show()).toBe(true);
1010
1011 expect(menu.prefix()).toEqual("El");
1012 expect(menu._prefix.active()).toEqual(false);
1013 expect(menu.alwaysEntryValue()).toEqual("El");
1014 expect(menu._entry.active()).toEqual(false);
1015 expect(menu.shownItem(0).name()).toEqual("Titel");
Leo Reppdedcf1a2021-08-18 18:57:47 +02001016 expect(directElementChildrenByTagName(menu.element(),"li")[0].innerHTML).toEqual("<strong>Tit<mark>el</mark></strong>");
Leo Repp56904d22021-04-26 15:53:22 +02001017 expect(menu.shownItem(0).active()).toBe(true);
1018 expect(menu.shownItem(1).name()).toEqual("Untertitel");
Leo Reppdedcf1a2021-08-18 18:57:47 +02001019 expect(directElementChildrenByTagName(menu.element(),"li")[1].innerHTML).toEqual("<strong>Untertit<mark>el</mark></strong>");
Leo Repp56904d22021-04-26 15:53:22 +02001020 expect(menu.shownItem(1).active()).toBe(false);
1021 expect(menu.shownItem(2)).toBe(undefined);
1022
1023 // Forward
1024 menu.next();
1025 expect(menu.prefix()).toEqual("El");
1026 expect(menu._prefix.active()).toEqual(false);
1027 expect(menu.alwaysEntryValue()).toEqual("El");
1028 expect(menu._entry.active()).toEqual(false);
1029 expect(menu.shownItem(0).name()).toEqual("Titel");
Leo Reppdedcf1a2021-08-18 18:57:47 +02001030 expect(directElementChildrenByTagName(menu.element(),"li")[0].innerHTML).toEqual("<strong>Tit<mark>el</mark></strong>");
Leo Repp56904d22021-04-26 15:53:22 +02001031 expect(menu.shownItem(0).active()).toBe(false);
1032 expect(menu.shownItem(1).name()).toEqual("Untertitel");
Leo Reppdedcf1a2021-08-18 18:57:47 +02001033 expect(directElementChildrenByTagName(menu.element(),"li")[1].innerHTML).toEqual("<strong>Untertit<mark>el</mark></strong>");
Leo Repp56904d22021-04-26 15:53:22 +02001034 expect(menu.shownItem(1).active()).toBe(true);
1035 expect(menu.shownItem(2)).toBe(undefined);
1036
1037 // Forward
1038 menu.next();
1039 expect(menu.prefix()).toEqual("El");
1040 expect(menu._prefix.active()).toEqual(true);
1041 expect(menu.alwaysEntryValue()).toEqual("El");
1042 expect(menu._entry.active()).toEqual(false);
1043 expect(menu.shownItem(0).name()).toEqual("Titel");
Leo Reppdedcf1a2021-08-18 18:57:47 +02001044 expect(directElementChildrenByTagName(menu.element(),"li")[0].innerHTML).toEqual("<strong>Tit<mark>el</mark></strong>");
Leo Repp56904d22021-04-26 15:53:22 +02001045 expect(menu.shownItem(0).active()).toBe(false);
1046 expect(menu.shownItem(1).name()).toEqual("Untertitel");
Leo Reppdedcf1a2021-08-18 18:57:47 +02001047 expect(directElementChildrenByTagName(menu.element(),"li")[1].innerHTML).toEqual("<strong>Untertit<mark>el</mark></strong>");
Leo Repp56904d22021-04-26 15:53:22 +02001048 expect(menu.shownItem(1).active()).toBe(false);
1049 expect(menu.shownItem(2)).toBe(undefined);
1050
1051 // Forward
1052 menu.next();
1053 expect(menu.prefix()).toEqual("El");
1054 expect(menu._prefix.active()).toEqual(false);
1055 expect(menu.alwaysEntryValue()).toEqual("El");
1056 expect(menu._entry.active()).toEqual(true);
1057 expect(menu.shownItem(0).name()).toEqual("Titel");
Leo Reppdedcf1a2021-08-18 18:57:47 +02001058 expect(directElementChildrenByTagName(menu.element(),"li")[0].innerHTML).toEqual("<strong>Tit<mark>el</mark></strong>");
Leo Repp56904d22021-04-26 15:53:22 +02001059 expect(menu.shownItem(0).active()).toBe(false);
1060 expect(menu.shownItem(1).name()).toEqual("Untertitel");
Leo Reppdedcf1a2021-08-18 18:57:47 +02001061 expect(directElementChildrenByTagName(menu.element(),"li")[1].innerHTML).toEqual("<strong>Untertit<mark>el</mark></strong>");
Leo Repp56904d22021-04-26 15:53:22 +02001062 expect(menu.shownItem(1).active()).toBe(false);
1063 expect(menu.shownItem(2)).toBe(undefined);
1064
1065 menu.prev()
1066 expect(menu.prefix()).toEqual("El");
1067 expect(menu._prefix.active()).toEqual(true);
1068 expect(menu.alwaysEntryValue()).toEqual("El");
1069 expect(menu._entry.active()).toEqual(false);
1070 expect(menu.shownItem(0).name()).toEqual("Titel");
Leo Reppdedcf1a2021-08-18 18:57:47 +02001071 expect(directElementChildrenByTagName(menu.element(),"li")[0].innerHTML).toEqual("<strong>Tit<mark>el</mark></strong>");
Leo Repp56904d22021-04-26 15:53:22 +02001072 expect(menu.shownItem(0).active()).toBe(false);
1073 expect(menu.shownItem(1).name()).toEqual("Untertitel");
Leo Reppdedcf1a2021-08-18 18:57:47 +02001074 expect(directElementChildrenByTagName(menu.element(),"li")[1].innerHTML).toEqual("<strong>Untertit<mark>el</mark></strong>");
Leo Repp56904d22021-04-26 15:53:22 +02001075 expect(menu.shownItem(1).active()).toBe(false);
1076 expect(menu.shownItem(2)).toBe(undefined);
1077
1078 // Backward
1079 menu.prev();
1080 expect(menu.prefix()).toEqual("El");
1081 expect(menu._prefix.active()).toEqual(false);
1082 expect(menu.alwaysEntryValue()).toEqual("El");
1083 expect(menu._entry.active()).toEqual(false);
1084 expect(menu.shownItem(0).name()).toEqual("Titel");
Leo Reppdedcf1a2021-08-18 18:57:47 +02001085 expect(directElementChildrenByTagName(menu.element(),"li")[0].innerHTML).toEqual("<strong>Tit<mark>el</mark></strong>");
Leo Repp56904d22021-04-26 15:53:22 +02001086 expect(menu.shownItem(0).active()).toBe(false);
1087
1088 expect(menu.shownItem(1).name()).toEqual("Untertitel");
Leo Reppdedcf1a2021-08-18 18:57:47 +02001089 expect(directElementChildrenByTagName(menu.element(),"li")[1].innerHTML).toEqual("<strong>Untertit<mark>el</mark></strong>");
Leo Repp56904d22021-04-26 15:53:22 +02001090 expect(menu.shownItem(1).active()).toBe(true);
1091 expect(menu.shownItem(2)).toBe(undefined);
1092 });
1093
1094
1095 it('should be navigatable with a prefix (2)', function () {
1096 var menu = HintMenu.create("cnx/", demolist);
1097 menu._firstActive = true;
1098
1099 menu.limit(3);
1100 expect(menu.show()).toBe(true);
1101 expect(menu.prefix()).toEqual("");
1102 menu.prefix('el');
1103 expect(menu.alwaysEntryValue()).toEqual("");
1104 menu.alwaysEntryValue('el');
1105 expect(menu.show()).toBe(true);
1106
1107 expect(menu.prefix()).toEqual("el");
1108 expect(menu._prefix.active()).toEqual(false);
1109 expect(menu.alwaysEntryValue()).toEqual("el");
1110 expect(menu._entry.active()).toEqual(false);
1111 expect(menu.shownItem(0).name()).toEqual("Titel");
Leo Reppdedcf1a2021-08-18 18:57:47 +02001112 expect(directElementChildrenByTagName(menu.element(),"li")[0].innerHTML).toEqual("<strong>Tit<mark>el</mark></strong>");
Leo Repp56904d22021-04-26 15:53:22 +02001113 expect(menu.shownItem(0).active()).toBe(true);
1114 expect(menu.shownItem(1).name()).toEqual("Untertitel");
Leo Reppdedcf1a2021-08-18 18:57:47 +02001115 expect(directElementChildrenByTagName(menu.element(),"li")[1].innerHTML).toEqual("<strong>Untertit<mark>el</mark></strong>");
Leo Repp56904d22021-04-26 15:53:22 +02001116 expect(menu.shownItem(1).active()).toBe(false);
1117 expect(menu.shownItem(2)).toBe(undefined);
1118
1119 // Backward
1120 menu.prev();
1121 expect(menu._prefix.active()).toEqual(false);
1122 expect(menu._entry.active()).toEqual(true);
1123
1124 expect(menu.shownItem(0).name()).toEqual("Titel");
Leo Reppdedcf1a2021-08-18 18:57:47 +02001125 expect(directElementChildrenByTagName(menu.element(),"li")[0].innerHTML).toEqual("<strong>Tit<mark>el</mark></strong>");
Leo Repp56904d22021-04-26 15:53:22 +02001126 expect(menu.shownItem(0).active()).toBe(false);
1127
1128 expect(menu.shownItem(1).name()).toEqual("Untertitel");
Leo Reppdedcf1a2021-08-18 18:57:47 +02001129 expect(directElementChildrenByTagName(menu.element(),"li")[1].innerHTML).toEqual("<strong>Untertit<mark>el</mark></strong>");
Leo Repp56904d22021-04-26 15:53:22 +02001130 expect(menu.shownItem(1).active()).toBe(false);
1131 expect(menu.shownItem(2)).toBe(undefined);
1132
1133
1134 // Backward
1135 menu.prev();
1136 expect(menu._prefix.active()).toEqual(true);
1137 expect(menu._entry.active()).toEqual(false);
1138
1139 expect(menu.shownItem(0).name()).toEqual("Titel");
Leo Reppdedcf1a2021-08-18 18:57:47 +02001140 expect(directElementChildrenByTagName(menu.element(),"li")[0].innerHTML).toEqual("<strong>Tit<mark>el</mark></strong>");
Leo Repp56904d22021-04-26 15:53:22 +02001141 expect(menu.shownItem(0).active()).toBe(false);
1142
1143 expect(menu.shownItem(1).name()).toEqual("Untertitel");
Leo Reppdedcf1a2021-08-18 18:57:47 +02001144 expect(directElementChildrenByTagName(menu.element(),"li")[1].innerHTML).toEqual("<strong>Untertit<mark>el</mark></strong>");
Leo Repp56904d22021-04-26 15:53:22 +02001145 expect(menu.shownItem(1).active()).toBe(false);
1146 expect(menu.shownItem(2)).toBe(undefined);
1147
1148 // Backward
1149 menu.prev();
1150 expect(menu._prefix.active()).toEqual(false);
1151 expect(menu._entry.active()).toEqual(false);
1152 expect(menu.shownItem(0).name()).toEqual("Titel");
Leo Reppdedcf1a2021-08-18 18:57:47 +02001153 expect(directElementChildrenByTagName(menu.element(),"li")[0].innerHTML).toEqual("<strong>Tit<mark>el</mark></strong>");
Leo Repp56904d22021-04-26 15:53:22 +02001154 expect(menu.shownItem(0).active()).toBe(false);
1155 expect(menu.shownItem(1).name()).toEqual("Untertitel");
Leo Reppdedcf1a2021-08-18 18:57:47 +02001156 expect(directElementChildrenByTagName(menu.element(),"li")[1].innerHTML).toEqual("<strong>Untertit<mark>el</mark></strong>");
Leo Repp56904d22021-04-26 15:53:22 +02001157 expect(menu.shownItem(1).active()).toBe(true);
1158 expect(menu.shownItem(2)).toBe(undefined);
1159 });
1160
1161 it('should be navigatable with a prefix (3)', function () {
1162 var menu = HintMenu.create("cnx/", demolist);
1163 menu._firstActive = true;
1164 menu.limit(3);
1165 expect(menu.show()).toBe(true);
1166 expect(menu.prefix()).toEqual("");
1167 menu.prefix('el');
1168 expect(menu.alwaysEntryValue()).toEqual("");
1169 expect(menu.alwaysEntry().value()).toEqual("");
1170 menu.alwaysEntryValue('el');
1171 expect(menu.show()).toBe(true);
1172
1173 expect(menu.prefix()).toEqual("el");
1174 expect(menu._prefix.active()).toEqual(false);
1175 expect(menu.alwaysEntry().value()).toEqual("el");
1176 expect(menu._entry.active()).toEqual(false);
1177 expect(menu.shownItem(0).name()).toEqual("Titel");
Leo Reppdedcf1a2021-08-18 18:57:47 +02001178 expect(directElementChildrenByTagName(menu.element(),"li")[0].innerHTML).toEqual("<strong>Tit<mark>el</mark></strong>");
Leo Repp56904d22021-04-26 15:53:22 +02001179 expect(menu.shownItem(0).active()).toBe(true);
1180 expect(menu.shownItem(1).name()).toEqual("Untertitel");
Leo Reppdedcf1a2021-08-18 18:57:47 +02001181 expect(directElementChildrenByTagName(menu.element(),"li")[1].innerHTML).toEqual("<strong>Untertit<mark>el</mark></strong>");
Leo Repp56904d22021-04-26 15:53:22 +02001182 expect(menu.shownItem(1).active()).toBe(false);
1183 expect(menu.shownItem(2)).toBe(undefined);
1184
1185 // Backward
1186 menu.prev();
1187 expect(menu._prefix.active()).toEqual(false);
1188 expect(menu._entry.active()).toEqual(true);
1189 expect(menu.shownItem(0).name()).toEqual("Titel");
Leo Reppdedcf1a2021-08-18 18:57:47 +02001190 expect(directElementChildrenByTagName(menu.element(),"li")[0].innerHTML).toEqual("<strong>Tit<mark>el</mark></strong>");
Leo Repp56904d22021-04-26 15:53:22 +02001191 expect(menu.shownItem(0).active()).toBe(false);
1192 expect(menu.shownItem(1).name()).toEqual("Untertitel");
Leo Reppdedcf1a2021-08-18 18:57:47 +02001193 expect(directElementChildrenByTagName(menu.element(),"li")[1].innerHTML).toEqual("<strong>Untertit<mark>el</mark></strong>");
Leo Repp56904d22021-04-26 15:53:22 +02001194 expect(menu.shownItem(1).active()).toBe(false);
1195 expect(menu.shownItem(2)).toBe(undefined);
1196
1197 // Backward
1198 menu.prev();
1199 expect(menu._prefix.active()).toEqual(true);
1200 expect(menu._entry.active()).toEqual(false);
1201 expect(menu.shownItem(0).name()).toEqual("Titel");
Leo Reppdedcf1a2021-08-18 18:57:47 +02001202 expect(directElementChildrenByTagName(menu.element(),"li")[0].innerHTML).toEqual("<strong>Tit<mark>el</mark></strong>");
Leo Repp56904d22021-04-26 15:53:22 +02001203 expect(menu.shownItem(0).active()).toBe(false);
1204 expect(menu.shownItem(1).name()).toEqual("Untertitel");
Leo Reppdedcf1a2021-08-18 18:57:47 +02001205 expect(directElementChildrenByTagName(menu.element(),"li")[1].innerHTML).toEqual("<strong>Untertit<mark>el</mark></strong>");
Leo Repp56904d22021-04-26 15:53:22 +02001206 expect(menu.shownItem(1).active()).toBe(false);
1207 expect(menu.shownItem(2)).toBe(undefined);
1208
1209
1210 // Forward
1211 menu.next();
1212 expect(menu.prefix()).toEqual("el");
1213 expect(menu._prefix.active()).toEqual(false);
1214 expect(menu._entry.active()).toEqual(true);
1215 expect(menu.shownItem(0).name()).toEqual("Titel");
Leo Reppdedcf1a2021-08-18 18:57:47 +02001216 expect(directElementChildrenByTagName(menu.element(),"li")[0].innerHTML).toEqual("<strong>Tit<mark>el</mark></strong>");
Leo Repp56904d22021-04-26 15:53:22 +02001217 expect(menu.shownItem(0).active()).toBe(false);
1218 expect(menu.shownItem(1).name()).toEqual("Untertitel");
Leo Reppdedcf1a2021-08-18 18:57:47 +02001219 expect(directElementChildrenByTagName(menu.element(),"li")[1].innerHTML).toEqual("<strong>Untertit<mark>el</mark></strong>");
Leo Repp56904d22021-04-26 15:53:22 +02001220 expect(menu.shownItem(1).active()).toBe(false);
1221 expect(menu.shownItem(2)).toBe(undefined);
1222
1223 // Forward
1224 menu.next();
1225 expect(menu.prefix()).toEqual("el");
1226 expect(menu._prefix.active()).toEqual(false);
1227 expect(menu._entry.active()).toEqual(false);
1228 expect(menu.shownItem(0).name()).toEqual("Titel");
Leo Reppdedcf1a2021-08-18 18:57:47 +02001229 expect(directElementChildrenByTagName(menu.element(),"li")[0].innerHTML).toEqual("<strong>Tit<mark>el</mark></strong>");
Leo Repp56904d22021-04-26 15:53:22 +02001230 expect(menu.shownItem(0).active()).toBe(true);
1231 expect(menu.shownItem(1).name()).toEqual("Untertitel");
Leo Reppdedcf1a2021-08-18 18:57:47 +02001232 expect(directElementChildrenByTagName(menu.element(),"li")[1].innerHTML).toEqual("<strong>Untertit<mark>el</mark></strong>");
Leo Repp56904d22021-04-26 15:53:22 +02001233 expect(menu.shownItem(1).active()).toBe(false);
1234 expect(menu.shownItem(2)).toBe(undefined);
1235 });
1236
1237
1238
1239 xit('should scroll to a chosen value after prefixing, if the chosen value is live');
1240 });
1241
1242 describe('KorAP.AlwaysMenu.Entry', function () {
1243 it('should be initializable', function () {
1244 var p = alwaysEntryClass.create();
1245 expect(p.element().classList.contains('pref')).toBeTruthy();
1246 expect(p.isSet()).not.toBeTruthy();
1247 expect(p.element().innerHTML).toEqual("Speichern");
1248 expect(p.value()).toEqual("");
1249
1250 /*
1251 expect(mi.lcField()).toEqual(' baum');
1252 */
1253
1254 });
1255
1256 it('should be initializable with a different name', function () {
1257 var p = alwaysEntryClass.create("Save");
1258 expect(p.element().classList.contains('pref')).toBeTruthy();
1259 expect(p.isSet()).not.toBeTruthy();
1260 expect(p.element().innerHTML).toEqual("Save");
1261 expect(p.value()).toEqual("");
1262
1263 /*
1264 expect(mi.lcField()).toEqual(' baum');
1265 */
1266
1267 });
1268
1269 it('should be modifiable', function () {
1270 var p = alwaysEntryClass.create();
1271 expect(p.value()).toEqual('');
1272 expect(p.element().firstChild).toEqual(document.createTextNode("Speichern"));
1273
1274 // Set string
1275 expect(p.value('Test')).toEqual('Test');
1276 expect(p.value()).toEqual('Test');
1277 expect(p.element().firstChild.nodeValue).toEqual('Speichern');
1278
1279 // Add string
1280 expect(p.add('ified')).toEqual('Testified');
1281 expect(p.value()).toEqual('Testified');
1282 expect(p.element().firstChild.nodeValue).toEqual('Speichern');
1283
1284 // Clear string
1285 p.clear();
1286 expect(p.value()).toEqual('');
1287 expect(p.element().firstChild).toEqual(document.createTextNode("Speichern"));
1288
1289 // Set string
1290 expect(p.value('Test')).toEqual('Test');
1291 expect(p.value()).toEqual('Test');
1292 expect(p.element().firstChild.nodeValue).toEqual('Speichern');
1293
1294 expect(p.chop()).toEqual('Tes');
1295 expect(p.value()).toEqual('Tes');
1296 expect(p.element().firstChild.nodeValue).toEqual('Speichern');
1297
1298 expect(p.chop()).toEqual('Te');
1299 expect(p.value()).toEqual('Te');
1300 expect(p.element().firstChild.nodeValue).toEqual('Speichern');
1301
1302 expect(p.chop()).toEqual('T');
1303 expect(p.value()).toEqual('T');
1304 expect(p.element().firstChild.nodeValue).toEqual('Speichern');
1305
1306 expect(p.chop()).toEqual('');
1307 expect(p.value()).toEqual('');
1308 expect(p.element().firstChild).toEqual(document.createTextNode("Speichern"));
1309 });
1310
1311 it('should be activatable', function () {
1312 var p = alwaysEntryClass.create();
1313 expect(p.value()).toEqual('');
1314 expect(p.element().firstChild).toEqual(document.createTextNode("Speichern"));
1315
1316 expect(p.value('Test')).toEqual('Test');
1317 expect(p.element().firstChild.nodeValue).toEqual('Speichern');
1318
1319 expect(p.active()).not.toBeTruthy();
1320 expect(p.element().classList.contains('active')).not.toBeTruthy();
1321
1322 p.active(true);
1323 expect(p.active()).toBeTruthy();
1324 expect(p.element().classList.contains('active')).toBeTruthy();
1325 });
1326 });
1327
1328 describe('KorAP.AlwaysMenu.Slider', function () {
1329
1330 var demolonglist = [
1331 ['Titel', 'title'],
1332 ['Untertitel', 'subTitle'],
1333 ['Veröffentlichungsdatum', 'pubDate'],
1334 ['Länge', 'length'],
1335 ['Autor', 'author'],
1336 ['Genre', 'genre'],
1337 ['corpusID', 'corpusID'],
1338 ['docID', 'docID'],
1339 ['textID', 'textID'],
1340 ];
1341
1342 it('should correctly be initializable', function () {
1343 var list = [
1344 ["Constituency"],
1345 ["Lemma"],
1346 ["Morphology"],
1347 ["Part-of-Speech"],
1348 ["Syntax"]
1349 ];
1350
1351 var menu = OwnAlwaysMenu.create(list);
1352
1353 menu._firstActive = true;
1354 menu.limit(3);
1355
1356 expect(menu.show()).toBe(true);
1357
1358 expect(menu.shownItem(0).active()).toBe(true);
1359 expect(menu.shownItem(1).active()).toBe(false);
1360 expect(menu.shownItem(2).active()).toBe(false);
1361 expect(menu.slider().offset()).toEqual(0);
1362 expect(menu.position).toEqual(0);
1363 });
1364
1365 it('should correctly move on arrow keys', function () {
1366 var list = [
1367 ["Constituency"],
1368 ["Lemma"],
1369 ["Morphology"],
1370 ["Part-of-Speech"],
1371 ["Syntax"]
1372 ];
1373
1374 var menu = OwnAlwaysMenu.create(list);
1375
1376 menu._firstActive = true;
1377 menu.limit(3);
1378
1379 expect(menu.show()).toBe(true);
1380
1381 menu.next();
1382 expect(menu.shownItem(0).active()).toBe(false);
1383 expect(menu.shownItem(1).active()).toBe(true);
1384 expect(menu.shownItem(2).active()).toBe(false);
1385 expect(menu._prefix.active()).toBe(false);
1386 expect(menu._entry.active()).toBe(false);
1387 expect(menu.slider().offset()).toEqual(0);
1388 expect(menu.position).toEqual(1);
1389
1390 menu.next();
1391 expect(menu.shownItem(0).active()).toBe(false);
1392 expect(menu.shownItem(1).active()).toBe(false);
1393 expect(menu.shownItem(2).active()).toBe(true);
1394 expect(menu._prefix.active()).toBe(false);
1395 expect(menu._entry.active()).toBe(false);
1396 expect(menu.slider().offset()).toEqual(0);
1397 expect(menu.position).toEqual(2);
1398
1399 menu.next();
1400 expect(menu.shownItem(0).active()).toBe(false);
1401 expect(menu.shownItem(1).active()).toBe(false);
1402 expect(menu.shownItem(2).active()).toBe(true);
1403 expect(menu._prefix.active()).toBe(false);
1404 expect(menu._entry.active()).toBe(false);
1405 expect(menu.slider().offset()).toEqual(1);
1406 expect(menu.position).toEqual(3);
1407
1408 menu.next();
1409 expect(menu.shownItem(0).active()).toBe(false);
1410 expect(menu.shownItem(1).active()).toBe(false);
1411 expect(menu.shownItem(2).active()).toBe(true);
1412 expect(menu._prefix.active()).toBe(false);
1413 expect(menu._entry.active()).toBe(false);
1414 expect(menu.slider().offset()).toEqual(2);
1415 expect(menu.position).toEqual(4);
1416
1417 menu.next();
1418 expect(menu.shownItem(0).active()).toBe(false);
1419 expect(menu.shownItem(1).active()).toBe(false);
1420 expect(menu.shownItem(2).active()).toBe(false);
1421 expect(menu._prefix.active()).toBe(false);
1422 expect(menu._entry.active()).toBe(true);
1423 expect(menu.slider().offset()).toEqual(2);
1424 expect(menu.position).toEqual(7);
1425
1426 menu.next();
1427 expect(menu.shownItem(0).active()).toBe(true);
1428 expect(menu.shownItem(1).active()).toBe(false);
1429 expect(menu.shownItem(2).active()).toBe(false);
1430 expect(menu._prefix.active()).toBe(false);
1431 expect(menu._entry.active()).toBe(false);
1432 expect(menu.slider().offset()).toEqual(0);
1433 expect(menu.position).toEqual(0);
1434
1435 expect(menu.slider()._slider.style.height).toEqual('60%');
1436 });
1437
1438 });
1439
1440 describe('KorAP.AlwaysMenu.Benchmark', function () {
1441 var menu = alwaysMenuClass.create([
1442 ['Titel', 'title'],
1443 ['Untertitel', 'subTitle'],
1444 ['Veröffentlichungsdatum', 'pubDate'],
1445 ['Länge', 'length'],
1446 ['Autor', 'author']
1447 ]);
1448
1449 menu.limit(3).show();
1450
1451 // Some actions
1452 menu.next();
1453 menu.next();
1454 menu.prev();
1455 menu.prev();
1456 menu.prev();
1457
1458 menu.pageDown();
1459 menu.pageUp();
1460
1461 // There is no fourth item in the list!
1462 menu.prefix('e').show(4);
1463 menu.next();
1464 menu.next();
1465 menu.prev();
1466 menu.prev();
1467 menu.prev();
1468 });
1469 });