blob: 870d5ba98c4b31f1c2baf88b5f81dea909d20db2 [file] [log] [blame]
Akronc7448732016-04-27 14:06:58 +02001define({
2
3 /**
4 * Create new lengthField object.
5 */
6 create : function () {
7 return Object.create(this)._init();
8 },
9
10 // Initialize lengthField object
11 _init : function () {
12 this._element = document.createElement('div');
13 this._element.classList.add('lengthField');
14 return this;
15 },
16
17 /**
Akron1ff3ac22016-04-28 16:30:45 +020018 * Upgrade this object to another object,
19 * while private data stays intact.
20 *
21 * @param {Object} An object with properties.
Akronc7448732016-04-27 14:06:58 +020022 */
Akron1ff3ac22016-04-28 16:30:45 +020023 upgradeTo : function (props) {
24 for (var prop in props) {
25 this[prop] = props[prop];
26 };
27 return this;
Akronc7448732016-04-27 14:06:58 +020028 },
29
30 /**
31 * Get the associated dom element.
32 */
33 element : function () {
34 return this._element;
Akron1ff3ac22016-04-28 16:30:45 +020035 },
36
37 /**
38 * Add string to lengthField.
39 */
40 add : function (param) {
41 this._element.appendChild(document.createElement('span'))
42 .appendChild(document.createTextNode(param[0] + '--'));
Akroneaba63e2018-01-26 19:49:30 +010043 },
44
45 /**
46 * Remove all initialized values
47 */
48 reset : function () {
49 while (this._element.firstChild) {
50 this._element.firstChild.remove();
51 };
Akronc7448732016-04-27 14:06:58 +020052 }
53});