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