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