Akron | 00cd4d1 | 2016-05-31 21:01:11 +0200 | [diff] [blame] | 1 | /** |
| 2 | * Hint menu alert |
| 3 | */ |
| 4 | define(function () { |
| 5 | "use strict"; |
| 6 | return { |
| 7 | create : function (msg) { |
| 8 | return Object.create(this)._init(msg); |
| 9 | }, |
| 10 | _init : function (msg) { |
Akron | 02360e4 | 2016-06-07 13:41:12 +0200 | [diff] [blame] | 11 | this._type = 'alert'; |
Akron | 00cd4d1 | 2016-05-31 21:01:11 +0200 | [diff] [blame] | 12 | this.active = false; |
| 13 | this._element = document.createElement('div'); |
| 14 | this._element.style.opacity = 0; |
| 15 | this._element.classList.add('alert', 'hint'); |
| 16 | return this; |
| 17 | }, |
| 18 | show : function (msg) { |
| 19 | this._element.textContent = msg; |
| 20 | this.active = true; |
| 21 | this._element.style.opacity = 1; |
| 22 | }, |
| 23 | |
Akron | 02360e4 | 2016-06-07 13:41:12 +0200 | [diff] [blame] | 24 | hide : function () { |
Akron | 00cd4d1 | 2016-05-31 21:01:11 +0200 | [diff] [blame] | 25 | if (!this.active) |
| 26 | return false; |
| 27 | this._element.style.opacity = 0; |
| 28 | this.active = false; |
| 29 | return true; |
| 30 | }, |
| 31 | |
| 32 | element : function () { |
| 33 | return this._element; |
| 34 | } |
| 35 | } |
| 36 | }); |