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