Akron | 99713ef | 2017-06-28 18:19:28 +0200 | [diff] [blame] | 1 | /** |
| 2 | * Information about a match. |
| 3 | */ |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 4 | define([ |
| 5 | 'match/infolayer', |
| 6 | 'match/table', |
| 7 | 'match/tree', |
Akron | bd34298 | 2018-01-25 18:01:46 +0100 | [diff] [blame] | 8 | 'match/reference', // rename to meta |
Akron | 0988d88 | 2017-11-10 16:13:12 +0100 | [diff] [blame] | 9 | 'match/relations', |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 10 | 'match/treemenu', |
Akron | 99713ef | 2017-06-28 18:19:28 +0200 | [diff] [blame] | 11 | 'match/querycreator', |
Nils Diewald | 7c8ced2 | 2015-04-15 19:21:00 +0000 | [diff] [blame] | 12 | 'util' |
| 13 | ], function (infoLayerClass, |
Akron | 3bb91bc | 2016-12-02 16:43:17 +0100 | [diff] [blame] | 14 | matchTableClass, |
| 15 | matchTreeClass, |
Akron | bd34298 | 2018-01-25 18:01:46 +0100 | [diff] [blame] | 16 | matchRefClass, |
Akron | 0988d88 | 2017-11-10 16:13:12 +0100 | [diff] [blame] | 17 | matchRelClass, |
Akron | 99713ef | 2017-06-28 18:19:28 +0200 | [diff] [blame] | 18 | matchTreeMenuClass, |
Akron | 0988d88 | 2017-11-10 16:13:12 +0100 | [diff] [blame] | 19 | matchQueryCreator) { |
Akron | 3bb91bc | 2016-12-02 16:43:17 +0100 | [diff] [blame] | 20 | |
Nils Diewald | 7148c6f | 2015-05-04 15:07:53 +0000 | [diff] [blame] | 21 | // Override |
Nils Diewald | 0e6992a | 2015-04-14 20:13:52 +0000 | [diff] [blame] | 22 | KorAP.API.getMatchInfo = KorAP.API.getMatchInfo || function () { |
| 23 | KorAP.log(0, 'KorAP.API.getMatchInfo() not implemented') |
| 24 | return {}; |
| 25 | }; |
| 26 | |
| 27 | var loc = KorAP.Locale; |
| 28 | |
Nils Diewald | 0e6992a | 2015-04-14 20:13:52 +0000 | [diff] [blame] | 29 | return { |
Nils Diewald | 7148c6f | 2015-05-04 15:07:53 +0000 | [diff] [blame] | 30 | |
| 31 | /** |
| 32 | * Create new match object |
| 33 | */ |
Nils Diewald | 0e6992a | 2015-04-14 20:13:52 +0000 | [diff] [blame] | 34 | create : function (match) { |
| 35 | return Object.create(this)._init(match); |
| 36 | }, |
| 37 | |
| 38 | /** |
| 39 | * Initialize object |
| 40 | */ |
| 41 | _init : function (match) { |
| 42 | this._match = match; |
| 43 | this.opened = false; |
| 44 | return this; |
| 45 | }, |
| 46 | |
| 47 | /** |
| 48 | * Get match object |
| 49 | */ |
| 50 | match : function () { |
| 51 | return this._match; |
| 52 | }, |
| 53 | |
Nils Diewald | 7148c6f | 2015-05-04 15:07:53 +0000 | [diff] [blame] | 54 | |
| 55 | /** |
| 56 | * Open the information view, |
| 57 | * if closed, otherwise close. |
| 58 | */ |
Akron | bd34298 | 2018-01-25 18:01:46 +0100 | [diff] [blame] | 59 | /* |
Nils Diewald | 0e6992a | 2015-04-14 20:13:52 +0000 | [diff] [blame] | 60 | toggle : function () { |
Akron | 3bb91bc | 2016-12-02 16:43:17 +0100 | [diff] [blame] | 61 | |
Akron | 08b82d6 | 2016-12-05 15:06:05 +0100 | [diff] [blame] | 62 | var elem = this._match.element(); |
Akron | 3bb91bc | 2016-12-02 16:43:17 +0100 | [diff] [blame] | 63 | |
| 64 | if (this.opened == true) { |
Akron | d67d45b | 2017-05-18 21:47:38 +0200 | [diff] [blame] | 65 | elem.removeChild( |
| 66 | this.element() |
| 67 | ); |
| 68 | this.opened = false; |
Nils Diewald | 0e6992a | 2015-04-14 20:13:52 +0000 | [diff] [blame] | 69 | } |
| 70 | else { |
Akron | d67d45b | 2017-05-18 21:47:38 +0200 | [diff] [blame] | 71 | // Append element to match |
Akron | 3bb91bc | 2016-12-02 16:43:17 +0100 | [diff] [blame] | 72 | elem.appendChild( |
Akron | d67d45b | 2017-05-18 21:47:38 +0200 | [diff] [blame] | 73 | this.element() |
| 74 | ); |
| 75 | this.opened = true; |
Nils Diewald | 0e6992a | 2015-04-14 20:13:52 +0000 | [diff] [blame] | 76 | }; |
| 77 | |
| 78 | return this.opened; |
| 79 | }, |
Akron | bd34298 | 2018-01-25 18:01:46 +0100 | [diff] [blame] | 80 | */ |
Nils Diewald | 0e6992a | 2015-04-14 20:13:52 +0000 | [diff] [blame] | 81 | |
| 82 | |
| 83 | /** |
Nils Diewald | 7148c6f | 2015-05-04 15:07:53 +0000 | [diff] [blame] | 84 | * Retrieve and parse snippet for table |
| 85 | * representation |
Nils Diewald | 0e6992a | 2015-04-14 20:13:52 +0000 | [diff] [blame] | 86 | */ |
| 87 | getTable : function (tokens, cb) { |
| 88 | var focus = []; |
| 89 | |
| 90 | // Get all tokens |
| 91 | if (tokens === undefined) { |
Akron | d67d45b | 2017-05-18 21:47:38 +0200 | [diff] [blame] | 92 | focus = this._match.getTokens(); |
Nils Diewald | 0e6992a | 2015-04-14 20:13:52 +0000 | [diff] [blame] | 93 | } |
| 94 | |
| 95 | // Get only some tokens |
| 96 | else { |
Akron | d67d45b | 2017-05-18 21:47:38 +0200 | [diff] [blame] | 97 | |
| 98 | // Push newly to focus array |
| 99 | for (var i = 0; i < tokens.length; i++) { |
| 100 | var term = tokens[i]; |
| 101 | try { |
| 102 | // Create info layer objects |
| 103 | var layer = infoLayerClass.create(term); |
| 104 | layer.type = "tokens"; |
| 105 | focus.push(layer); |
| 106 | } |
| 107 | catch (e) { |
| 108 | continue; |
| 109 | }; |
| 110 | }; |
Nils Diewald | 0e6992a | 2015-04-14 20:13:52 +0000 | [diff] [blame] | 111 | }; |
| 112 | |
| 113 | // No tokens chosen |
| 114 | if (focus.length == 0) |
Akron | d67d45b | 2017-05-18 21:47:38 +0200 | [diff] [blame] | 115 | cb(null); |
Nils Diewald | 0e6992a | 2015-04-14 20:13:52 +0000 | [diff] [blame] | 116 | |
| 117 | // Get info (may be cached) |
Nils Diewald | 0e6992a | 2015-04-14 20:13:52 +0000 | [diff] [blame] | 118 | KorAP.API.getMatchInfo( |
Akron | d67d45b | 2017-05-18 21:47:38 +0200 | [diff] [blame] | 119 | this._match, |
| 120 | { 'spans' : false, 'layer' : focus }, |
| 121 | |
| 122 | // Callback for retrieval |
| 123 | function (matchResponse) { |
Akron | 3bb91bc | 2016-12-02 16:43:17 +0100 | [diff] [blame] | 124 | |
Akron | 515851a | 2017-05-02 12:53:17 +0200 | [diff] [blame] | 125 | if (matchResponse === undefined) |
| 126 | cb(null); |
| 127 | |
Akron | d67d45b | 2017-05-18 21:47:38 +0200 | [diff] [blame] | 128 | // Get snippet from match info |
| 129 | if (matchResponse["snippet"] !== undefined) { |
| 130 | this._table = matchTableClass.create(matchResponse["snippet"]); |
| 131 | cb(this._table); |
| 132 | }; |
| 133 | }.bind(this) |
Nils Diewald | 0e6992a | 2015-04-14 20:13:52 +0000 | [diff] [blame] | 134 | ); |
| 135 | |
| 136 | /* |
| 137 | // Todo: Store the table as a hash of the focus |
| 138 | return null; |
| 139 | */ |
| 140 | }, |
Akron | bd34298 | 2018-01-25 18:01:46 +0100 | [diff] [blame] | 141 | |
| 142 | |
| 143 | getMeta : function (metaInfo, cb) { |
| 144 | |
| 145 | }, |
Nils Diewald | 0e6992a | 2015-04-14 20:13:52 +0000 | [diff] [blame] | 146 | |
| 147 | |
| 148 | /** |
| 149 | * Retrieve and parse snippet for tree representation |
| 150 | */ |
Akron | 0988d88 | 2017-11-10 16:13:12 +0100 | [diff] [blame] | 151 | getTree : function (foundry, layer, type, cb) { |
Nils Diewald | 0e6992a | 2015-04-14 20:13:52 +0000 | [diff] [blame] | 152 | var focus = []; |
| 153 | |
| 154 | // TODO: Support and cache multiple trees |
| 155 | KorAP.API.getMatchInfo( |
Akron | d67d45b | 2017-05-18 21:47:38 +0200 | [diff] [blame] | 156 | this._match, { |
| 157 | 'spans' : true, |
| 158 | 'foundry' : foundry, |
| 159 | 'layer' : layer |
| 160 | }, |
| 161 | function (matchResponse) { |
| 162 | // Get snippet from match info |
| 163 | if (matchResponse["snippet"] !== undefined) { |
| 164 | // Todo: This should be cached somehow |
Akron | c56cf2d | 2016-11-09 22:02:38 +0100 | [diff] [blame] | 165 | |
Akron | 0988d88 | 2017-11-10 16:13:12 +0100 | [diff] [blame] | 166 | if (type === "spans") { |
| 167 | cb(matchTreeClass.create(matchResponse["snippet"])); |
| 168 | } |
| 169 | else if (type === "rels") { |
| 170 | cb(matchRelClass.create(matchResponse["snippet"])); |
| 171 | } |
| 172 | |
| 173 | // Unknown tree type |
| 174 | else { |
| 175 | cb(null); |
| 176 | }; |
Akron | d67d45b | 2017-05-18 21:47:38 +0200 | [diff] [blame] | 177 | } |
| 178 | else { |
| 179 | cb(null); |
| 180 | }; |
| 181 | }.bind(this) |
Nils Diewald | 0e6992a | 2015-04-14 20:13:52 +0000 | [diff] [blame] | 182 | ); |
| 183 | }, |
| 184 | |
| 185 | /** |
| 186 | * Destroy this match information view. |
| 187 | */ |
| 188 | destroy : function () { |
| 189 | |
| 190 | // Remove circular reference |
| 191 | if (this._treeMenu !== undefined) |
Akron | 99713ef | 2017-06-28 18:19:28 +0200 | [diff] [blame] | 192 | delete this._treeMenu["info"]; |
Nils Diewald | 0e6992a | 2015-04-14 20:13:52 +0000 | [diff] [blame] | 193 | |
| 194 | this._treeMenu.destroy(); |
| 195 | this._treeMenu = undefined; |
| 196 | this._match = undefined; |
Akron | 99713ef | 2017-06-28 18:19:28 +0200 | [diff] [blame] | 197 | this._matchCreator = undefined; |
Nils Diewald | 0e6992a | 2015-04-14 20:13:52 +0000 | [diff] [blame] | 198 | // Element destroy |
| 199 | }, |
| 200 | |
| 201 | /** |
| 202 | * Add a new tree view to the list |
| 203 | */ |
Akron | 0988d88 | 2017-11-10 16:13:12 +0100 | [diff] [blame] | 204 | addTree : function (foundry, layer, type, cb) { |
Nils Diewald | 0e6992a | 2015-04-14 20:13:52 +0000 | [diff] [blame] | 205 | var matchtree = document.createElement('div'); |
| 206 | matchtree.classList.add('matchtree'); |
| 207 | |
| 208 | var h6 = matchtree.appendChild(document.createElement('h6')); |
| 209 | h6.appendChild(document.createElement('span')) |
Akron | 99713ef | 2017-06-28 18:19:28 +0200 | [diff] [blame] | 210 | .appendChild(document.createTextNode(foundry)); |
Nils Diewald | 0e6992a | 2015-04-14 20:13:52 +0000 | [diff] [blame] | 211 | h6.appendChild(document.createElement('span')) |
Akron | d67d45b | 2017-05-18 21:47:38 +0200 | [diff] [blame] | 212 | .appendChild(document.createTextNode(layer)); |
| 213 | |
Nils Diewald | 0e6992a | 2015-04-14 20:13:52 +0000 | [diff] [blame] | 214 | var tree = matchtree.appendChild( |
Akron | d67d45b | 2017-05-18 21:47:38 +0200 | [diff] [blame] | 215 | document.createElement('div') |
Nils Diewald | 0e6992a | 2015-04-14 20:13:52 +0000 | [diff] [blame] | 216 | ); |
| 217 | |
| 218 | this._element.insertBefore(matchtree, this._element.lastChild); |
| 219 | |
Akron | c56cf2d | 2016-11-09 22:02:38 +0100 | [diff] [blame] | 220 | var actions = tree.appendChild(document.createElement('ul')); |
| 221 | actions.classList.add('action', 'image'); |
| 222 | var close = actions.appendChild(document.createElement('li')); |
| 223 | close.className = 'close'; |
| 224 | close.appendChild(document.createElement('span')); |
Nils Diewald | 0e6992a | 2015-04-14 20:13:52 +0000 | [diff] [blame] | 225 | close.addEventListener( |
Akron | d67d45b | 2017-05-18 21:47:38 +0200 | [diff] [blame] | 226 | 'click', function (e) { |
| 227 | matchtree.parentNode.removeChild(matchtree); |
| 228 | e.halt(); |
| 229 | } |
Nils Diewald | 0e6992a | 2015-04-14 20:13:52 +0000 | [diff] [blame] | 230 | ); |
| 231 | |
Nils Diewald | 0ec142f | 2015-05-05 00:29:23 +0000 | [diff] [blame] | 232 | tree.classList.add('loading'); |
| 233 | |
Nils Diewald | 0e6992a | 2015-04-14 20:13:52 +0000 | [diff] [blame] | 234 | // Get tree data async |
Akron | 0988d88 | 2017-11-10 16:13:12 +0100 | [diff] [blame] | 235 | this.getTree(foundry, layer, type, function (treeObj) { |
Nils Diewald | 0ec142f | 2015-05-05 00:29:23 +0000 | [diff] [blame] | 236 | |
Akron | d67d45b | 2017-05-18 21:47:38 +0200 | [diff] [blame] | 237 | tree.classList.remove('loading'); |
Nils Diewald | 0ec142f | 2015-05-05 00:29:23 +0000 | [diff] [blame] | 238 | |
Akron | d67d45b | 2017-05-18 21:47:38 +0200 | [diff] [blame] | 239 | // Something went wrong - probably log!!! |
Nils Diewald | 0ec142f | 2015-05-05 00:29:23 +0000 | [diff] [blame] | 240 | |
Akron | d67d45b | 2017-05-18 21:47:38 +0200 | [diff] [blame] | 241 | if (treeObj === null) { |
| 242 | tree.appendChild(document.createTextNode('No data available.')); |
| 243 | } |
| 244 | else { |
| 245 | tree.appendChild(treeObj.element()); |
Akron | 0988d88 | 2017-11-10 16:13:12 +0100 | [diff] [blame] | 246 | treeObj.show(); |
Akron | d67d45b | 2017-05-18 21:47:38 +0200 | [diff] [blame] | 247 | // Reposition the view to the center |
| 248 | // (This may in a future release be a reposition |
| 249 | // to move the root into the center or the actual |
| 250 | // match) |
Akron | c56cf2d | 2016-11-09 22:02:38 +0100 | [diff] [blame] | 251 | |
Akron | 0988d88 | 2017-11-10 16:13:12 +0100 | [diff] [blame] | 252 | // This is currently not supported by relations |
| 253 | if (type === "spans") { |
| 254 | var dl = document.createElement('li'); |
| 255 | dl.className = 'download'; |
| 256 | dl.addEventListener( |
| 257 | 'click', function (e) { |
Akron | c56cf2d | 2016-11-09 22:02:38 +0100 | [diff] [blame] | 258 | |
Akron | 0988d88 | 2017-11-10 16:13:12 +0100 | [diff] [blame] | 259 | var a = document.createElement('a'); |
| 260 | a.setAttribute('href-lang', 'image/svg+xml'); |
| 261 | a.setAttribute('href', 'data:image/svg+xml;base64,'+treeObj.toBase64()); |
| 262 | a.setAttribute('download', 'tree.svg'); |
| 263 | a.target = '_blank'; |
Akron | a27f0d4 | 2017-11-13 14:08:41 +0100 | [diff] [blame] | 264 | a.setAttribute('rel', 'noopener noreferrer'); |
Akron | 0988d88 | 2017-11-10 16:13:12 +0100 | [diff] [blame] | 265 | |
| 266 | document.body.appendChild(a); |
| 267 | a.click(); |
| 268 | document.body.removeChild(a) |
| 269 | e.halt(); |
| 270 | } |
| 271 | ); |
| 272 | |
| 273 | actions.appendChild(dl); |
| 274 | }; |
| 275 | |
Akron | c56cf2d | 2016-11-09 22:02:38 +0100 | [diff] [blame] | 276 | treeObj.center(); |
Akron | d67d45b | 2017-05-18 21:47:38 +0200 | [diff] [blame] | 277 | }; |
| 278 | |
| 279 | if (cb !== undefined) |
| 280 | cb(treeObj); |
Nils Diewald | 0e6992a | 2015-04-14 20:13:52 +0000 | [diff] [blame] | 281 | }); |
| 282 | }, |
Akron | bd34298 | 2018-01-25 18:01:46 +0100 | [diff] [blame] | 283 | |
| 284 | |
Akron | e767969 | 2018-01-26 12:06:33 +0100 | [diff] [blame^] | 285 | // Add meta information to match |
Akron | bd34298 | 2018-01-25 18:01:46 +0100 | [diff] [blame] | 286 | addMeta : function () { |
| 287 | var matchmeta = document.createElement('div'); |
| 288 | // matchRefClass.create(); |
| 289 | |
| 290 | // TODO: This is part of the getMeta! |
| 291 | var metaInfo = this._match.element().getAttribute('data-info'); |
| 292 | |
| 293 | if (metaInfo) |
| 294 | metaInfo = JSON.parse(metaInfo); |
| 295 | |
| 296 | // There is metainfo |
| 297 | if (metaInfo) { |
| 298 | |
| 299 | // Add metainfo to matchview |
| 300 | var metaElem = matchRefClass.create(this._match).element(metaInfo); |
Akron | e767969 | 2018-01-26 12:06:33 +0100 | [diff] [blame^] | 301 | var elem = this.element(); |
Akron | bd34298 | 2018-01-25 18:01:46 +0100 | [diff] [blame] | 302 | |
Akron | e767969 | 2018-01-26 12:06:33 +0100 | [diff] [blame^] | 303 | elem.insertBefore( |
| 304 | metaElem, |
| 305 | elem.firstChild |
| 306 | ); |
| 307 | |
| 308 | console.log(elem); |
Akron | bd34298 | 2018-01-25 18:01:46 +0100 | [diff] [blame] | 309 | }; |
| 310 | }, |
| 311 | |
| 312 | // Add table |
| 313 | addTable : function () { |
| 314 | |
| 315 | var info = this.element(); |
Nils Diewald | 0e6992a | 2015-04-14 20:13:52 +0000 | [diff] [blame] | 316 | |
| 317 | // Append default table |
| 318 | var matchtable = document.createElement('div'); |
Nils Diewald | 0ec142f | 2015-05-05 00:29:23 +0000 | [diff] [blame] | 319 | matchtable.classList.add('matchtable', 'loading'); |
Nils Diewald | 0e6992a | 2015-04-14 20:13:52 +0000 | [diff] [blame] | 320 | info.appendChild(matchtable); |
| 321 | |
| 322 | // Create the table asynchronous |
| 323 | this.getTable(undefined, function (table) { |
Akron | 3bb91bc | 2016-12-02 16:43:17 +0100 | [diff] [blame] | 324 | |
Akron | d67d45b | 2017-05-18 21:47:38 +0200 | [diff] [blame] | 325 | if (table !== null) { |
Akron | 3bb91bc | 2016-12-02 16:43:17 +0100 | [diff] [blame] | 326 | matchtable.appendChild(table.element()); |
| 327 | }; |
Akron | 515851a | 2017-05-02 12:53:17 +0200 | [diff] [blame] | 328 | matchtable.classList.remove('loading'); |
Akron | 99713ef | 2017-06-28 18:19:28 +0200 | [diff] [blame] | 329 | |
| 330 | // Add query creator |
Akron | e8ea000 | 2017-06-28 18:51:52 +0200 | [diff] [blame] | 331 | this._matchCreator = matchQueryCreator.create(info); |
Nils Diewald | 0e6992a | 2015-04-14 20:13:52 +0000 | [diff] [blame] | 332 | }); |
| 333 | |
Akron | bd34298 | 2018-01-25 18:01:46 +0100 | [diff] [blame] | 334 | |
| 335 | info.appendChild(this.addTreeMenu()); |
| 336 | }, |
| 337 | |
| 338 | |
| 339 | addTreeMenu : function () { |
| 340 | |
Akron | d67d45b | 2017-05-18 21:47:38 +0200 | [diff] [blame] | 341 | // Join spans and relations |
| 342 | var treeLayers = [] |
| 343 | var spans = this._match.getSpans(); |
| 344 | var rels = this._match.getRels(); |
| 345 | var i; |
| 346 | for (i in spans) { |
| 347 | treeLayers.push(spans[i]); |
| 348 | }; |
| 349 | for (i in rels) { |
| 350 | treeLayers.push(rels[i]); |
| 351 | }; |
| 352 | |
Nils Diewald | 0e6992a | 2015-04-14 20:13:52 +0000 | [diff] [blame] | 353 | // Get spans |
Akron | d67d45b | 2017-05-18 21:47:38 +0200 | [diff] [blame] | 354 | treeLayers = treeLayers.sort( |
| 355 | function (a, b) { |
| 356 | if (a.foundry < b.foundry) { |
| 357 | return -1; |
| 358 | } |
| 359 | else if (a.foundry > b.foundry) { |
| 360 | return 1; |
| 361 | } |
| 362 | else if (a.layer < b.layer) { |
| 363 | return -1; |
| 364 | } |
| 365 | else if (a.layer > b.layer) { |
| 366 | return 1; |
| 367 | }; |
| 368 | return 0; |
| 369 | }); |
Nils Diewald | 0e6992a | 2015-04-14 20:13:52 +0000 | [diff] [blame] | 370 | |
| 371 | var menuList = []; |
| 372 | |
| 373 | // Show tree views |
Akron | d67d45b | 2017-05-18 21:47:38 +0200 | [diff] [blame] | 374 | for (var i = 0; i < treeLayers.length; i++) { |
| 375 | var span = treeLayers[i]; |
| 376 | |
| 377 | // Add foundry/layer to menu list |
| 378 | menuList.push([ |
| 379 | span.foundry + '/' + span.layer, |
| 380 | span.foundry, |
Akron | 0988d88 | 2017-11-10 16:13:12 +0100 | [diff] [blame] | 381 | span.layer, |
| 382 | span.type |
Akron | d67d45b | 2017-05-18 21:47:38 +0200 | [diff] [blame] | 383 | ]); |
Nils Diewald | 0e6992a | 2015-04-14 20:13:52 +0000 | [diff] [blame] | 384 | }; |
| 385 | |
| 386 | // Create tree menu |
| 387 | var treemenu = this.treeMenu(menuList); |
Akron | bd34298 | 2018-01-25 18:01:46 +0100 | [diff] [blame] | 388 | var span = document.createElement('p'); |
Nils Diewald | 0e6992a | 2015-04-14 20:13:52 +0000 | [diff] [blame] | 389 | span.classList.add('addtree'); |
| 390 | span.appendChild(document.createTextNode(loc.ADDTREE)); |
| 391 | |
| 392 | var treeElement = treemenu.element(); |
| 393 | span.appendChild(treeElement); |
| 394 | |
| 395 | span.addEventListener('click', function (e) { |
Akron | d67d45b | 2017-05-18 21:47:38 +0200 | [diff] [blame] | 396 | treemenu.show(); |
| 397 | treemenu.focus(); |
Nils Diewald | 0e6992a | 2015-04-14 20:13:52 +0000 | [diff] [blame] | 398 | }); |
Akron | bd34298 | 2018-01-25 18:01:46 +0100 | [diff] [blame] | 399 | |
| 400 | return span; |
| 401 | }, |
| 402 | |
| 403 | /** |
| 404 | * Create match information view. |
| 405 | */ |
| 406 | element : function () { |
| 407 | |
| 408 | if (this._element !== undefined) |
| 409 | return this._element; |
| 410 | |
| 411 | // Create info table |
| 412 | var info = document.createElement('div'); |
| 413 | info.classList.add('matchinfo'); |
Nils Diewald | 0e6992a | 2015-04-14 20:13:52 +0000 | [diff] [blame] | 414 | |
| 415 | this._element = info; |
| 416 | |
Akron | bd34298 | 2018-01-25 18:01:46 +0100 | [diff] [blame] | 417 | return this._element; |
Nils Diewald | 0e6992a | 2015-04-14 20:13:52 +0000 | [diff] [blame] | 418 | }, |
| 419 | |
| 420 | |
| 421 | /** |
| 422 | * Get tree menu. |
| 423 | * There is only one menu rendered |
| 424 | * - no matter how many trees exist |
| 425 | */ |
| 426 | treeMenu : function (list) { |
| 427 | if (this._treeMenu !== undefined) |
Akron | d67d45b | 2017-05-18 21:47:38 +0200 | [diff] [blame] | 428 | return this._treeMenu; |
Nils Diewald | 0e6992a | 2015-04-14 20:13:52 +0000 | [diff] [blame] | 429 | |
| 430 | return this._treeMenu = matchTreeMenuClass.create(this, list); |
| 431 | } |
| 432 | }; |
| 433 | }); |