blob: 1df0f55202f432caa976286c0d1f580475007964 [file] [log] [blame]
Nils Diewald0e6992a2015-04-14 20:13:52 +00001requirejs.config({
2 baseUrl: '../js/src'
3});
4
5require(['menu','menu/item', 'menu/prefix'], function (menuClass, itemClass, prefixClass) {
Nils Diewald7148c6f2015-05-04 15:07:53 +00006
Nils Diewald0e6992a2015-04-14 20:13:52 +00007 var OwnMenuItemClass = {
8 create : function (params) {
9 return Object.create(itemClass).upgradeTo(this)._init(params);
10 },
11 content : function (content) {
12 if (arguments.length === 1) {
13 this._content = content;
14 };
15 return this._content;
16 },
17
18 // enter or click
19 onclick : function () {
20 console.log(this._name);
21 },
22
23 // right arrow
24 further : function () {
25 console.log("Further: " + this._name);
26 },
27 _init : function (params) {
28 if (params[0] === undefined)
29 throw new Error("Missing parameters");
30
31 this._name = params[0];
32 this._content = document.createTextNode(this._name);
33 this._lcField = ' ' + this.content().textContent.toLowerCase();
34
35 return this;
36 }
37 };
38
39 var OwnPrefixClass = {
40 create : function () {
41 return Object.create(prefixClass)
42 .upgradeTo(this)
43 ._init();
44 },
45 onclick : function () {
46 console.log('Prefix: ' + this.value());
47 }
48 };
49
50 var OwnMenu = {
51 create : function (params) {
Nils Diewald20f7ace2015-05-07 12:51:34 +000052 var obj = Object.create(menuClass)
Nils Diewald0e6992a2015-04-14 20:13:52 +000053 .upgradeTo(this)
54 ._init(OwnMenuItemClass, OwnPrefixClass, params);
Nils Diewald20f7ace2015-05-07 12:51:34 +000055 obj._firstActive = true;
56 return obj;
Nils Diewald0e6992a2015-04-14 20:13:52 +000057 }
58 };
59
60 var menu = OwnMenu.create([
61 ['Titel', 'title', 'string'],
62 ['Untertitel', 'subTitle', 'string'],
63 ['Veröffentlichungsdatum', 'pubDate', 'date'],
64 ['Länge', 'length', 'integer'],
65 ['Autor', 'author', 'string'],
66 ['Genre', 'genre', 'string'],
67 ['corpusID', 'corpusID', 'string'],
68 ['docID', 'docID', 'string'],
69 ['textID', 'textID', 'string']
70 ]);
71
72 document.getElementById('menu').appendChild(menu.element());
73
74 menu.limit(3);
75 menu.show('');
76 menu.focus();
77});