blob: 218063439eb5e8914b4a1cd751358a9210643064 [file] [log] [blame]
Nils Diewald0e6992a2015-04-14 20:13:52 +00001requirejs.config({
2 baseUrl: '../js/src'
3});
4
Akron6bb71582016-06-10 20:41:08 +02005require(['menu','menu/item', 'menu/prefix', 'menu/lengthField', 'selectMenu'], function (menuClass, itemClass, prefixClass, lengthFieldClass, selectMenuClass) {
Nils Diewald7148c6f2015-05-04 15:07:53 +00006
Akron0b92f692016-05-25 22:37:13 +02007 /**
8 * Create own menu item class.
9 */
Nils Diewald0e6992a2015-04-14 20:13:52 +000010 var OwnMenuItemClass = {
11 create : function (params) {
12 return Object.create(itemClass).upgradeTo(this)._init(params);
13 },
Akron1ff3ac22016-04-28 16:30:45 +020014
Akron0b92f692016-05-25 22:37:13 +020015 // content function
Nils Diewald0e6992a2015-04-14 20:13:52 +000016 content : function (content) {
17 if (arguments.length === 1) {
18 this._content = content;
19 };
20 return this._content;
21 },
22
23 // enter or click
24 onclick : function () {
25 console.log(this._name);
26 },
27
28 // right arrow
29 further : function () {
30 console.log("Further: " + this._name);
31 },
Akron0b92f692016-05-25 22:37:13 +020032
33 // initialize item
Nils Diewald0e6992a2015-04-14 20:13:52 +000034 _init : function (params) {
35 if (params[0] === undefined)
36 throw new Error("Missing parameters");
37
38 this._name = params[0];
39 this._content = document.createTextNode(this._name);
40 this._lcField = ' ' + this.content().textContent.toLowerCase();
Nils Diewald0e6992a2015-04-14 20:13:52 +000041 return this;
42 }
43 };
44
Akron0b92f692016-05-25 22:37:13 +020045 /**
46 * Create own prefix class.
47 */
Nils Diewald0e6992a2015-04-14 20:13:52 +000048 var OwnPrefixClass = {
49 create : function () {
50 return Object.create(prefixClass)
51 .upgradeTo(this)
52 ._init();
53 },
54 onclick : function () {
55 console.log('Prefix: ' + this.value());
56 }
57 };
58
Akron0b92f692016-05-25 22:37:13 +020059 /**
60 * Create own menu class.
61 */
Nils Diewald0e6992a2015-04-14 20:13:52 +000062 var OwnMenu = {
63 create : function (params) {
Nils Diewald20f7ace2015-05-07 12:51:34 +000064 var obj = Object.create(menuClass)
Nils Diewald0e6992a2015-04-14 20:13:52 +000065 .upgradeTo(this)
Akron1ff3ac22016-04-28 16:30:45 +020066 ._init(OwnMenuItemClass, OwnPrefixClass, lengthFieldClass, params);
Nils Diewald20f7ace2015-05-07 12:51:34 +000067 obj._firstActive = true;
68 return obj;
Nils Diewald0e6992a2015-04-14 20:13:52 +000069 }
70 };
71
72 var menu = OwnMenu.create([
73 ['Titel', 'title', 'string'],
74 ['Untertitel', 'subTitle', 'string'],
Akronc7448732016-04-27 14:06:58 +020075 ['Beschreibung', 'desc', 'string'],
Nils Diewald0e6992a2015-04-14 20:13:52 +000076 ['Veröffentlichungsdatum', 'pubDate', 'date'],
77 ['Länge', 'length', 'integer'],
78 ['Autor', 'author', 'string'],
79 ['Genre', 'genre', 'string'],
80 ['corpusID', 'corpusID', 'string'],
81 ['docID', 'docID', 'string'],
82 ['textID', 'textID', 'string']
83 ]);
84
85 document.getElementById('menu').appendChild(menu.element());
86
Akron0b92f692016-05-25 22:37:13 +020087 menu.limit(3).show(3);
Nils Diewald0e6992a2015-04-14 20:13:52 +000088 menu.focus();
Akron6bb71582016-06-10 20:41:08 +020089
90 selectMenuClass.create(document.getElementById('choose-ql')).limit(5); // .show();
Nils Diewald0e6992a2015-04-14 20:13:52 +000091});