blob: 055963b0b14ca424a8ede2441a2e83b141807709 [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) {
52 return Object.create(menuClass)
53 .upgradeTo(this)
54 ._init(OwnMenuItemClass, OwnPrefixClass, params);
55 }
56 };
57
58 var menu = OwnMenu.create([
59 ['Titel', 'title', 'string'],
60 ['Untertitel', 'subTitle', 'string'],
61 ['Veröffentlichungsdatum', 'pubDate', 'date'],
62 ['Länge', 'length', 'integer'],
63 ['Autor', 'author', 'string'],
64 ['Genre', 'genre', 'string'],
65 ['corpusID', 'corpusID', 'string'],
66 ['docID', 'docID', 'string'],
67 ['textID', 'textID', 'string']
68 ]);
69
70 document.getElementById('menu').appendChild(menu.element());
71
72 menu.limit(3);
73 menu.show('');
74 menu.focus();
75});