Nils Diewald | 0e6992a | 2015-04-14 20:13:52 +0000 | [diff] [blame] | 1 | /** |
| 2 | * Menu to choose from for tree views. |
| 3 | */ |
| 4 | define(['menu', 'match/treeitem'], function (menuClass, itemClass) { |
| 5 | "use strict"; |
| 6 | |
| 7 | return { |
Nils Diewald | 7148c6f | 2015-05-04 15:07:53 +0000 | [diff] [blame] | 8 | |
| 9 | /** |
| 10 | * Create new menu object. |
| 11 | * Pass the match information object |
| 12 | * and the item parameters. |
| 13 | * |
| 14 | * @param info The match info object |
| 15 | * @param params The match menu items |
| 16 | * as an array of arrays. |
| 17 | */ |
Nils Diewald | 0e6992a | 2015-04-14 20:13:52 +0000 | [diff] [blame] | 18 | create : function (info, params) { |
| 19 | var obj = Object.create(menuClass) |
Akron | d67d45b | 2017-05-18 21:47:38 +0200 | [diff] [blame] | 20 | .upgradeTo(this) |
| 21 | ._init(params, {itemClass : itemClass}); |
Nils Diewald | 0e6992a | 2015-04-14 20:13:52 +0000 | [diff] [blame] | 22 | obj.limit(6); |
| 23 | obj._info = info; |
| 24 | |
| 25 | // This is only domspecific |
| 26 | obj.element().addEventListener('blur', function (e) { |
Akron | d67d45b | 2017-05-18 21:47:38 +0200 | [diff] [blame] | 27 | this.menu.hide(); |
Nils Diewald | 0e6992a | 2015-04-14 20:13:52 +0000 | [diff] [blame] | 28 | }); |
| 29 | |
| 30 | return obj; |
| 31 | }, |
Nils Diewald | 7148c6f | 2015-05-04 15:07:53 +0000 | [diff] [blame] | 32 | |
| 33 | /** |
| 34 | * The match information object of the menu. |
| 35 | */ |
Nils Diewald | 0e6992a | 2015-04-14 20:13:52 +0000 | [diff] [blame] | 36 | info :function () { |
| 37 | return this._info; |
| 38 | } |
| 39 | }; |
| 40 | }); |