blob: dfb4df38ea98688eba9fc517b3be15b82a52e0b6 [file] [log] [blame]
Leo Reppd162b2e2021-06-30 13:51:07 +02001requirejs.config({
2 baseUrl: '../js/src'
3});
4 // here alwaysmenu instead of normal menu, then + alwaysEntry
5require(['containermenu','menu/item', 'menu/prefix', 'menu/lengthField', 'selectMenu', 'hint/item', 'hint/lengthField',
6'container/container', 'container/containeritem'
7 ],
8function (containerMenuClass, itemClass, prefixClass, lengthFieldClass, selectMenuClass, hintItemClass, hintLengthField, containerClass, containerItemClass) {
9
10 /**
11 * Create own menu item class.
12 */
13 var OwnMenuItemClass = {
14 create : function (params) {
15 return Object.create(itemClass).upgradeTo(this)._init(params);
16 },
17
18 // content function
19 content : function (content) {
20 if (arguments.length === 1) {
21 this._content = content;
22 };
23 return this._content;
24 },
25
26 // enter or click
Leo Repp8e21cbe2021-08-18 16:37:52 +020027 onclick : function (event) {
Leo Reppd162b2e2021-06-30 13:51:07 +020028 console.log(this._name);
Leo Repp8e21cbe2021-08-18 16:37:52 +020029 event.halt();
Leo Reppd162b2e2021-06-30 13:51:07 +020030 },
31
32 // right arrow
33 further : function () {
34 console.log("Further: " + this._name);
35 },
36
37 // initialize item
38 _init : function (params) {
39 if (params[0] === undefined)
40 throw new Error("Missing parameters");
41
42 this._name = params[0];
43 this._content = document.createTextNode(this._name);
44 this._lcField = ' ' + this.content().textContent.toLowerCase();
45 this._i=0;
46 return this;
47 }
48 };
49
50
51 /**
52 * Create own conainerItem class.
53 */
54 var OwnContainerItemClass = {
55 create : function () {
56 var obj = containerItemClass.create()
57 .upgradeTo(this);
58 //._init();
59 obj.value="";
Leo Repp8e21cbe2021-08-18 16:37:52 +020060 obj.defaultTextValue = "CI";
Leo Reppd162b2e2021-06-30 13:51:07 +020061 return obj;
62 },
63 add : function (letter) {
64 this.value+=letter;
65 },
66 clear : function () {
67 this.value = "";
68 },
69 further : function () {
70 this.value = this.value + this.value;
71 },
Leo Repp8e21cbe2021-08-18 16:37:52 +020072 isSelectable : function () {
73 return (this.value !== "");
74 },
75 chop : function () {
76 console.log("chop");
77 console.log(this.content(this.value));
78 },
Leo Reppd162b2e2021-06-30 13:51:07 +020079 onclick : function () {
Leo Repp8e21cbe2021-08-18 16:37:52 +020080 console.log('ContainerItem ' + this.value);
Leo Reppd162b2e2021-06-30 13:51:07 +020081 console.log(this._i);
82 this._menu.limit(this._i);
83 this._menu.show();
Leo Reppd162b2e2021-06-30 13:51:07 +020084 }
85 };
86 //List of items.
87 var ExampleItemList = new Array;
88 ExampleItemList.push(OwnContainerItemClass.create());
89 ExampleItemList.push(OwnContainerItemClass.create());
Leo Reppc66268e2021-10-28 11:44:35 +020090 ExampleItemList.push(OwnContainerItemClass.create());
Leo Reppd162b2e2021-06-30 13:51:07 +020091 ExampleItemList[0].value = "Example Item 1";
92 ExampleItemList[0]._i = 3;
93 ExampleItemList[1]._i = 4;
Leo Reppc66268e2021-10-28 11:44:35 +020094 ExampleItemList[2].value = "Remove the Prefix Test";
95 ExampleItemList[2]._i=5;
96 ExampleItemList[2].onclick = function (e) {
97 this._menu.container().removeItemByIndex(3);
98 };
Leo Reppd162b2e2021-06-30 13:51:07 +020099
100 //Own container class.
101 var OwnContainerClass = {
102 create : function (listOfContainerItems, params) {
103 console.log(containerClass);
104 return containerClass.create(listOfContainerItems, params)
105 .upgradeTo(this);
106 }
107 //Dont know what you would want to add though
108 // You could add the containerItemClass parameter here *if* you really wanted to.
109 };
110
111 /**
112 * Create own menu class.
113 */
114
115 var OwnMenu = {
116 create : function (list) {
117 const params = {
118 itemClass : OwnMenuItemClass,
119 prefixClass : prefixClass,
120 lengthFieldClass : lengthFieldClass,
121 containerClass : OwnContainerClass,
122 containerItemClass : OwnContainerItemClass
123 };
124 console.log("Am now in OwnMenu create",containerMenuClass);
125 console.log(ExampleItemList); // we learn, that it definetly has all the functions defined in alwaysmenu.js
126 var obj = containerMenuClass.create(list,params,ExampleItemList)
127 .upgradeTo(this);
128 //._init(list, params);
129 obj._firstActive = true;
130 console.log("OwnMenu Element",obj._el);
131 return obj;
132 }
133 };
134
135 var list = [
136 ["Constituency"],
137 ["Lemma"],
138 ["Morphology"],
139 ["Part-of-Speech"],
140 ["Syntax"]
141 ];
142
143 /**
144 var list = [
145 ['Titel', 'title', 'string'],
146 ['Untertitel', 'subTitle', 'string'],
147 ['Beschreibung', 'desc', 'string'],
148 ['Veröffentlichungsdatum', 'pubDate', 'date'],
149 ['Länge', 'length', 'integer'],
150 ['Autor', 'author', 'string'],
151 ['Genre', 'genre', 'string'],
152 ['corpusID', 'corpusID', 'string'],
153 ['docID', 'docID', 'string'],
154 ['textID', 'textID', 'string']
155 ];
156 */
157
158 var menu = OwnMenu.create(list);
159
160 /**
161 var largeMenu = OwnMenu.create([
162 // http://www.ids-mannheim.de/cosmas2/projekt/referenz/stts/morph.html
163 // http://nachhalt.sfb632.uni-potsdam.de/owl-docu/stts.html
164 // "$.", "$(", "$,"
165 ["ADJA","ADJA ", "Attributive Adjective"],
166 ["ADJD","ADJD ", "Predicative Adjective"],
167 ["ADV","ADV ", "Adverb"],
168 ["APPO","APPO ", "Postposition"],
169 ["APPR","APPR ", "Preposition"],
170 ["APPRART","APPRART ", "Preposition with Determiner"],
171 ["APZR","APZR ","Right Circumposition"],
172 ["ART","ART ", "Determiner"],
173 ["CARD","CARD ", "Cardinal Number"],
174 ["FM","FM ", "Foreign Material"],
175 ["ITJ","ITJ ", "Interjection"],
176 ["KOKOM","KOKOM ", "Comparison Particle"],
177 ["KON","KON ", "Coordinating Conjuncion"],
178 ["KOUI","KOUI ", "Subordinating Conjunction with 'zu'"],
179 ["KOUS","KOUS ", "Subordinating Conjunction with Sentence"],
180 ["NE","NE ", "Named Entity"],
181 ["NN","NN ", "Normal Nomina"],
182 ["PAV", "PAV ", "Pronominal Adverb"],
183 ["PDAT","PDAT ","Attributive Demonstrative Pronoun"],
184 ["PDS","PDS ", "Substitutive Demonstrative Pronoun"],
185 ["PIAT","PIAT ", "Attributive Indefinite Pronoun without Determiner"],
186 ["PIDAT","PIDAT ", "Attributive Indefinite Pronoun with Determiner"],
187 ["PIS","PIS ", "Substitutive Indefinite Pronoun"],
188 ["PPER","PPER ", "Personal Pronoun"],
189 ["PPOSAT","PPOSAT ", "Attributive Possessive Pronoun"],
190 ["PPOSS","PPOSS ", "Substitutive Possessive Pronoun"],
191 ["PRELAT","PRELAT ", "Attributive Relative Pronoun"],
192 ["PRELS","PRELS ", "Substitutive Relative Pronoun"],
193 ["PRF","PRF ", "Reflexive Pronoun"],
194 ["PROAV","PROAV ", "Pronominal Adverb"],
195 ["PTKA","PTKA ","Particle with Adjective"],
196 ["PTKANT","PTKANT ", "Answering Particle"],
197 ["PTKNEG","PTKNEG ", "Negation Particle"],
198 ["PTKVZ","PTKVZ ", "Separated Verbal Particle"],
199 ["PTKZU","PTKZU ", "'zu' Particle"],
200 ["PWAT","PWAT ", "Attributive Interrogative Pronoun"],
201 ["PWAV","PWAV ", "Adverbial Interrogative Pronoun"],
202 ["PWS","PWS ", "Substitutive Interrogative Pronoun"],
203 ["TRUNC","TRUNC ","Truncated"],
204 ["VAFIN","VAFIN ", "Auxiliary Finite Verb"],
205 ["VAIMP","VAIMP ", "Auxiliary Finite Imperative Verb"],
206 ["VAINF","VAINF ", "Auxiliary Infinite Verb"],
207 ["VAPP","VAPP ", "Auxiliary Perfect Participle"],
208 ["VMFIN","VMFIN ", "Modal Finite Verb"],
209 ["VMINF","VMINF ", "Modal Infinite Verb"],
210 ["VMPP","VMPP ", "Modal Perfect Participle"],
211 ["VVFIN","VVFIN ","Finite Verb"],
212 ["VVIMP","VVIMP ", "Finite Imperative Verb"],
213 ["VVINF","VVINF ", "Infinite Verb"],
214 ["VVIZU","VVIZU ", "Infinite Verb with 'zu'"],
215 ["VVPP","VVPP ", "Perfect Participle"],
216 ["XY", "XY ", "Non-Word"]
217 ]);
218 */
219 document.getElementById('menu').appendChild(menu.element());
220 //document.getElementById('largemenu').appendChild(largeMenu.element());
221
Leo Repp8e21cbe2021-08-18 16:37:52 +0200222 menu.container().addItem({ value : "Dynamically added", defaultTextValue : "dynamic", _i : 5})
223
Leo Reppd162b2e2021-06-30 13:51:07 +0200224 menu.limit(3).show(3);
225 menu.focus();
226
227 //largeMenu.limit(8).show(3);
228});