blob: 2983230b7aff19c685f29cad150b0594d9b11676 [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 Repp84539162021-10-25 12:06:07 +020027 onclick : function () {
Leo Reppd162b2e2021-06-30 13:51:07 +020028 console.log(this._name);
29 },
30
31 // right arrow
32 further : function () {
33 console.log("Further: " + this._name);
34 },
35
36 // initialize item
37 _init : function (params) {
38 if (params[0] === undefined)
39 throw new Error("Missing parameters");
40
41 this._name = params[0];
42 this._content = document.createTextNode(this._name);
43 this._lcField = ' ' + this.content().textContent.toLowerCase();
Leo Repp84539162021-10-25 12:06:07 +020044 this.newLimit=0;
Leo Reppd162b2e2021-06-30 13:51:07 +020045 return this;
46 }
47 };
48
49
50 /**
51 * Create own conainerItem class.
52 */
53 var OwnContainerItemClass = {
54 create : function () {
55 var obj = containerItemClass.create()
56 .upgradeTo(this);
57 //._init();
58 obj.value="";
Leo Repp57997402021-08-18 16:37:52 +020059 obj.defaultTextValue = "CI";
Leo Reppd162b2e2021-06-30 13:51:07 +020060 return obj;
61 },
62 add : function (letter) {
63 this.value+=letter;
64 },
65 clear : function () {
66 this.value = "";
67 },
68 further : function () {
69 this.value = this.value + this.value;
70 },
71 onclick : function () {
Leo Repp57997402021-08-18 16:37:52 +020072 console.log('ContainerItem ' + this.value);
Leo Repp84539162021-10-25 12:06:07 +020073 console.log(this.newLimit);
74 this._menu.limit(this.newLimit);
Leo Reppd162b2e2021-06-30 13:51:07 +020075 this._menu.show();
Leo Reppd162b2e2021-06-30 13:51:07 +020076 }
77 };
78 //List of items.
79 var ExampleItemList = new Array;
80 ExampleItemList.push(OwnContainerItemClass.create());
81 ExampleItemList.push(OwnContainerItemClass.create());
Leo Reppc66268e2021-10-28 11:44:35 +020082 ExampleItemList.push(OwnContainerItemClass.create());
Leo Reppd162b2e2021-06-30 13:51:07 +020083 ExampleItemList[0].value = "Example Item 1";
Leo Repp84539162021-10-25 12:06:07 +020084 ExampleItemList[0].newLimit = 3;
85 ExampleItemList[1].newLimit = 4;
Leo Reppc66268e2021-10-28 11:44:35 +020086 ExampleItemList[2].value = "Remove the Prefix Test";
Leo Repp84539162021-10-25 12:06:07 +020087 ExampleItemList[2].newLimit=5;
Leo Reppc66268e2021-10-28 11:44:35 +020088 ExampleItemList[2].onclick = function (e) {
Leo Repp84539162021-10-25 12:06:07 +020089 this._menu.container().addItem({defaultTextValue: "new", newLimit:4 })
90 this.initContent("I created a new item");
91 this._menu.container().removeItemByIndex(0);
Leo Reppc66268e2021-10-28 11:44:35 +020092 };
Leo Reppd162b2e2021-06-30 13:51:07 +020093
94 //Own container class.
95 var OwnContainerClass = {
96 create : function (listOfContainerItems, params) {
97 console.log(containerClass);
98 return containerClass.create(listOfContainerItems, params)
99 .upgradeTo(this);
100 }
101 //Dont know what you would want to add though
102 // You could add the containerItemClass parameter here *if* you really wanted to.
103 };
104
105 /**
106 * Create own menu class.
107 */
108
109 var OwnMenu = {
110 create : function (list) {
111 const params = {
112 itemClass : OwnMenuItemClass,
113 prefixClass : prefixClass,
114 lengthFieldClass : lengthFieldClass,
115 containerClass : OwnContainerClass,
116 containerItemClass : OwnContainerItemClass
117 };
118 console.log("Am now in OwnMenu create",containerMenuClass);
119 console.log(ExampleItemList); // we learn, that it definetly has all the functions defined in alwaysmenu.js
120 var obj = containerMenuClass.create(list,params,ExampleItemList)
121 .upgradeTo(this);
122 //._init(list, params);
123 obj._firstActive = true;
124 console.log("OwnMenu Element",obj._el);
125 return obj;
126 }
127 };
128
129 var list = [
130 ["Constituency"],
131 ["Lemma"],
132 ["Morphology"],
133 ["Part-of-Speech"],
134 ["Syntax"]
135 ];
136
137 /**
138 var list = [
139 ['Titel', 'title', 'string'],
140 ['Untertitel', 'subTitle', 'string'],
141 ['Beschreibung', 'desc', 'string'],
142 ['Veröffentlichungsdatum', 'pubDate', 'date'],
143 ['Länge', 'length', 'integer'],
144 ['Autor', 'author', 'string'],
145 ['Genre', 'genre', 'string'],
146 ['corpusID', 'corpusID', 'string'],
147 ['docID', 'docID', 'string'],
148 ['textID', 'textID', 'string']
149 ];
150 */
151
152 var menu = OwnMenu.create(list);
153
154 /**
155 var largeMenu = OwnMenu.create([
156 // http://www.ids-mannheim.de/cosmas2/projekt/referenz/stts/morph.html
157 // http://nachhalt.sfb632.uni-potsdam.de/owl-docu/stts.html
158 // "$.", "$(", "$,"
159 ["ADJA","ADJA ", "Attributive Adjective"],
160 ["ADJD","ADJD ", "Predicative Adjective"],
161 ["ADV","ADV ", "Adverb"],
162 ["APPO","APPO ", "Postposition"],
163 ["APPR","APPR ", "Preposition"],
164 ["APPRART","APPRART ", "Preposition with Determiner"],
165 ["APZR","APZR ","Right Circumposition"],
166 ["ART","ART ", "Determiner"],
167 ["CARD","CARD ", "Cardinal Number"],
168 ["FM","FM ", "Foreign Material"],
169 ["ITJ","ITJ ", "Interjection"],
170 ["KOKOM","KOKOM ", "Comparison Particle"],
171 ["KON","KON ", "Coordinating Conjuncion"],
172 ["KOUI","KOUI ", "Subordinating Conjunction with 'zu'"],
173 ["KOUS","KOUS ", "Subordinating Conjunction with Sentence"],
174 ["NE","NE ", "Named Entity"],
175 ["NN","NN ", "Normal Nomina"],
176 ["PAV", "PAV ", "Pronominal Adverb"],
177 ["PDAT","PDAT ","Attributive Demonstrative Pronoun"],
178 ["PDS","PDS ", "Substitutive Demonstrative Pronoun"],
179 ["PIAT","PIAT ", "Attributive Indefinite Pronoun without Determiner"],
180 ["PIDAT","PIDAT ", "Attributive Indefinite Pronoun with Determiner"],
181 ["PIS","PIS ", "Substitutive Indefinite Pronoun"],
182 ["PPER","PPER ", "Personal Pronoun"],
183 ["PPOSAT","PPOSAT ", "Attributive Possessive Pronoun"],
184 ["PPOSS","PPOSS ", "Substitutive Possessive Pronoun"],
185 ["PRELAT","PRELAT ", "Attributive Relative Pronoun"],
186 ["PRELS","PRELS ", "Substitutive Relative Pronoun"],
187 ["PRF","PRF ", "Reflexive Pronoun"],
188 ["PROAV","PROAV ", "Pronominal Adverb"],
189 ["PTKA","PTKA ","Particle with Adjective"],
190 ["PTKANT","PTKANT ", "Answering Particle"],
191 ["PTKNEG","PTKNEG ", "Negation Particle"],
192 ["PTKVZ","PTKVZ ", "Separated Verbal Particle"],
193 ["PTKZU","PTKZU ", "'zu' Particle"],
194 ["PWAT","PWAT ", "Attributive Interrogative Pronoun"],
195 ["PWAV","PWAV ", "Adverbial Interrogative Pronoun"],
196 ["PWS","PWS ", "Substitutive Interrogative Pronoun"],
197 ["TRUNC","TRUNC ","Truncated"],
198 ["VAFIN","VAFIN ", "Auxiliary Finite Verb"],
199 ["VAIMP","VAIMP ", "Auxiliary Finite Imperative Verb"],
200 ["VAINF","VAINF ", "Auxiliary Infinite Verb"],
201 ["VAPP","VAPP ", "Auxiliary Perfect Participle"],
202 ["VMFIN","VMFIN ", "Modal Finite Verb"],
203 ["VMINF","VMINF ", "Modal Infinite Verb"],
204 ["VMPP","VMPP ", "Modal Perfect Participle"],
205 ["VVFIN","VVFIN ","Finite Verb"],
206 ["VVIMP","VVIMP ", "Finite Imperative Verb"],
207 ["VVINF","VVINF ", "Infinite Verb"],
208 ["VVIZU","VVIZU ", "Infinite Verb with 'zu'"],
209 ["VVPP","VVPP ", "Perfect Participle"],
210 ["XY", "XY ", "Non-Word"]
211 ]);
212 */
213 document.getElementById('menu').appendChild(menu.element());
214 //document.getElementById('largemenu').appendChild(largeMenu.element());
215
Leo Repp84539162021-10-25 12:06:07 +0200216 menu.container().addItem({ value : "Dynamically added", defaultTextValue : "dynamic", newLimit : 5})
Leo Repp57997402021-08-18 16:37:52 +0200217
Leo Reppd162b2e2021-06-30 13:51:07 +0200218 menu.limit(3).show(3);
219 menu.focus();
220
221 //largeMenu.limit(8).show(3);
222});