Leo Repp | d162b2e | 2021-06-30 13:51:07 +0200 | [diff] [blame] | 1 | requirejs.config({ |
| 2 | baseUrl: '../js/src' |
| 3 | }); |
| 4 | // here alwaysmenu instead of normal menu, then + alwaysEntry |
| 5 | require(['containermenu','menu/item', 'menu/prefix', 'menu/lengthField', 'selectMenu', 'hint/item', 'hint/lengthField', |
| 6 | 'container/container', 'container/containeritem' |
| 7 | ], |
| 8 | function (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 Repp | 5799740 | 2021-08-18 16:37:52 +0200 | [diff] [blame^] | 27 | onclick : function (event) { |
Leo Repp | d162b2e | 2021-06-30 13:51:07 +0200 | [diff] [blame] | 28 | console.log(this._name); |
Leo Repp | 5799740 | 2021-08-18 16:37:52 +0200 | [diff] [blame^] | 29 | event.halt(); |
Leo Repp | d162b2e | 2021-06-30 13:51:07 +0200 | [diff] [blame] | 30 | }, |
| 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 Repp | 5799740 | 2021-08-18 16:37:52 +0200 | [diff] [blame^] | 60 | obj.defaultTextValue = "CI"; |
Leo Repp | d162b2e | 2021-06-30 13:51:07 +0200 | [diff] [blame] | 61 | 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 Repp | 5799740 | 2021-08-18 16:37:52 +0200 | [diff] [blame^] | 72 | isSelectable : function () { |
| 73 | return (this.value !== ""); |
| 74 | }, |
| 75 | chop : function () { |
| 76 | console.log("chop"); |
| 77 | console.log(this.content(this.value)); |
| 78 | }, |
Leo Repp | d162b2e | 2021-06-30 13:51:07 +0200 | [diff] [blame] | 79 | onclick : function () { |
Leo Repp | 5799740 | 2021-08-18 16:37:52 +0200 | [diff] [blame^] | 80 | console.log('ContainerItem ' + this.value); |
Leo Repp | d162b2e | 2021-06-30 13:51:07 +0200 | [diff] [blame] | 81 | console.log(this._i); |
| 82 | this._menu.limit(this._i); |
| 83 | this._menu.show(); |
Leo Repp | d162b2e | 2021-06-30 13:51:07 +0200 | [diff] [blame] | 84 | } |
| 85 | }; |
| 86 | //List of items. |
| 87 | var ExampleItemList = new Array; |
| 88 | ExampleItemList.push(OwnContainerItemClass.create()); |
| 89 | ExampleItemList.push(OwnContainerItemClass.create()); |
Leo Repp | c66268e | 2021-10-28 11:44:35 +0200 | [diff] [blame] | 90 | ExampleItemList.push(OwnContainerItemClass.create()); |
Leo Repp | d162b2e | 2021-06-30 13:51:07 +0200 | [diff] [blame] | 91 | ExampleItemList[0].value = "Example Item 1"; |
| 92 | ExampleItemList[0]._i = 3; |
| 93 | ExampleItemList[1]._i = 4; |
Leo Repp | c66268e | 2021-10-28 11:44:35 +0200 | [diff] [blame] | 94 | ExampleItemList[2].value = "Remove the Prefix Test"; |
| 95 | ExampleItemList[2]._i=5; |
| 96 | ExampleItemList[2].onclick = function (e) { |
| 97 | this._menu.container().removeItemByIndex(3); |
Leo Repp | 5799740 | 2021-08-18 16:37:52 +0200 | [diff] [blame^] | 98 | //Should fail, that's ok. You can also try index 0 for testing functionality. |
Leo Repp | c66268e | 2021-10-28 11:44:35 +0200 | [diff] [blame] | 99 | }; |
Leo Repp | d162b2e | 2021-06-30 13:51:07 +0200 | [diff] [blame] | 100 | |
| 101 | //Own container class. |
| 102 | var OwnContainerClass = { |
| 103 | create : function (listOfContainerItems, params) { |
| 104 | console.log(containerClass); |
| 105 | return containerClass.create(listOfContainerItems, params) |
| 106 | .upgradeTo(this); |
| 107 | } |
| 108 | //Dont know what you would want to add though |
| 109 | // You could add the containerItemClass parameter here *if* you really wanted to. |
| 110 | }; |
| 111 | |
| 112 | /** |
| 113 | * Create own menu class. |
| 114 | */ |
| 115 | |
| 116 | var OwnMenu = { |
| 117 | create : function (list) { |
| 118 | const params = { |
| 119 | itemClass : OwnMenuItemClass, |
| 120 | prefixClass : prefixClass, |
| 121 | lengthFieldClass : lengthFieldClass, |
| 122 | containerClass : OwnContainerClass, |
| 123 | containerItemClass : OwnContainerItemClass |
| 124 | }; |
| 125 | console.log("Am now in OwnMenu create",containerMenuClass); |
| 126 | console.log(ExampleItemList); // we learn, that it definetly has all the functions defined in alwaysmenu.js |
| 127 | var obj = containerMenuClass.create(list,params,ExampleItemList) |
| 128 | .upgradeTo(this); |
| 129 | //._init(list, params); |
| 130 | obj._firstActive = true; |
| 131 | console.log("OwnMenu Element",obj._el); |
| 132 | return obj; |
| 133 | } |
| 134 | }; |
| 135 | |
| 136 | var list = [ |
| 137 | ["Constituency"], |
| 138 | ["Lemma"], |
| 139 | ["Morphology"], |
| 140 | ["Part-of-Speech"], |
| 141 | ["Syntax"] |
| 142 | ]; |
| 143 | |
| 144 | /** |
| 145 | var list = [ |
| 146 | ['Titel', 'title', 'string'], |
| 147 | ['Untertitel', 'subTitle', 'string'], |
| 148 | ['Beschreibung', 'desc', 'string'], |
| 149 | ['Veröffentlichungsdatum', 'pubDate', 'date'], |
| 150 | ['Länge', 'length', 'integer'], |
| 151 | ['Autor', 'author', 'string'], |
| 152 | ['Genre', 'genre', 'string'], |
| 153 | ['corpusID', 'corpusID', 'string'], |
| 154 | ['docID', 'docID', 'string'], |
| 155 | ['textID', 'textID', 'string'] |
| 156 | ]; |
| 157 | */ |
| 158 | |
| 159 | var menu = OwnMenu.create(list); |
| 160 | |
| 161 | /** |
| 162 | var largeMenu = OwnMenu.create([ |
| 163 | // http://www.ids-mannheim.de/cosmas2/projekt/referenz/stts/morph.html |
| 164 | // http://nachhalt.sfb632.uni-potsdam.de/owl-docu/stts.html |
| 165 | // "$.", "$(", "$," |
| 166 | ["ADJA","ADJA ", "Attributive Adjective"], |
| 167 | ["ADJD","ADJD ", "Predicative Adjective"], |
| 168 | ["ADV","ADV ", "Adverb"], |
| 169 | ["APPO","APPO ", "Postposition"], |
| 170 | ["APPR","APPR ", "Preposition"], |
| 171 | ["APPRART","APPRART ", "Preposition with Determiner"], |
| 172 | ["APZR","APZR ","Right Circumposition"], |
| 173 | ["ART","ART ", "Determiner"], |
| 174 | ["CARD","CARD ", "Cardinal Number"], |
| 175 | ["FM","FM ", "Foreign Material"], |
| 176 | ["ITJ","ITJ ", "Interjection"], |
| 177 | ["KOKOM","KOKOM ", "Comparison Particle"], |
| 178 | ["KON","KON ", "Coordinating Conjuncion"], |
| 179 | ["KOUI","KOUI ", "Subordinating Conjunction with 'zu'"], |
| 180 | ["KOUS","KOUS ", "Subordinating Conjunction with Sentence"], |
| 181 | ["NE","NE ", "Named Entity"], |
| 182 | ["NN","NN ", "Normal Nomina"], |
| 183 | ["PAV", "PAV ", "Pronominal Adverb"], |
| 184 | ["PDAT","PDAT ","Attributive Demonstrative Pronoun"], |
| 185 | ["PDS","PDS ", "Substitutive Demonstrative Pronoun"], |
| 186 | ["PIAT","PIAT ", "Attributive Indefinite Pronoun without Determiner"], |
| 187 | ["PIDAT","PIDAT ", "Attributive Indefinite Pronoun with Determiner"], |
| 188 | ["PIS","PIS ", "Substitutive Indefinite Pronoun"], |
| 189 | ["PPER","PPER ", "Personal Pronoun"], |
| 190 | ["PPOSAT","PPOSAT ", "Attributive Possessive Pronoun"], |
| 191 | ["PPOSS","PPOSS ", "Substitutive Possessive Pronoun"], |
| 192 | ["PRELAT","PRELAT ", "Attributive Relative Pronoun"], |
| 193 | ["PRELS","PRELS ", "Substitutive Relative Pronoun"], |
| 194 | ["PRF","PRF ", "Reflexive Pronoun"], |
| 195 | ["PROAV","PROAV ", "Pronominal Adverb"], |
| 196 | ["PTKA","PTKA ","Particle with Adjective"], |
| 197 | ["PTKANT","PTKANT ", "Answering Particle"], |
| 198 | ["PTKNEG","PTKNEG ", "Negation Particle"], |
| 199 | ["PTKVZ","PTKVZ ", "Separated Verbal Particle"], |
| 200 | ["PTKZU","PTKZU ", "'zu' Particle"], |
| 201 | ["PWAT","PWAT ", "Attributive Interrogative Pronoun"], |
| 202 | ["PWAV","PWAV ", "Adverbial Interrogative Pronoun"], |
| 203 | ["PWS","PWS ", "Substitutive Interrogative Pronoun"], |
| 204 | ["TRUNC","TRUNC ","Truncated"], |
| 205 | ["VAFIN","VAFIN ", "Auxiliary Finite Verb"], |
| 206 | ["VAIMP","VAIMP ", "Auxiliary Finite Imperative Verb"], |
| 207 | ["VAINF","VAINF ", "Auxiliary Infinite Verb"], |
| 208 | ["VAPP","VAPP ", "Auxiliary Perfect Participle"], |
| 209 | ["VMFIN","VMFIN ", "Modal Finite Verb"], |
| 210 | ["VMINF","VMINF ", "Modal Infinite Verb"], |
| 211 | ["VMPP","VMPP ", "Modal Perfect Participle"], |
| 212 | ["VVFIN","VVFIN ","Finite Verb"], |
| 213 | ["VVIMP","VVIMP ", "Finite Imperative Verb"], |
| 214 | ["VVINF","VVINF ", "Infinite Verb"], |
| 215 | ["VVIZU","VVIZU ", "Infinite Verb with 'zu'"], |
| 216 | ["VVPP","VVPP ", "Perfect Participle"], |
| 217 | ["XY", "XY ", "Non-Word"] |
| 218 | ]); |
| 219 | */ |
| 220 | document.getElementById('menu').appendChild(menu.element()); |
| 221 | //document.getElementById('largemenu').appendChild(largeMenu.element()); |
| 222 | |
Leo Repp | 5799740 | 2021-08-18 16:37:52 +0200 | [diff] [blame^] | 223 | menu.container().addItem({ value : "Dynamically added", defaultTextValue : "dynamic", _i : 5}) |
| 224 | |
Leo Repp | d162b2e | 2021-06-30 13:51:07 +0200 | [diff] [blame] | 225 | menu.limit(3).show(3); |
| 226 | menu.focus(); |
| 227 | |
| 228 | //largeMenu.limit(8).show(3); |
| 229 | }); |