blob: c8d7696e09b196442ba14b327223a3eea88de758 [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;
22 t._element = document.createElement('div');
23 t._element.style.display = 'none';
24 t._element.classList.add('alert', 'hint');
25 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;
34 const e = this._element;
35 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;
46 this._element.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 () {
56 return this._element;
57 }
58 }
59});