blob: bf965d79aa124dcb47807d615e36ad438119d405 [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 {
Nils Diewald7148c6f2015-05-04 15:07:53 +00006
7 /**
8 * Create new hint helper menu.
9 */
Nils Diewald0e6992a2015-04-14 20:13:52 +000010 create : function (hint, context, params) {
11 var obj = Object.create(menuClass)
12 .upgradeTo(this)
13 ._init(itemClass, prefixClass, params);
14 obj._context = context;
15 obj._element.classList.add('hint');
16 obj._hint = hint;
17
18 // This is only domspecific
19 obj.element().addEventListener('blur', function (e) {
20 this.menu.hide();
21 });
22
23 // Focus on input field on hide
24 obj.onHide = function () {
25 var input = this._hint.inputField();
26 input.container().classList.remove('active');
27 input.element().focus();
28 };
29
30 return obj;
31 },
Nils Diewald7148c6f2015-05-04 15:07:53 +000032
33 /**
34 * The hint helper object,
35 * the menu is attached to.
36 */
Nils Diewald0e6992a2015-04-14 20:13:52 +000037 hint : function () {
38 return this._hint;
39 }
40 };
41});