blob: c579945d6e8ded8b3060d3a55efbd9c894dc0f66 [file] [log] [blame]
Nils Diewald0e6992a2015-04-14 20:13:52 +00001/**
2 * Hint menu
3 */
4define(['menu', 'hint/item', 'hint/prefix'], function (menuClass, itemClass, prefixClass) {
5 return {
6 create : function (hint, context, params) {
7 var obj = Object.create(menuClass)
8 .upgradeTo(this)
9 ._init(itemClass, prefixClass, params);
10 obj._context = context;
11 obj._element.classList.add('hint');
12 obj._hint = hint;
13
14 // This is only domspecific
15 obj.element().addEventListener('blur', function (e) {
16 this.menu.hide();
17 });
18
19 // Focus on input field on hide
20 obj.onHide = function () {
21 var input = this._hint.inputField();
22 input.container().classList.remove('active');
23 input.element().focus();
24 };
25
26 return obj;
27 },
28 // Todo: Is this necessary?
29 context : function () {
30 return this._context;
31 },
32 hint : function () {
33 return this._hint;
34 }
35 };
36});