Menus now have a fixed length based on their content
diff --git a/dev/demo/menudemo.js b/dev/demo/menudemo.js
index 35e2170..2d66de9 100644
--- a/dev/demo/menudemo.js
+++ b/dev/demo/menudemo.js
@@ -60,6 +60,7 @@
var menu = OwnMenu.create([
['Titel', 'title', 'string'],
['Untertitel', 'subTitle', 'string'],
+ ['Beschreibung', 'desc', 'string'],
['Veröffentlichungsdatum', 'pubDate', 'date'],
['Länge', 'length', 'integer'],
['Autor', 'author', 'string'],
diff --git a/dev/js/spec/menuSpec.js b/dev/js/spec/menuSpec.js
index 2b4e8f6..30bf793 100644
--- a/dev/js/spec/menuSpec.js
+++ b/dev/js/spec/menuSpec.js
@@ -1,8 +1,9 @@
define(['menu'], function () {
- var menuItemClass = require('menu/item');
- var prefixClass = require('menu/prefix');
- var menuClass = require('menu');
+ var menuItemClass = require('menu/item');
+ var prefixClass = require('menu/prefix');
+ var menuClass = require('menu');
+ var lengthFieldClass = require('menu/lengthField');
// The OwnMenu item
KorAP.OwnMenuItem = {
@@ -403,16 +404,16 @@
expect(menu.show()).toBe(true);
- expect(menu.element().childNodes[1].innerHTML).toEqual("<strong>Constituency</strong><span>Example 1</span>");
- expect(menu.element().childNodes[2].innerHTML).toEqual("<strong>Lemma</strong>");
- expect(menu.element().childNodes[2].getAttribute("data-action")).toEqual("l=");
- expect(menu.element().childNodes[3].innerHTML).toEqual("<strong>Morphology</strong><span>Example 2</span>");
- expect(menu.element().childNodes[4]).toBe(undefined);
+ expect(menu.element().childNodes[2].innerHTML).toEqual("<strong>Constituency</strong><span>Example 1</span>");
+ expect(menu.element().childNodes[3].innerHTML).toEqual("<strong>Lemma</strong>");
+ expect(menu.element().childNodes[3].getAttribute("data-action")).toEqual("l=");
+ expect(menu.element().childNodes[4].innerHTML).toEqual("<strong>Morphology</strong><span>Example 2</span>");
+ expect(menu.element().childNodes[5]).toBe(undefined);
// Check boundaries
- expect(menu.element().childNodes[1].classList.contains("no-more")).toBe(true);
- expect(menu.element().childNodes[2].classList.contains("no-more")).toBe(false);
+ expect(menu.element().childNodes[2].classList.contains("no-more")).toBe(true);
expect(menu.element().childNodes[3].classList.contains("no-more")).toBe(false);
+ expect(menu.element().childNodes[4].classList.contains("no-more")).toBe(false);
});
it('should be filterable', function () {
@@ -420,44 +421,44 @@
menu.limit(3);
expect(menu.prefix("o").show()).toBe(true);
expect(menu.element().childNodes[0].innerHTML).toEqual("o");
- expect(menu.element().childNodes[1].innerHTML).toEqual("<strong>C<mark>o</mark>nstituency</strong><span>Example 1</span>");
- expect(menu.element().childNodes[2].innerHTML).toEqual("<strong>M<mark>o</mark>rph<mark>o</mark>l<mark>o</mark>gy</strong><span>Example 2</span>");
- expect(menu.element().childNodes[3].innerHTML).toEqual("<strong>Part-<mark>o</mark>f-Speech</strong>");
- expect(menu.element().childNodes[4]).toBe(undefined);
+ expect(menu.element().childNodes[2].innerHTML).toEqual("<strong>C<mark>o</mark>nstituency</strong><span>Example 1</span>");
+ expect(menu.element().childNodes[3].innerHTML).toEqual("<strong>M<mark>o</mark>rph<mark>o</mark>l<mark>o</mark>gy</strong><span>Example 2</span>");
+ expect(menu.element().childNodes[4].innerHTML).toEqual("<strong>Part-<mark>o</mark>f-Speech</strong>");
+ expect(menu.element().childNodes[5]).toBe(undefined);
// Check boundaries
- expect(menu.element().childNodes[1].classList.contains("no-more")).toBe(true);
- expect(menu.element().childNodes[2].classList.contains("no-more")).toBe(false);
- expect(menu.element().childNodes[3].classList.contains("no-more")).toBe(true);
+ expect(menu.element().childNodes[2].classList.contains("no-more")).toBe(true);
+ expect(menu.element().childNodes[3].classList.contains("no-more")).toBe(false);
+ expect(menu.element().childNodes[4].classList.contains("no-more")).toBe(true);
menu.limit(2);
expect(menu.prefix("o").show()).toBe(true);
expect(menu.element().childNodes[0].innerHTML).toEqual("o");
- expect(menu.element().childNodes[1].innerHTML).toEqual("<strong>C<mark>o</mark>nstituency</strong><span>Example 1</span>");
- expect(menu.element().childNodes[2].innerHTML).toEqual("<strong>M<mark>o</mark>rph<mark>o</mark>l<mark>o</mark>gy</strong><span>Example 2</span>");
- expect(menu.element().childNodes[3]).toBe(undefined);
+ expect(menu.element().childNodes[2].innerHTML).toEqual("<strong>C<mark>o</mark>nstituency</strong><span>Example 1</span>");
+ expect(menu.element().childNodes[3].innerHTML).toEqual("<strong>M<mark>o</mark>rph<mark>o</mark>l<mark>o</mark>gy</strong><span>Example 2</span>");
+ expect(menu.element().childNodes[4]).toBe(undefined);
// Check boundaries
- expect(menu.element().childNodes[1].classList.contains("no-more")).toBe(true);
- expect(menu.element().childNodes[2].classList.contains("no-more")).toBe(false);
- expect(menu.element().childNodes[3]).toBe(undefined);
+ expect(menu.element().childNodes[2].classList.contains("no-more")).toBe(true);
+ expect(menu.element().childNodes[3].classList.contains("no-more")).toBe(false);
+ expect(menu.element().childNodes[4]).toBe(undefined);
expect(menu.prefix("e").show()).toBe(true);
expect(menu.element().childNodes[0].innerHTML).toEqual("e");
- expect(menu.element().childNodes[1].innerHTML).toEqual("<strong>Constitu<mark>e</mark>ncy</strong><span><mark>E</mark>xampl<mark>e</mark> 1</span>");
- expect(menu.element().childNodes[2].innerHTML).toEqual("<strong>Morphology</strong><span><mark>E</mark>xampl<mark>e</mark> 2</span>");
- expect(menu.element().childNodes[3]).toBe(undefined);
+ expect(menu.element().childNodes[2].innerHTML).toEqual("<strong>Constitu<mark>e</mark>ncy</strong><span><mark>E</mark>xampl<mark>e</mark> 1</span>");
+ expect(menu.element().childNodes[3].innerHTML).toEqual("<strong>Morphology</strong><span><mark>E</mark>xampl<mark>e</mark> 2</span>");
+ expect(menu.element().childNodes[4]).toBe(undefined);
menu.limit(5);
expect(menu.prefix("a").show()).toBe(true);
expect(menu.element().childNodes[0].innerHTML).toEqual("a");
- expect(menu.element().childNodes[1].innerHTML).toEqual("<strong>Constituency</strong><span>Ex<mark>a</mark>mple 1</span>");
- expect(menu.element().childNodes[2].innerHTML).toEqual("<strong>Lemm<mark>a</mark></strong>");
- expect(menu.element().childNodes[3].innerHTML).toEqual("<strong>Morphology</strong><span>Ex<mark>a</mark>mple 2</span>");
- expect(menu.element().childNodes[4].innerHTML).toEqual("<strong>P<mark>a</mark>rt-of-Speech</strong>");
- expect(menu.element().childNodes[5].innerHTML).toEqual("<strong>Synt<mark>a</mark>x</strong>");
- expect(menu.element().childNodes[6]).toBe(undefined);
+ expect(menu.element().childNodes[2].innerHTML).toEqual("<strong>Constituency</strong><span>Ex<mark>a</mark>mple 1</span>");
+ expect(menu.element().childNodes[3].innerHTML).toEqual("<strong>Lemm<mark>a</mark></strong>");
+ expect(menu.element().childNodes[4].innerHTML).toEqual("<strong>Morphology</strong><span>Ex<mark>a</mark>mple 2</span>");
+ expect(menu.element().childNodes[5].innerHTML).toEqual("<strong>P<mark>a</mark>rt-of-Speech</strong>");
+ expect(menu.element().childNodes[6].innerHTML).toEqual("<strong>Synt<mark>a</mark>x</strong>");
+ expect(menu.element().childNodes[7]).toBe(undefined);
});
@@ -468,74 +469,74 @@
// Show only 3 items
menu.limit(3);
expect(menu.show()).toBe(true);
- expect(menu.element().childNodes[1].innerHTML).toEqual("<strong>Constituency</strong><span>Example 1</span>");
+ expect(menu.element().childNodes[2].innerHTML).toEqual("<strong>Constituency</strong><span>Example 1</span>");
expect(menu.shownItem(0).active()).toBe(true);
- expect(menu.element().childNodes[2].innerHTML).toEqual("<strong>Lemma</strong>");
+ expect(menu.element().childNodes[3].innerHTML).toEqual("<strong>Lemma</strong>");
expect(menu.shownItem(1).active()).toBe(false);
- expect(menu.element().childNodes[3].innerHTML).toEqual("<strong>Morphology</strong><span>Example 2</span>");
+ expect(menu.element().childNodes[4].innerHTML).toEqual("<strong>Morphology</strong><span>Example 2</span>");
expect(menu.shownItem(2).active()).toBe(false);
- expect(menu.element().childNodes[4]).toBe(undefined);
+ expect(menu.element().childNodes[5]).toBe(undefined);
// Activate next (1)
menu.next();
- expect(menu.element().childNodes[1].innerHTML).toEqual("<strong>Constituency</strong><span>Example 1</span>");
+ expect(menu.element().childNodes[2].innerHTML).toEqual("<strong>Constituency</strong><span>Example 1</span>");
expect(menu.shownItem(0).active()).toBe(false);
- expect(menu.element().childNodes[2].innerHTML).toEqual("<strong>Lemma</strong>");
+ expect(menu.element().childNodes[3].innerHTML).toEqual("<strong>Lemma</strong>");
expect(menu.shownItem(1).active()).toBe(true);
- expect(menu.element().childNodes[3].innerHTML).toEqual("<strong>Morphology</strong><span>Example 2</span>");
+ expect(menu.element().childNodes[4].innerHTML).toEqual("<strong>Morphology</strong><span>Example 2</span>");
expect(menu.shownItem(2).active()).toBe(false);
- expect(menu.element().childNodes[4]).toBe(undefined);
+ expect(menu.element().childNodes[5]).toBe(undefined);
// Activate next (2)
menu.next();
- expect(menu.element().childNodes[1].innerHTML).toEqual("<strong>Constituency</strong><span>Example 1</span>");
+ expect(menu.element().childNodes[2].innerHTML).toEqual("<strong>Constituency</strong><span>Example 1</span>");
expect(menu.shownItem(0).active()).toBe(false);
- expect(menu.element().childNodes[2].innerHTML).toEqual("<strong>Lemma</strong>");
+ expect(menu.element().childNodes[3].innerHTML).toEqual("<strong>Lemma</strong>");
expect(menu.shownItem(1).active()).toBe(false);
- expect(menu.element().childNodes[3].innerHTML).toEqual("<strong>Morphology</strong><span>Example 2</span>");
+ expect(menu.element().childNodes[4].innerHTML).toEqual("<strong>Morphology</strong><span>Example 2</span>");
expect(menu.shownItem(2).active()).toBe(true);
- expect(menu.element().childNodes[4]).toBe(undefined);
+ expect(menu.element().childNodes[5]).toBe(undefined);
// Activate next (3)
// scroll!
menu.next();
- expect(menu.element().childNodes[1].innerHTML).toEqual("<strong>Lemma</strong>");
+ expect(menu.element().childNodes[2].innerHTML).toEqual("<strong>Lemma</strong>");
expect(menu.shownItem(0).active()).toBe(false);
- expect(menu.element().childNodes[2].innerHTML).toEqual("<strong>Morphology</strong><span>Example 2</span>");
+ expect(menu.element().childNodes[3].innerHTML).toEqual("<strong>Morphology</strong><span>Example 2</span>");
expect(menu.shownItem(1).active()).toBe(false);
- expect(menu.element().childNodes[3].innerHTML).toEqual("<strong>Part-of-Speech</strong>");
+ expect(menu.element().childNodes[4].innerHTML).toEqual("<strong>Part-of-Speech</strong>");
expect(menu.shownItem(2).active()).toBe(true);
- expect(menu.element().childNodes[4]).toBe(undefined);
+ expect(menu.element().childNodes[5]).toBe(undefined);
// Activate next (4)
menu.next();
- expect(menu.element().childNodes[1].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(0).active()).toBe(false);
- expect(menu.element().childNodes[2].innerHTML).toEqual("<strong>Part-of-Speech</strong>");
+ expect(menu.element().childNodes[3].innerHTML).toEqual("<strong>Part-of-Speech</strong>");
expect(menu.shownItem(1).active()).toBe(false);
- expect(menu.element().childNodes[3].innerHTML).toEqual("<strong>Syntax</strong>");
+ expect(menu.element().childNodes[4].innerHTML).toEqual("<strong>Syntax</strong>");
expect(menu.shownItem(2).active()).toBe(true);
- expect(menu.element().childNodes[4]).toBe(undefined);
+ expect(menu.element().childNodes[5]).toBe(undefined);
// Activate next (5) - ROLL
menu.next();
- expect(menu.element().childNodes[1].innerHTML).toEqual("<strong>Constituency</strong><span>Example 1</span>");
+ expect(menu.element().childNodes[2].innerHTML).toEqual("<strong>Constituency</strong><span>Example 1</span>");
expect(menu.shownItem(0).active()).toBe(true);
- expect(menu.element().childNodes[2].innerHTML).toEqual("<strong>Lemma</strong>");
+ expect(menu.element().childNodes[3].innerHTML).toEqual("<strong>Lemma</strong>");
expect(menu.shownItem(1).active()).toBe(false);
- expect(menu.element().childNodes[3].innerHTML).toEqual("<strong>Morphology</strong><span>Example 2</span>");
+ expect(menu.element().childNodes[4].innerHTML).toEqual("<strong>Morphology</strong><span>Example 2</span>");
expect(menu.shownItem(2).active()).toBe(false);
- expect(menu.element().childNodes[4]).toBe(undefined);
+ expect(menu.element().childNodes[5]).toBe(undefined);
// Active next (6)
menu.next();
- expect(menu.element().childNodes[1].innerHTML).toEqual("<strong>Constituency</strong><span>Example 1</span>");
+ expect(menu.element().childNodes[2].innerHTML).toEqual("<strong>Constituency</strong><span>Example 1</span>");
expect(menu.shownItem(0).active()).toBe(false);
- expect(menu.element().childNodes[2].innerHTML).toEqual("<strong>Lemma</strong>");
+ expect(menu.element().childNodes[3].innerHTML).toEqual("<strong>Lemma</strong>");
expect(menu.shownItem(1).active()).toBe(true);
- expect(menu.element().childNodes[3].innerHTML).toEqual("<strong>Morphology</strong><span>Example 2</span>");
+ expect(menu.element().childNodes[4].innerHTML).toEqual("<strong>Morphology</strong><span>Example 2</span>");
expect(menu.shownItem(2).active()).toBe(false);
- expect(menu.element().childNodes[4]).toBe(undefined);
+ expect(menu.element().childNodes[5]).toBe(undefined);
});
it('should be prevable', function () {
@@ -544,33 +545,33 @@
menu.limit(3);
expect(menu.show()).toBe(true);
- expect(menu.element().childNodes[1].innerHTML).toEqual("<strong>Constituency</strong><span>Example 1</span>");
+ expect(menu.element().childNodes[2].innerHTML).toEqual("<strong>Constituency</strong><span>Example 1</span>");
expect(menu.shownItem(0).active()).toBe(true);
- expect(menu.element().childNodes[2].innerHTML).toEqual("<strong>Lemma</strong>");
+ expect(menu.element().childNodes[3].innerHTML).toEqual("<strong>Lemma</strong>");
expect(menu.shownItem(1).active()).toBe(false);
- expect(menu.element().childNodes[3].innerHTML).toEqual("<strong>Morphology</strong><span>Example 2</span>");
+ expect(menu.element().childNodes[4].innerHTML).toEqual("<strong>Morphology</strong><span>Example 2</span>");
expect(menu.shownItem(2).active()).toBe(false);
- expect(menu.element().childNodes[4]).toBe(undefined);
+ expect(menu.element().childNodes[5]).toBe(undefined);
// Activate prev (1) - roll to bottom
menu.prev();
- expect(menu.element().childNodes[1].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(0).active()).toBe(false);
- expect(menu.element().childNodes[2].innerHTML).toEqual("<strong>Part-of-Speech</strong>");
+ expect(menu.element().childNodes[3].innerHTML).toEqual("<strong>Part-of-Speech</strong>");
expect(menu.shownItem(1).active()).toBe(false);
- expect(menu.element().childNodes[3].innerHTML).toEqual("<strong>Syntax</strong>");
+ expect(menu.element().childNodes[4].innerHTML).toEqual("<strong>Syntax</strong>");
expect(menu.shownItem(2).active()).toBe(true);
- expect(menu.element().childNodes[4]).toBe(undefined);
+ expect(menu.element().childNodes[5]).toBe(undefined);
// Activate prev (2)
menu.prev();
- expect(menu.element().childNodes[1].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(0).active()).toBe(false);
- expect(menu.element().childNodes[2].innerHTML).toEqual("<strong>Part-of-Speech</strong>");
+ expect(menu.element().childNodes[3].innerHTML).toEqual("<strong>Part-of-Speech</strong>");
expect(menu.shownItem(1).active()).toBe(true);
- expect(menu.element().childNodes[3].innerHTML).toEqual("<strong>Syntax</strong>");
+ expect(menu.element().childNodes[4].innerHTML).toEqual("<strong>Syntax</strong>");
expect(menu.shownItem(2).active()).toBe(false);
- expect(menu.element().childNodes[4]).toBe(undefined);
+ expect(menu.element().childNodes[5]).toBe(undefined);
// Activate prev (3)
menu.prev();
@@ -580,7 +581,7 @@
expect(menu.shownItem(1).active()).toBe(false);
expect(menu.shownItem(2).name()).toEqual("Syntax");
expect(menu.shownItem(2).active()).toBe(false);
- expect(menu.element().childNodes[4]).toBe(undefined);
+ expect(menu.element().childNodes[5]).toBe(undefined);
// Activate prev (4)
menu.prev();
@@ -590,7 +591,7 @@
expect(menu.shownItem(1).active()).toBe(false);
expect(menu.shownItem(2).name()).toEqual("Part-of-Speech");
expect(menu.shownItem(2).active()).toBe(false);
- expect(menu.element().childNodes[4]).toBe(undefined);
+ expect(menu.element().childNodes[5]).toBe(undefined);
// Activate prev (5)
menu.prev();
@@ -600,7 +601,7 @@
expect(menu.shownItem(1).active()).toBe(false);
expect(menu.shownItem(2).name()).toEqual("Morphology");
expect(menu.shownItem(2).active()).toBe(false);
- expect(menu.element().childNodes[4]).toBe(undefined);
+ expect(menu.element().childNodes[5]).toBe(undefined);
// Activate next (1)
menu.next();
@@ -610,7 +611,7 @@
expect(menu.shownItem(1).active()).toBe(true);
expect(menu.shownItem(2).name()).toEqual("Morphology");
expect(menu.shownItem(2).active()).toBe(false);
- expect(menu.element().childNodes[4]).toBe(undefined);
+ expect(menu.element().childNodes[5]).toBe(undefined);
// Activate prev (6)
menu.prev();
@@ -623,7 +624,7 @@
expect(menu.shownItem(1).active()).toBe(false);
expect(menu.shownItem(2).name()).toEqual("Syntax");
expect(menu.shownItem(2).active()).toBe(true);
- expect(menu.element().childNodes[4]).toBe(undefined);
+ expect(menu.element().childNodes[5]).toBe(undefined);
});
@@ -634,49 +635,49 @@
expect(menu.prefix("o").show()).toBe(true);
expect(menu.shownItem(0).name()).toEqual("Constituency");
- expect(menu.element().childNodes[1].innerHTML).toEqual("<strong>C<mark>o</mark>nstituency</strong><span>Example 1</span>");
+ expect(menu.element().childNodes[2].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[2].innerHTML).toEqual("<strong>M<mark>o</mark>rph<mark>o</mark>l<mark>o</mark>gy</strong><span>Example 2</span>");
+ expect(menu.element().childNodes[3].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[1].innerHTML).toEqual("<strong>C<mark>o</mark>nstituency</strong><span>Example 1</span>");
+ expect(menu.element().childNodes[2].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[2].innerHTML).toEqual("<strong>M<mark>o</mark>rph<mark>o</mark>l<mark>o</mark>gy</strong><span>Example 2</span>");
+ expect(menu.element().childNodes[3].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[1].innerHTML).toEqual("<strong>M<mark>o</mark>rph<mark>o</mark>l<mark>o</mark>gy</strong><span>Example 2</span>");
+ expect(menu.element().childNodes[2].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[2].innerHTML).toEqual("<strong>Part-<mark>o</mark>f-Speech</strong>");
+ expect(menu.element().childNodes[3].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) - to prefix
menu.next();
expect(menu.shownItem(0).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.element().childNodes[2].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[2].innerHTML).toEqual("<strong>Part-<mark>o</mark>f-Speech</strong>");
+ expect(menu.element().childNodes[3].innerHTML).toEqual("<strong>Part-<mark>o</mark>f-Speech</strong>");
expect(menu.shownItem(1).active()).toBe(false);
expect(menu.shownItem(2)).toBe(undefined);
menu.next();
expect(menu.shownItem(0).name()).toEqual("Constituency");
- expect(menu.element().childNodes[1].innerHTML).toEqual("<strong>C<mark>o</mark>nstituency</strong><span>Example 1</span>");
+ expect(menu.element().childNodes[2].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[2].innerHTML).toEqual("<strong>M<mark>o</mark>rph<mark>o</mark>l<mark>o</mark>gy</strong><span>Example 2</span>");
+ expect(menu.element().childNodes[3].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);
});
@@ -690,20 +691,20 @@
expect(menu.prefix("ex").show()).toBe(true);
expect(menu.shownItem(0).name()).toEqual("Constituency");
- expect(menu.element().childNodes[1].innerHTML).toEqual("<strong>Constituency</strong><span><mark>Ex</mark>ample 1</span>");
+ expect(menu.element().childNodes[2].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[2].innerHTML).toEqual("<strong>Morphology</strong><span><mark>Ex</mark>ample 2</span>");
+ expect(menu.element().childNodes[3].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[1].innerHTML).toEqual("<strong>Constituency</strong><span><mark>Ex</mark>ample 1</span>");
+ expect(menu.element().childNodes[2].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[2].innerHTML).toEqual("<strong>Morphology</strong><span><mark>Ex</mark>ample 2</span>");
+ expect(menu.element().childNodes[3].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);
@@ -712,11 +713,11 @@
expect(menu.prefix()).toEqual('ex');
expect(menu.shownItem(0).name()).toEqual("Constituency");
- expect(menu.element().childNodes[1].innerHTML).toEqual("<strong>Constituency</strong><span><mark>Ex</mark>ample 1</span>");
+ expect(menu.element().childNodes[2].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[2].innerHTML).toEqual("<strong>Morphology</strong><span><mark>Ex</mark>ample 2</span>");
+ expect(menu.element().childNodes[3].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);
@@ -727,10 +728,10 @@
expect(menu.prefix("e").show()).toBe(true);
expect(menu._prefix.active()).toBe(false);
expect(menu.shownItem(0).name()).toEqual("Constituency");
- expect(menu.element().childNodes[1].innerHTML).toEqual("<strong>Constitu<mark>e</mark>ncy</strong><span><mark>E</mark>xampl<mark>e</mark> 1</span>");
+ expect(menu.element().childNodes[2].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[2].innerHTML).toEqual("<strong>Morphology</strong><span><mark>E</mark>xampl<mark>e</mark> 2</span>");
+ expect(menu.element().childNodes[3].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);
@@ -739,10 +740,10 @@
expect(menu._prefix.active()).toBe(false);
expect(menu.prefix()).toEqual('e');
expect(menu.shownItem(0).name()).toEqual("Constituency");
- expect(menu.element().childNodes[1].innerHTML).toEqual("<strong>Constitu<mark>e</mark>ncy</strong><span><mark>E</mark>xampl<mark>e</mark> 1</span>");
+ expect(menu.element().childNodes[2].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[2].innerHTML).toEqual("<strong>Morphology</strong><span><mark>E</mark>xampl<mark>e</mark> 2</span>");
+ expect(menu.element().childNodes[3].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);
@@ -750,10 +751,10 @@
menu.next();
expect(menu._prefix.active()).toBe(true);
expect(menu.shownItem(0).name()).toEqual("Constituency");
- expect(menu.element().childNodes[1].innerHTML).toEqual("<strong>Constitu<mark>e</mark>ncy</strong><span><mark>E</mark>xampl<mark>e</mark> 1</span>");
+ expect(menu.element().childNodes[2].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[2].innerHTML).toEqual("<strong>Morphology</strong><span><mark>E</mark>xampl<mark>e</mark> 2</span>");
+ expect(menu.element().childNodes[3].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);
@@ -761,10 +762,10 @@
menu.next();
expect(menu._prefix.active()).toBe(false);
expect(menu.shownItem(0).name()).toEqual("Constituency");
- expect(menu.element().childNodes[1].innerHTML).toEqual("<strong>Constitu<mark>e</mark>ncy</strong><span><mark>E</mark>xampl<mark>e</mark> 1</span>");
+ expect(menu.element().childNodes[2].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[2].innerHTML).toEqual("<strong>Morphology</strong><span><mark>E</mark>xampl<mark>e</mark> 2</span>");
+ expect(menu.element().childNodes[3].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);
});
@@ -787,13 +788,13 @@
expect(menu.prefix()).toEqual("");
expect(menu.shownItem(0).name()).toEqual("Titel");
- expect(menu.element().childNodes[1].innerHTML).toEqual("<strong>Titel</strong>");
+ expect(menu.element().childNodes[2].innerHTML).toEqual("<strong>Titel</strong>");
expect(menu.shownItem(0).active()).toBe(true);
expect(menu.shownItem(1).name()).toEqual("Untertitel");
- expect(menu.element().childNodes[2].innerHTML).toEqual("<strong>Untertitel</strong>");
+ expect(menu.element().childNodes[3].innerHTML).toEqual("<strong>Untertitel</strong>");
expect(menu.shownItem(1).active()).toBe(false);
expect(menu.shownItem(2).name()).toEqual("Veröffentlichungsdatum");
- expect(menu.element().childNodes[3].innerHTML).toEqual("<strong>Veröffentlichungsdatum</strong>");
+ expect(menu.element().childNodes[4].innerHTML).toEqual("<strong>Veröffentlichungsdatum</strong>");
expect(menu.shownItem(2).active()).toBe(false);
expect(menu.shownItem(3)).toBe(undefined);
@@ -801,31 +802,31 @@
expect(menu.show()).toBe(true);
expect(menu.prefix()).toEqual("a");
expect(menu.shownItem(0).name()).toEqual("Autor");
- expect(menu.element().childNodes[1].innerHTML).toEqual("<strong><mark>A</mark>utor</strong>");
+ expect(menu.element().childNodes[2].innerHTML).toEqual("<strong><mark>A</mark>utor</strong>");
menu._prefix.add('u');
expect(menu.show()).toBe(true);
expect(menu.prefix()).toEqual("au");
expect(menu.shownItem(0).name()).toEqual("Autor");
- expect(menu.element().childNodes[1].innerHTML).toEqual("<strong><mark>Au</mark>tor</strong>");
+ expect(menu.element().childNodes[2].innerHTML).toEqual("<strong><mark>Au</mark>tor</strong>");
menu._prefix.chop();
expect(menu.show()).toBe(true);
expect(menu.prefix()).toEqual("a");
expect(menu.shownItem(0).name()).toEqual("Autor");
- expect(menu.element().childNodes[1].innerHTML).toEqual("<strong><mark>A</mark>utor</strong>");
+ expect(menu.element().childNodes[2].innerHTML).toEqual("<strong><mark>A</mark>utor</strong>");
menu._prefix.chop();
expect(menu.show()).toBe(true);
expect(menu.prefix()).toEqual("");
expect(menu.shownItem(0).name()).toEqual("Titel");
- expect(menu.element().childNodes[1].innerHTML).toEqual("<strong>Titel</strong>");
+ expect(menu.element().childNodes[2].innerHTML).toEqual("<strong>Titel</strong>");
expect(menu.shownItem(0).active()).toBe(true);
expect(menu.shownItem(1).name()).toEqual("Untertitel");
- expect(menu.element().childNodes[2].innerHTML).toEqual("<strong>Untertitel</strong>");
+ expect(menu.element().childNodes[3].innerHTML).toEqual("<strong>Untertitel</strong>");
expect(menu.shownItem(1).active()).toBe(false);
expect(menu.shownItem(2).name()).toEqual("Veröffentlichungsdatum");
- expect(menu.element().childNodes[3].innerHTML).toEqual("<strong>Veröffentlichungsdatum</strong>");
+ expect(menu.element().childNodes[4].innerHTML).toEqual("<strong>Veröffentlichungsdatum</strong>");
expect(menu.shownItem(2).active()).toBe(false);
expect(menu.shownItem(3)).toBe(undefined);
@@ -834,26 +835,26 @@
expect(menu.show()).toBe(true);
expect(menu.prefix()).toEqual("");
expect(menu.shownItem(0).name()).toEqual("Titel");
- expect(menu.element().childNodes[1].innerHTML).toEqual("<strong>Titel</strong>");
+ expect(menu.element().childNodes[2].innerHTML).toEqual("<strong>Titel</strong>");
expect(menu.shownItem(0).active()).toBe(true);
expect(menu.shownItem(1).name()).toEqual("Untertitel");
- expect(menu.element().childNodes[2].innerHTML).toEqual("<strong>Untertitel</strong>");
+ expect(menu.element().childNodes[3].innerHTML).toEqual("<strong>Untertitel</strong>");
expect(menu.shownItem(1).active()).toBe(false);
expect(menu.shownItem(2).name()).toEqual("Veröffentlichungsdatum");
- expect(menu.element().childNodes[3].innerHTML).toEqual("<strong>Veröffentlichungsdatum</strong>");
+ expect(menu.element().childNodes[4].innerHTML).toEqual("<strong>Veröffentlichungsdatum</strong>");
expect(menu.shownItem(2).active()).toBe(false);
// Forward
menu.next();
expect(menu.prefix()).toEqual("");
expect(menu.shownItem(0).name()).toEqual("Titel");
- expect(menu.element().childNodes[1].innerHTML).toEqual("<strong>Titel</strong>");
+ expect(menu.element().childNodes[2].innerHTML).toEqual("<strong>Titel</strong>");
expect(menu.shownItem(0).active()).toBe(false);
expect(menu.shownItem(1).name()).toEqual("Untertitel");
- expect(menu.element().childNodes[2].innerHTML).toEqual("<strong>Untertitel</strong>");
+ expect(menu.element().childNodes[3].innerHTML).toEqual("<strong>Untertitel</strong>");
expect(menu.shownItem(1).active()).toBe(true);
expect(menu.shownItem(2).name()).toEqual("Veröffentlichungsdatum");
- expect(menu.element().childNodes[3].innerHTML).toEqual("<strong>Veröffentlichungsdatum</strong>");
+ expect(menu.element().childNodes[4].innerHTML).toEqual("<strong>Veröffentlichungsdatum</strong>");
expect(menu.shownItem(2).active()).toBe(false);
expect(menu.shownItem(3)).toBe(undefined);
@@ -861,13 +862,13 @@
menu.next();
expect(menu.prefix()).toEqual("");
expect(menu.shownItem(0).name()).toEqual("Titel");
- expect(menu.element().childNodes[1].innerHTML).toEqual("<strong>Titel</strong>");
+ expect(menu.element().childNodes[2].innerHTML).toEqual("<strong>Titel</strong>");
expect(menu.shownItem(0).active()).toBe(false);
expect(menu.shownItem(1).name()).toEqual("Untertitel");
- expect(menu.element().childNodes[2].innerHTML).toEqual("<strong>Untertitel</strong>");
+ expect(menu.element().childNodes[3].innerHTML).toEqual("<strong>Untertitel</strong>");
expect(menu.shownItem(1).active()).toBe(false);
expect(menu.shownItem(2).name()).toEqual("Veröffentlichungsdatum");
- expect(menu.element().childNodes[3].innerHTML).toEqual("<strong>Veröffentlichungsdatum</strong>");
+ expect(menu.element().childNodes[4].innerHTML).toEqual("<strong>Veröffentlichungsdatum</strong>");
expect(menu.shownItem(2).active()).toBe(true);
expect(menu.shownItem(3)).toBe(undefined);
@@ -875,13 +876,13 @@
menu.next();
expect(menu.prefix()).toEqual("");
expect(menu.shownItem(0).name()).toEqual("Untertitel");
- expect(menu.element().childNodes[1].innerHTML).toEqual("<strong>Untertitel</strong>");
+ expect(menu.element().childNodes[2].innerHTML).toEqual("<strong>Untertitel</strong>");
expect(menu.shownItem(0).active()).toBe(false);
expect(menu.shownItem(1).name()).toEqual("Veröffentlichungsdatum");
- expect(menu.element().childNodes[2].innerHTML).toEqual("<strong>Veröffentlichungsdatum</strong>");
+ expect(menu.element().childNodes[3].innerHTML).toEqual("<strong>Veröffentlichungsdatum</strong>");
expect(menu.shownItem(1).active()).toBe(false);
expect(menu.shownItem(2).name()).toEqual("Länge");
- expect(menu.element().childNodes[3].innerHTML).toEqual("<strong>Länge</strong>");
+ expect(menu.element().childNodes[4].innerHTML).toEqual("<strong>Länge</strong>");
expect(menu.shownItem(2).active()).toBe(true);
expect(menu.shownItem(3)).toBe(undefined);
@@ -889,13 +890,13 @@
menu.next();
expect(menu.prefix()).toEqual("");
expect(menu.shownItem(0).name()).toEqual("Veröffentlichungsdatum");
- expect(menu.element().childNodes[1].innerHTML).toEqual("<strong>Veröffentlichungsdatum</strong>");
+ expect(menu.element().childNodes[2].innerHTML).toEqual("<strong>Veröffentlichungsdatum</strong>");
expect(menu.shownItem(0).active()).toBe(false);
expect(menu.shownItem(1).name()).toEqual("Länge");
- expect(menu.element().childNodes[2].innerHTML).toEqual("<strong>Länge</strong>");
+ expect(menu.element().childNodes[3].innerHTML).toEqual("<strong>Länge</strong>");
expect(menu.shownItem(1).active()).toBe(false);
expect(menu.shownItem(2).name()).toEqual("Autor");
- expect(menu.element().childNodes[3].innerHTML).toEqual("<strong>Autor</strong>");
+ expect(menu.element().childNodes[4].innerHTML).toEqual("<strong>Autor</strong>");
expect(menu.shownItem(2).active()).toBe(true);
expect(menu.shownItem(3)).toBe(undefined);
@@ -903,13 +904,13 @@
menu.next();
expect(menu.prefix()).toEqual("");
expect(menu.shownItem(0).name()).toEqual("Titel");
- expect(menu.element().childNodes[1].innerHTML).toEqual("<strong>Titel</strong>");
+ expect(menu.element().childNodes[2].innerHTML).toEqual("<strong>Titel</strong>");
expect(menu.shownItem(0).active()).toBe(true);
expect(menu.shownItem(1).name()).toEqual("Untertitel");
- expect(menu.element().childNodes[2].innerHTML).toEqual("<strong>Untertitel</strong>");
+ expect(menu.element().childNodes[3].innerHTML).toEqual("<strong>Untertitel</strong>");
expect(menu.shownItem(1).active()).toBe(false);
expect(menu.shownItem(2).name()).toEqual("Veröffentlichungsdatum");
- expect(menu.element().childNodes[3].innerHTML).toEqual("<strong>Veröffentlichungsdatum</strong>");
+ expect(menu.element().childNodes[4].innerHTML).toEqual("<strong>Veröffentlichungsdatum</strong>");
expect(menu.shownItem(2).active()).toBe(false);
});
@@ -929,10 +930,10 @@
expect(menu.prefix()).toEqual("el");
expect(menu._prefix.active()).toEqual(false);
expect(menu.shownItem(0).name()).toEqual("Titel");
- expect(menu.element().childNodes[1].innerHTML).toEqual("<strong>Tit<mark>el</mark></strong>");
+ expect(menu.element().childNodes[2].innerHTML).toEqual("<strong>Tit<mark>el</mark></strong>");
expect(menu.shownItem(0).active()).toBe(true);
expect(menu.shownItem(1).name()).toEqual("Untertitel");
- expect(menu.element().childNodes[2].innerHTML).toEqual("<strong>Untertit<mark>el</mark></strong>");
+ expect(menu.element().childNodes[3].innerHTML).toEqual("<strong>Untertit<mark>el</mark></strong>");
expect(menu.shownItem(1).active()).toBe(false);
expect(menu.shownItem(2)).toBe(undefined);
@@ -941,10 +942,10 @@
expect(menu.prefix()).toEqual("el");
expect(menu._prefix.active()).toEqual(false);
expect(menu.shownItem(0).name()).toEqual("Titel");
- expect(menu.element().childNodes[1].innerHTML).toEqual("<strong>Tit<mark>el</mark></strong>");
+ expect(menu.element().childNodes[2].innerHTML).toEqual("<strong>Tit<mark>el</mark></strong>");
expect(menu.shownItem(0).active()).toBe(false);
expect(menu.shownItem(1).name()).toEqual("Untertitel");
- expect(menu.element().childNodes[2].innerHTML).toEqual("<strong>Untertit<mark>el</mark></strong>");
+ expect(menu.element().childNodes[3].innerHTML).toEqual("<strong>Untertit<mark>el</mark></strong>");
expect(menu.shownItem(1).active()).toBe(true);
expect(menu.shownItem(2)).toBe(undefined);
@@ -953,10 +954,10 @@
expect(menu.prefix()).toEqual("el");
expect(menu._prefix.active()).toEqual(true);
expect(menu.shownItem(0).name()).toEqual("Titel");
- expect(menu.element().childNodes[1].innerHTML).toEqual("<strong>Tit<mark>el</mark></strong>");
+ expect(menu.element().childNodes[2].innerHTML).toEqual("<strong>Tit<mark>el</mark></strong>");
expect(menu.shownItem(0).active()).toBe(false);
expect(menu.shownItem(1).name()).toEqual("Untertitel");
- expect(menu.element().childNodes[2].innerHTML).toEqual("<strong>Untertit<mark>el</mark></strong>");
+ expect(menu.element().childNodes[3].innerHTML).toEqual("<strong>Untertit<mark>el</mark></strong>");
expect(menu.shownItem(1).active()).toBe(false);
expect(menu.shownItem(2)).toBe(undefined);
@@ -965,11 +966,11 @@
expect(menu.prefix()).toEqual("el");
expect(menu._prefix.active()).toEqual(false);
expect(menu.shownItem(0).name()).toEqual("Titel");
- expect(menu.element().childNodes[1].innerHTML).toEqual("<strong>Tit<mark>el</mark></strong>");
+ expect(menu.element().childNodes[2].innerHTML).toEqual("<strong>Tit<mark>el</mark></strong>");
expect(menu.shownItem(0).active()).toBe(false);
expect(menu.shownItem(1).name()).toEqual("Untertitel");
- expect(menu.element().childNodes[2].innerHTML).toEqual("<strong>Untertit<mark>el</mark></strong>");
+ expect(menu.element().childNodes[3].innerHTML).toEqual("<strong>Untertit<mark>el</mark></strong>");
expect(menu.shownItem(1).active()).toBe(true);
expect(menu.shownItem(2)).toBe(undefined);
});
@@ -988,10 +989,10 @@
expect(menu.prefix()).toEqual("el");
expect(menu._prefix.active()).toEqual(false);
expect(menu.shownItem(0).name()).toEqual("Titel");
- expect(menu.element().childNodes[1].innerHTML).toEqual("<strong>Tit<mark>el</mark></strong>");
+ expect(menu.element().childNodes[2].innerHTML).toEqual("<strong>Tit<mark>el</mark></strong>");
expect(menu.shownItem(0).active()).toBe(true);
expect(menu.shownItem(1).name()).toEqual("Untertitel");
- expect(menu.element().childNodes[2].innerHTML).toEqual("<strong>Untertit<mark>el</mark></strong>");
+ expect(menu.element().childNodes[3].innerHTML).toEqual("<strong>Untertit<mark>el</mark></strong>");
expect(menu.shownItem(1).active()).toBe(false);
expect(menu.shownItem(2)).toBe(undefined);
@@ -1000,11 +1001,11 @@
expect(menu._prefix.active()).toEqual(true);
expect(menu.shownItem(0).name()).toEqual("Titel");
- expect(menu.element().childNodes[1].innerHTML).toEqual("<strong>Tit<mark>el</mark></strong>");
+ expect(menu.element().childNodes[2].innerHTML).toEqual("<strong>Tit<mark>el</mark></strong>");
expect(menu.shownItem(0).active()).toBe(false);
expect(menu.shownItem(1).name()).toEqual("Untertitel");
- expect(menu.element().childNodes[2].innerHTML).toEqual("<strong>Untertit<mark>el</mark></strong>");
+ expect(menu.element().childNodes[3].innerHTML).toEqual("<strong>Untertit<mark>el</mark></strong>");
expect(menu.shownItem(1).active()).toBe(false);
expect(menu.shownItem(2)).toBe(undefined);
@@ -1012,10 +1013,10 @@
menu.prev();
expect(menu._prefix.active()).toEqual(false);
expect(menu.shownItem(0).name()).toEqual("Titel");
- expect(menu.element().childNodes[1].innerHTML).toEqual("<strong>Tit<mark>el</mark></strong>");
+ expect(menu.element().childNodes[2].innerHTML).toEqual("<strong>Tit<mark>el</mark></strong>");
expect(menu.shownItem(0).active()).toBe(false);
expect(menu.shownItem(1).name()).toEqual("Untertitel");
- expect(menu.element().childNodes[2].innerHTML).toEqual("<strong>Untertit<mark>el</mark></strong>");
+ expect(menu.element().childNodes[3].innerHTML).toEqual("<strong>Untertit<mark>el</mark></strong>");
expect(menu.shownItem(1).active()).toBe(true);
expect(menu.shownItem(2)).toBe(undefined);
});
@@ -1032,10 +1033,10 @@
expect(menu.prefix()).toEqual("el");
expect(menu._prefix.active()).toEqual(false);
expect(menu.shownItem(0).name()).toEqual("Titel");
- expect(menu.element().childNodes[1].innerHTML).toEqual("<strong>Tit<mark>el</mark></strong>");
+ expect(menu.element().childNodes[2].innerHTML).toEqual("<strong>Tit<mark>el</mark></strong>");
expect(menu.shownItem(0).active()).toBe(true);
expect(menu.shownItem(1).name()).toEqual("Untertitel");
- expect(menu.element().childNodes[2].innerHTML).toEqual("<strong>Untertit<mark>el</mark></strong>");
+ expect(menu.element().childNodes[3].innerHTML).toEqual("<strong>Untertit<mark>el</mark></strong>");
expect(menu.shownItem(1).active()).toBe(false);
expect(menu.shownItem(2)).toBe(undefined);
@@ -1043,10 +1044,10 @@
menu.prev();
expect(menu._prefix.active()).toEqual(true);
expect(menu.shownItem(0).name()).toEqual("Titel");
- expect(menu.element().childNodes[1].innerHTML).toEqual("<strong>Tit<mark>el</mark></strong>");
+ expect(menu.element().childNodes[2].innerHTML).toEqual("<strong>Tit<mark>el</mark></strong>");
expect(menu.shownItem(0).active()).toBe(false);
expect(menu.shownItem(1).name()).toEqual("Untertitel");
- expect(menu.element().childNodes[2].innerHTML).toEqual("<strong>Untertit<mark>el</mark></strong>");
+ expect(menu.element().childNodes[3].innerHTML).toEqual("<strong>Untertit<mark>el</mark></strong>");
expect(menu.shownItem(1).active()).toBe(false);
expect(menu.shownItem(2)).toBe(undefined);
@@ -1056,10 +1057,10 @@
expect(menu.prefix()).toEqual("el");
expect(menu._prefix.active()).toEqual(false);
expect(menu.shownItem(0).name()).toEqual("Titel");
- expect(menu.element().childNodes[1].innerHTML).toEqual("<strong>Tit<mark>el</mark></strong>");
+ expect(menu.element().childNodes[2].innerHTML).toEqual("<strong>Tit<mark>el</mark></strong>");
expect(menu.shownItem(0).active()).toBe(true);
expect(menu.shownItem(1).name()).toEqual("Untertitel");
- expect(menu.element().childNodes[2].innerHTML).toEqual("<strong>Untertit<mark>el</mark></strong>");
+ expect(menu.element().childNodes[3].innerHTML).toEqual("<strong>Untertit<mark>el</mark></strong>");
expect(menu.shownItem(1).active()).toBe(false);
expect(menu.shownItem(2)).toBe(undefined);
@@ -1147,4 +1148,38 @@
expect(p.element().classList.contains('active')).toBeTruthy();
});
});
+
+ describe('KorAP.LengthField', function () {
+ it('should be initializable', function () {
+ var l = lengthFieldClass.create();
+ expect(l.element().classList.contains('lengthField')).toBeTruthy();
+ expect(l.element().children.length).toEqual(0);
+ });
+
+ it('should be extensible', function () {
+ var l = lengthFieldClass.create();
+ l.add('Baum');
+ expect(l.element().children.length).toEqual(1);
+ expect(l.element().children[0].nodeName).toEqual('SPAN');
+ expect(l.element().children[0].textContent).toEqual('Baum-');
+ l.add('Fragezeichen');
+ expect(l.element().children.length).toEqual(2);
+ expect(l.element().children[1].nodeName).toEqual('SPAN');
+ expect(l.element().children[1].textContent).toEqual('Fragezeichen-');
+ });
+
+ it('should be correctly initializable', function () {
+ var list = [
+ ["Constituency"],
+ ["Lemma"],
+ ["Morphology"],
+ ["Part-of-Speech"],
+ ["Syntax"]
+ ];
+
+ var menu = KorAP.OwnMenu.create(list);
+
+ expect(menu.lengthField().element().children.length).toEqual(5);
+ });
+ });
});
diff --git a/dev/js/src/menu.js b/dev/js/src/menu.js
index 2d9aacb..a8cf26a 100644
--- a/dev/js/src/menu.js
+++ b/dev/js/src/menu.js
@@ -11,9 +11,11 @@
define([
'menu/item',
'menu/prefix',
+ 'menu/lengthField',
'util'
], function (defaultItemClass,
- defaultPrefixClass) {
+ defaultPrefixClass,
+ lengthFieldClass) {
// Default maximum number of menu items
var menuLimit = 8;
@@ -156,13 +158,20 @@
var that = this;
this._itemClass = itemClass || defaultItemClass;
- if (prefixClass !== undefined)
+ // Add prefix object
+ if (prefixClass !== undefined) {
this._prefix = prefixClass.create();
- else
+ }
+ else {
this._prefix = defaultPrefixClass.create();
-
+ };
this._prefix._menu = this;
+ // Add lengthField object
+ this._lengthField = lengthFieldClass.create();
+ this._lengthField._menu = this;
+
+
var e = document.createElement("ul");
e.style.opacity = 0;
e.style.outline = 0;
@@ -170,6 +179,7 @@
e.classList.add('menu');
e.classList.add('roll');
e.appendChild(this._prefix.element());
+ e.appendChild(this._lengthField.element());
// This has to be cleaned up later on
e["menu"] = this;
@@ -213,9 +223,10 @@
// This may become circular
obj["_menu"] = this;
-
+ this._lengthField.add(params[i][0]);
this._items.push(obj);
};
+
this._limit = menuLimit;
this._position = 0; // position in the active list
this._active = -1; // active item in the item list
@@ -352,7 +363,6 @@
this._list.push(i);
while (this._items[++i] !== undefined) {
this._items[i].lowlight();
- // console.log(this._item);
};
return true;
};
@@ -401,6 +411,12 @@
return this._prefix.value();
},
+ /**
+ * Get the lengthField object.
+ */
+ lengthField : function () {
+ return this._lengthField;
+ },
// Append Items that should be shown
_showItems : function (offset) {
@@ -449,7 +465,8 @@
// Remove all children
var children = this._element.childNodes;
- for (var i = children.length - 1; i >= 1; i--) {
+ // Leave the prefix and lengthField
+ for (var i = children.length - 1; i >= 2; i--) {
this._element.removeChild(
children[i]
);
@@ -479,10 +496,10 @@
item.highlight(this.prefix());
var e = this.element();
- // Append element
+ // Append element after lengthFiled/prefix
e.insertBefore(
item.element(),
- e.children[1]
+ e.children[2]
);
},
@@ -691,7 +708,8 @@
// Remove the HTML node from the first item
_removeFirst : function () {
this.item(this._list[this._offset]).lowlight();
- this._element.removeChild(this._element.children[1]);
+ // leave lengthField/prefix
+ this._element.removeChild(this._element.children[2]);
},
diff --git a/dev/js/src/menu/lengthField.js b/dev/js/src/menu/lengthField.js
new file mode 100644
index 0000000..76958e4
--- /dev/null
+++ b/dev/js/src/menu/lengthField.js
@@ -0,0 +1,31 @@
+define({
+
+ /**
+ * Create new lengthField object.
+ */
+ create : function () {
+ return Object.create(this)._init();
+ },
+
+ // Initialize lengthField object
+ _init : function () {
+ this._element = document.createElement('div');
+ this._element.classList.add('lengthField');
+ return this;
+ },
+
+ /**
+ * Add string to lengthField.
+ */
+ add : function (string) {
+ this._element.appendChild(document.createElement('span'))
+ .appendChild(document.createTextNode(string + '-'));
+ },
+
+ /**
+ * Get the associated dom element.
+ */
+ element : function () {
+ return this._element;
+ }
+});
diff --git a/dev/scss/header/menu.scss b/dev/scss/header/menu.scss
index 46529bd..3652231 100644
--- a/dev/scss/header/menu.scss
+++ b/dev/scss/header/menu.scss
@@ -31,6 +31,22 @@
white-space: normal;
}
+ul.menu div.lengthField {
+ border: {
+ color: transparent;
+ width: $border-size;
+ }
+ padding: $item-padding;
+ padding-top: 0;
+ padding-bottom: 0;
+ span {
+ display: block;
+ line-height: 0;
+ color: transparent;
+ }
+ background-color: blue;
+}
+
ul.menu > li,
ul.menu > span.pref:not(.active) {
@include choose-item;
@@ -47,8 +63,10 @@
/**
* List items
*/
- > li {
+ > li, div.lengthField {
padding-right: 1.6em;
+ }
+ > li {
&:first-of-type {
border-top: {