Nils Diewald | 4c22125 | 2015-04-21 20:19:25 +0000 | [diff] [blame] | 1 | /** |
| 2 | * Menu showing all key fields. |
| 3 | */ |
Akron | e4961b1 | 2017-05-10 21:04:46 +0200 | [diff] [blame] | 4 | define(['menu', 'vc/item', 'vc/prefix'], function (menuClass, itemClass, prefixClass) { |
Akron | 0b489ad | 2018-02-02 16:49:32 +0100 | [diff] [blame] | 5 | |
Nils Diewald | 0e6992a | 2015-04-14 20:13:52 +0000 | [diff] [blame] | 6 | return { |
| 7 | create : function (params) { |
Nils Diewald | 7148c6f | 2015-05-04 15:07:53 +0000 | [diff] [blame] | 8 | var obj = Object.create(menuClass) |
Akron | e4961b1 | 2017-05-10 21:04:46 +0200 | [diff] [blame] | 9 | .upgradeTo(this) |
| 10 | ._init(params, { |
| 11 | itemClass : itemClass, |
| 12 | prefixClass : prefixClass |
| 13 | }); |
Nils Diewald | 7148c6f | 2015-05-04 15:07:53 +0000 | [diff] [blame] | 14 | obj.limit(6); |
| 15 | |
| 16 | // This is only domspecific |
| 17 | obj.element().addEventListener('blur', function (e) { |
Akron | e4961b1 | 2017-05-10 21:04:46 +0200 | [diff] [blame] | 18 | this.menu.hide(); |
Nils Diewald | 7148c6f | 2015-05-04 15:07:53 +0000 | [diff] [blame] | 19 | }); |
Akron | e4961b1 | 2017-05-10 21:04:46 +0200 | [diff] [blame] | 20 | |
Nils Diewald | 7148c6f | 2015-05-04 15:07:53 +0000 | [diff] [blame] | 21 | return obj; |
Nils Diewald | 1fcb2ad | 2015-04-20 19:19:18 +0000 | [diff] [blame] | 22 | }, |
Nils Diewald | 4c22125 | 2015-04-21 20:19:25 +0000 | [diff] [blame] | 23 | |
| 24 | /** |
| 25 | * Register callback for click event. |
| 26 | */ |
Nils Diewald | 1fcb2ad | 2015-04-20 19:19:18 +0000 | [diff] [blame] | 27 | released : function (cb) { |
| 28 | this._cb = cb; |
| 29 | }, |
Nils Diewald | 4c22125 | 2015-04-21 20:19:25 +0000 | [diff] [blame] | 30 | |
| 31 | /** |
| 32 | * A click event was released |
| 33 | */ |
| 34 | release : function (key, type) { |
Nils Diewald | 1fcb2ad | 2015-04-20 19:19:18 +0000 | [diff] [blame] | 35 | if (this._cb !== undefined) |
Akron | e4961b1 | 2017-05-10 21:04:46 +0200 | [diff] [blame] | 36 | this._cb(key, type); |
Nils Diewald | 0e6992a | 2015-04-14 20:13:52 +0000 | [diff] [blame] | 37 | } |
| 38 | }; |
| 39 | }); |