blob: 2d66de9c18ed0a97ec0c610496a306abb0876aae [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'],
Akronc7448732016-04-27 14:06:58 +020063 ['Beschreibung', 'desc', 'string'],
Nils Diewald0e6992a2015-04-14 20:13:52 +000064 ['Veröffentlichungsdatum', 'pubDate', 'date'],
65 ['Länge', 'length', 'integer'],
66 ['Autor', 'author', 'string'],
67 ['Genre', 'genre', 'string'],
68 ['corpusID', 'corpusID', 'string'],
69 ['docID', 'docID', 'string'],
70 ['textID', 'textID', 'string']
71 ]);
72
73 document.getElementById('menu').appendChild(menu.element());
74
Akron37513a62015-11-17 01:07:11 +010075 menu._active = 2;
Nils Diewald0e6992a2015-04-14 20:13:52 +000076 menu.limit(3);
77 menu.show('');
78 menu.focus();
79});