blob: 7847af20a8af989d91871853814046f80cd3b7e1 [file] [log] [blame]
Akron00cd4d12016-05-31 21:01:11 +02001/**
Akronda5bd3a2020-10-16 17:37:49 +02002 * Hint menu alert, positioned at the exact char.
Akron00cd4d12016-05-31 21:01:11 +02003 */
Akronda5bd3a2020-10-16 17:37:49 +02004"use strict";
5
Akron00cd4d12016-05-31 21:01:11 +02006define(function () {
Akronda5bd3a2020-10-16 17:37:49 +02007
Akron00cd4d12016-05-31 21:01:11 +02008 return {
Akronda5bd3a2020-10-16 17:37:49 +02009
10 /**
11 * Construct a new alert object
12 */
Akron00cd4d12016-05-31 21:01:11 +020013 create : function (msg) {
14 return Object.create(this)._init(msg);
15 },
Akronda5bd3a2020-10-16 17:37:49 +020016
17 // Init
Akron00cd4d12016-05-31 21:01:11 +020018 _init : function (msg) {
Akronda5bd3a2020-10-16 17:37:49 +020019 const t = this;
20 t._type = 'alert';
21 t.active = false;
Akron24aa0052020-11-10 11:00:34 +010022 t._el = document.createElement('div');
23 t._el.style.display = 'none';
24 t._el.classList.add('alert', 'hint');
Akronda5bd3a2020-10-16 17:37:49 +020025 return t;
Akron00cd4d12016-05-31 21:01:11 +020026 },
27
Akronda5bd3a2020-10-16 17:37:49 +020028
29 /**
30 * Show alert.
31 */
32 show : function (msg) {
33 this.active = true;
Akron24aa0052020-11-10 11:00:34 +010034 const e = this._el;
Akronda5bd3a2020-10-16 17:37:49 +020035 e.textContent = msg;
36 e.style.display = 'block';
37 },
38
39
40 /**
41 * Hide alert.
42 */
Akron02360e42016-06-07 13:41:12 +020043 hide : function () {
Akron00cd4d12016-05-31 21:01:11 +020044 if (!this.active)
Akrond30e2002016-11-07 03:19:58 +010045 return false;
Akron24aa0052020-11-10 11:00:34 +010046 this._el.style.display = 'none';
Akron00cd4d12016-05-31 21:01:11 +020047 this.active = false;
48 return true;
49 },
50
Akronda5bd3a2020-10-16 17:37:49 +020051
52 /**
53 * Get alert object.
54 */
Akron00cd4d12016-05-31 21:01:11 +020055 element : function () {
Akron24aa0052020-11-10 11:00:34 +010056 return this._el;
Akron00cd4d12016-05-31 21:01:11 +020057 }
58 }
59});