Nils Diewald | 0e6992a | 2015-04-14 20:13:52 +0000 | [diff] [blame] | 1 | requirejs.config({ |
| 2 | baseUrl: '../js/src' |
| 3 | }); |
| 4 | |
Akron | 71b91e4 | 2016-06-01 22:12:43 +0200 | [diff] [blame] | 5 | require(['menu','menu/item', 'menu/prefix', 'menu/lengthField', 'selectMenu', 'hint/item', 'hint/lengthField'], function (menuClass, itemClass, prefixClass, lengthFieldClass, selectMenuClass, hintItemClass, hintLengthField) { |
Nils Diewald | 7148c6f | 2015-05-04 15:07:53 +0000 | [diff] [blame] | 6 | |
Akron | 0b92f69 | 2016-05-25 22:37:13 +0200 | [diff] [blame] | 7 | /** |
| 8 | * Create own menu item class. |
| 9 | */ |
Nils Diewald | 0e6992a | 2015-04-14 20:13:52 +0000 | [diff] [blame] | 10 | var OwnMenuItemClass = { |
| 11 | create : function (params) { |
| 12 | return Object.create(itemClass).upgradeTo(this)._init(params); |
| 13 | }, |
Akron | 1ff3ac2 | 2016-04-28 16:30:45 +0200 | [diff] [blame] | 14 | |
Akron | 0b92f69 | 2016-05-25 22:37:13 +0200 | [diff] [blame] | 15 | // content function |
Nils Diewald | 0e6992a | 2015-04-14 20:13:52 +0000 | [diff] [blame] | 16 | 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 | }, |
Akron | 0b92f69 | 2016-05-25 22:37:13 +0200 | [diff] [blame] | 32 | |
| 33 | // initialize item |
Nils Diewald | 0e6992a | 2015-04-14 20:13:52 +0000 | [diff] [blame] | 34 | _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 Diewald | 0e6992a | 2015-04-14 20:13:52 +0000 | [diff] [blame] | 41 | return this; |
| 42 | } |
| 43 | }; |
| 44 | |
Akron | 0b92f69 | 2016-05-25 22:37:13 +0200 | [diff] [blame] | 45 | /** |
| 46 | * Create own prefix class. |
| 47 | */ |
Nils Diewald | 0e6992a | 2015-04-14 20:13:52 +0000 | [diff] [blame] | 48 | 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 | |
Akron | 0b92f69 | 2016-05-25 22:37:13 +0200 | [diff] [blame] | 59 | /** |
| 60 | * Create own menu class. |
| 61 | */ |
Nils Diewald | 0e6992a | 2015-04-14 20:13:52 +0000 | [diff] [blame] | 62 | var OwnMenu = { |
Akron | 7524be1 | 2016-06-01 17:31:33 +0200 | [diff] [blame] | 63 | create : function (list) { |
Nils Diewald | 20f7ace | 2015-05-07 12:51:34 +0000 | [diff] [blame] | 64 | var obj = Object.create(menuClass) |
Nils Diewald | 0e6992a | 2015-04-14 20:13:52 +0000 | [diff] [blame] | 65 | .upgradeTo(this) |
Akron | 7524be1 | 2016-06-01 17:31:33 +0200 | [diff] [blame] | 66 | ._init(list, { |
| 67 | itemClass : OwnMenuItemClass, |
| 68 | prefixClass : OwnPrefixClass, |
| 69 | lengthFieldClass : lengthFieldClass |
| 70 | }); |
Nils Diewald | 20f7ace | 2015-05-07 12:51:34 +0000 | [diff] [blame] | 71 | obj._firstActive = true; |
| 72 | return obj; |
Nils Diewald | 0e6992a | 2015-04-14 20:13:52 +0000 | [diff] [blame] | 73 | } |
| 74 | }; |
| 75 | |
| 76 | var menu = OwnMenu.create([ |
| 77 | ['Titel', 'title', 'string'], |
| 78 | ['Untertitel', 'subTitle', 'string'], |
Akron | c744873 | 2016-04-27 14:06:58 +0200 | [diff] [blame] | 79 | ['Beschreibung', 'desc', 'string'], |
Nils Diewald | 0e6992a | 2015-04-14 20:13:52 +0000 | [diff] [blame] | 80 | ['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 | |
Akron | 71b91e4 | 2016-06-01 22:12:43 +0200 | [diff] [blame] | 89 | 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 | |
Nils Diewald | 0e6992a | 2015-04-14 20:13:52 +0000 | [diff] [blame] | 147 | document.getElementById('menu').appendChild(menu.element()); |
Akron | 71b91e4 | 2016-06-01 22:12:43 +0200 | [diff] [blame] | 148 | document.getElementById('largemenu').appendChild(largeMenu.element()); |
Nils Diewald | 0e6992a | 2015-04-14 20:13:52 +0000 | [diff] [blame] | 149 | |
Akron | 0b92f69 | 2016-05-25 22:37:13 +0200 | [diff] [blame] | 150 | menu.limit(3).show(3); |
Nils Diewald | 0e6992a | 2015-04-14 20:13:52 +0000 | [diff] [blame] | 151 | menu.focus(); |
Akron | 6bb7158 | 2016-06-10 20:41:08 +0200 | [diff] [blame] | 152 | |
Akron | 7f613e0 | 2016-11-07 02:50:44 +0100 | [diff] [blame^] | 153 | /* |
Akron | 6bb7158 | 2016-06-10 20:41:08 +0200 | [diff] [blame] | 154 | selectMenuClass.create(document.getElementById('choose-ql')).limit(5); // .show(); |
Akron | 71b91e4 | 2016-06-01 22:12:43 +0200 | [diff] [blame] | 155 | largeMenu.limit(8).show(3); |
Akron | 7f613e0 | 2016-11-07 02:50:44 +0100 | [diff] [blame^] | 156 | */ |
Nils Diewald | 0e6992a | 2015-04-14 20:13:52 +0000 | [diff] [blame] | 157 | }); |