Akron | c53cfc8 | 2020-10-19 11:00:58 +0200 | [diff] [blame] | 1 | "use strict"; |
2 | |||||
Akron | c744873 | 2016-04-27 14:06:58 +0200 | [diff] [blame] | 3 | define({ |
4 | |||||
5 | /** | ||||
6 | * Create new lengthField object. | ||||
7 | */ | ||||
8 | create : function () { | ||||
9 | return Object.create(this)._init(); | ||||
10 | }, | ||||
11 | |||||
Akron | c53cfc8 | 2020-10-19 11:00:58 +0200 | [diff] [blame] | 12 | |
Akron | c744873 | 2016-04-27 14:06:58 +0200 | [diff] [blame] | 13 | // Initialize lengthField object |
14 | _init : function () { | ||||
Akron | 24aa005 | 2020-11-10 11:00:34 +0100 | [diff] [blame] | 15 | this._el = document.createElement('div'); |
16 | this._el.classList.add('lengthField'); | ||||
Akron | c744873 | 2016-04-27 14:06:58 +0200 | [diff] [blame] | 17 | return this; |
18 | }, | ||||
19 | |||||
Akron | c53cfc8 | 2020-10-19 11:00:58 +0200 | [diff] [blame] | 20 | |
Akron | c744873 | 2016-04-27 14:06:58 +0200 | [diff] [blame] | 21 | /** |
Akron | c744873 | 2016-04-27 14:06:58 +0200 | [diff] [blame] | 22 | * Get the associated dom element. |
23 | */ | ||||
24 | element : function () { | ||||
Akron | 24aa005 | 2020-11-10 11:00:34 +0100 | [diff] [blame] | 25 | return this._el; |
Akron | 1ff3ac2 | 2016-04-28 16:30:45 +0200 | [diff] [blame] | 26 | }, |
27 | |||||
Akron | c53cfc8 | 2020-10-19 11:00:58 +0200 | [diff] [blame] | 28 | |
Akron | 1ff3ac2 | 2016-04-28 16:30:45 +0200 | [diff] [blame] | 29 | /** |
30 | * Add string to lengthField. | ||||
31 | */ | ||||
32 | add : function (param) { | ||||
Akron | 24aa005 | 2020-11-10 11:00:34 +0100 | [diff] [blame] | 33 | this._el.appendChild(document.createElement('span')) |
Akron | 1ff3ac2 | 2016-04-28 16:30:45 +0200 | [diff] [blame] | 34 | .appendChild(document.createTextNode(param[0] + '--')); |
Akron | eaba63e | 2018-01-26 19:49:30 +0100 | [diff] [blame] | 35 | }, |
36 | |||||
Akron | c53cfc8 | 2020-10-19 11:00:58 +0200 | [diff] [blame] | 37 | |
Akron | eaba63e | 2018-01-26 19:49:30 +0100 | [diff] [blame] | 38 | /** |
39 | * Remove all initialized values | ||||
40 | */ | ||||
41 | reset : function () { | ||||
Akron | 24aa005 | 2020-11-10 11:00:34 +0100 | [diff] [blame] | 42 | while (this._el.firstChild) { |
43 | this._el.firstChild.remove(); | ||||
Akron | eaba63e | 2018-01-26 19:49:30 +0100 | [diff] [blame] | 44 | }; |
Akron | c744873 | 2016-04-27 14:06:58 +0200 | [diff] [blame] | 45 | } |
46 | }); |