blob: 29d5c1ba68cb5a7f0503d6f8140aebd251e64c41 [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 = {
Akron7524be12016-06-01 17:31:33 +020063 create : function (list) {
Nils Diewald20f7ace2015-05-07 12:51:34 +000064 var obj = Object.create(menuClass)
Nils Diewald0e6992a2015-04-14 20:13:52 +000065 .upgradeTo(this)
Akron7524be12016-06-01 17:31:33 +020066 ._init(list, {
67 itemClass : OwnMenuItemClass,
68 prefixClass : OwnPrefixClass,
69 lengthFieldClass : lengthFieldClass
70 });
Nils Diewald20f7ace2015-05-07 12:51:34 +000071 obj._firstActive = true;
72 return obj;
Nils Diewald0e6992a2015-04-14 20:13:52 +000073 }
74 };
75
76 var menu = OwnMenu.create([
77 ['Titel', 'title', 'string'],
78 ['Untertitel', 'subTitle', 'string'],
Akronc7448732016-04-27 14:06:58 +020079 ['Beschreibung', 'desc', 'string'],
Nils Diewald0e6992a2015-04-14 20:13:52 +000080 ['Veröffentlichungsdatum', 'pubDate', 'date'],
81 ['Länge', 'length', 'integer'],
82 ['Autor', 'author', 'string'],
83 ['Genre', 'genre', 'string'],
84 ['corpusID', 'corpusID', 'string'],
85 ['docID', 'docID', 'string'],
86 ['textID', 'textID', 'string']
87 ]);
88
89 document.getElementById('menu').appendChild(menu.element());
90
Akron0b92f692016-05-25 22:37:13 +020091 menu.limit(3).show(3);
Nils Diewald0e6992a2015-04-14 20:13:52 +000092 menu.focus();
Akron6bb71582016-06-10 20:41:08 +020093
94 selectMenuClass.create(document.getElementById('choose-ql')).limit(5); // .show();
Nils Diewald0e6992a2015-04-14 20:13:52 +000095});