Akron | e51eaa3 | 2020-11-10 09:35:53 +0100 | [diff] [blame] | 1 | "use strict"; |
| 2 | |
Akron | 6bb7158 | 2016-06-10 20:41:08 +0200 | [diff] [blame] | 3 | define(['menu/item'], function (itemClass) { |
| 4 | /** |
| 5 | * Menu item for select menus. |
| 6 | */ |
Akron | 6bb7158 | 2016-06-10 20:41:08 +0200 | [diff] [blame] | 7 | return { |
| 8 | |
| 9 | /** |
| 10 | * Create new menu item |
| 11 | * for tree views. |
| 12 | */ |
| 13 | create : function (params) { |
| 14 | return Object.create(itemClass) |
Akron | aba7a5a | 2016-08-15 21:58:33 +0200 | [diff] [blame] | 15 | .upgradeTo(this)._init(params); |
Akron | 6bb7158 | 2016-06-10 20:41:08 +0200 | [diff] [blame] | 16 | }, |
| 17 | |
Akron | 0b489ad | 2018-02-02 16:49:32 +0100 | [diff] [blame] | 18 | |
Akron | 6bb7158 | 2016-06-10 20:41:08 +0200 | [diff] [blame] | 19 | /** |
| 20 | * Override click action of the menu item. |
| 21 | */ |
| 22 | onclick : function (e) { |
| 23 | var menu = this.menu(); |
| 24 | menu.hide(); |
| 25 | // Index was set on initialization |
| 26 | menu.select(this._index); |
| 27 | menu.showTitle(); |
| 28 | e.halt(); |
| 29 | }, |
| 30 | |
Akron | 0b489ad | 2018-02-02 16:49:32 +0100 | [diff] [blame] | 31 | |
| 32 | /** |
| 33 | * Get title of item. |
| 34 | */ |
Akron | 6bb7158 | 2016-06-10 20:41:08 +0200 | [diff] [blame] | 35 | title : function () { |
| 36 | return this.content().textContent; |
| 37 | } |
| 38 | }; |
| 39 | }); |