blob: 1ca569ac3e5d5f2972eaec2db20d6e9583bc5794 [file] [log] [blame]
Nils Diewald0e6992a2015-04-14 20:13:52 +00001requirejs.config({
2 baseUrl: '../js/src'
3});
4
Akron82d67dd2017-02-01 14:26:34 +01005require(['menu','menu/item', 'menu/prefix', 'menu/lengthField', 'selectMenu', 'hint/item', 'hint/lengthField', 'multimenu'], function (menuClass, itemClass, prefixClass, lengthFieldClass, selectMenuClass, hintItemClass, hintLengthField, multiMenuClass) {
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
Akron71b91e42016-06-01 22:12:43 +020089 var largeMenu = menuClass.create([
90 // http://www.ids-mannheim.de/cosmas2/projekt/referenz/stts/morph.html
91 // http://nachhalt.sfb632.uni-potsdam.de/owl-docu/stts.html
92 // "$.", "$(", "$,"
93 ["ADJA","ADJA ", "Attributive Adjective"],
94 ["ADJD","ADJD ", "Predicative Adjective"],
95 ["ADV","ADV ", "Adverb"],
96 ["APPO","APPO ", "Postposition"],
97 ["APPR","APPR ", "Preposition"],
98 ["APPRART","APPRART ", "Preposition with Determiner"],
99 ["APZR","APZR ","Right Circumposition"],
100 ["ART","ART ", "Determiner"],
101 ["CARD","CARD ", "Cardinal Number"],
102 ["FM","FM ", "Foreign Material"],
103 ["ITJ","ITJ ", "Interjection"],
104 ["KOKOM","KOKOM ", "Comparison Particle"],
105 ["KON","KON ", "Coordinating Conjuncion"],
106 ["KOUI","KOUI ", "Subordinating Conjunction with 'zu'"],
107 ["KOUS","KOUS ", "Subordinating Conjunction with Sentence"],
108 ["NE","NE ", "Named Entity"],
109 ["NN","NN ", "Normal Nomina"],
110 ["PAV", "PAV ", "Pronominal Adverb"],
111 ["PDAT","PDAT ","Attributive Demonstrative Pronoun"],
112 ["PDS","PDS ", "Substitutive Demonstrative Pronoun"],
113 ["PIAT","PIAT ", "Attributive Indefinite Pronoun without Determiner"],
114 ["PIDAT","PIDAT ", "Attributive Indefinite Pronoun with Determiner"],
115 ["PIS","PIS ", "Substitutive Indefinite Pronoun"],
116 ["PPER","PPER ", "Personal Pronoun"],
117 ["PPOSAT","PPOSAT ", "Attributive Possessive Pronoun"],
118 ["PPOSS","PPOSS ", "Substitutive Possessive Pronoun"],
119 ["PRELAT","PRELAT ", "Attributive Relative Pronoun"],
120 ["PRELS","PRELS ", "Substitutive Relative Pronoun"],
121 ["PRF","PRF ", "Reflexive Pronoun"],
122 ["PROAV","PROAV ", "Pronominal Adverb"],
123 ["PTKA","PTKA ","Particle with Adjective"],
124 ["PTKANT","PTKANT ", "Answering Particle"],
125 ["PTKNEG","PTKNEG ", "Negation Particle"],
126 ["PTKVZ","PTKVZ ", "Separated Verbal Particle"],
127 ["PTKZU","PTKZU ", "'zu' Particle"],
128 ["PWAT","PWAT ", "Attributive Interrogative Pronoun"],
129 ["PWAV","PWAV ", "Adverbial Interrogative Pronoun"],
130 ["PWS","PWS ", "Substitutive Interrogative Pronoun"],
131 ["TRUNC","TRUNC ","Truncated"],
132 ["VAFIN","VAFIN ", "Auxiliary Finite Verb"],
133 ["VAIMP","VAIMP ", "Auxiliary Finite Imperative Verb"],
134 ["VAINF","VAINF ", "Auxiliary Infinite Verb"],
135 ["VAPP","VAPP ", "Auxiliary Perfect Participle"],
136 ["VMFIN","VMFIN ", "Modal Finite Verb"],
137 ["VMINF","VMINF ", "Modal Infinite Verb"],
138 ["VMPP","VMPP ", "Modal Perfect Participle"],
139 ["VVFIN","VVFIN ","Finite Verb"],
140 ["VVIMP","VVIMP ", "Finite Imperative Verb"],
141 ["VVINF","VVINF ", "Infinite Verb"],
142 ["VVIZU","VVIZU ", "Infinite Verb with 'zu'"],
143 ["VVPP","VVPP ", "Perfect Participle"],
144 ["XY", "XY ", "Non-Word"]
145 ], { 'itemClass' : hintItemClass, 'lengthField' : hintLengthField });
146
Akron82d67dd2017-02-01 14:26:34 +0100147 var multiMenu = multiMenuClass.create([
148 ["textSigle", "textSigle"],
149 ["author", "author"]
150 ]);
151
152
Nils Diewald0e6992a2015-04-14 20:13:52 +0000153 document.getElementById('menu').appendChild(menu.element());
Akron71b91e42016-06-01 22:12:43 +0200154 document.getElementById('largemenu').appendChild(largeMenu.element());
Akron82d67dd2017-02-01 14:26:34 +0100155 document.getElementById('multimenu').appendChild(multiMenu.element());
Nils Diewald0e6992a2015-04-14 20:13:52 +0000156
Akron0b92f692016-05-25 22:37:13 +0200157 menu.limit(3).show(3);
Nils Diewald0e6992a2015-04-14 20:13:52 +0000158 menu.focus();
Akron6bb71582016-06-10 20:41:08 +0200159
160 selectMenuClass.create(document.getElementById('choose-ql')).limit(5); // .show();
Akron71b91e42016-06-01 22:12:43 +0200161 largeMenu.limit(8).show(3);
Nils Diewald0e6992a2015-04-14 20:13:52 +0000162});