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