forked from BasicPrimitives/javascript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSize.js
More file actions
45 lines (40 loc) · 1.55 KB
/
Size.js
File metadata and controls
45 lines (40 loc) · 1.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import { ControlType } from './enums';
import { RangeConfig, RangeRender } from './Range';
import { SizeFormatter } from './Formatters';
export function SizeConfig(id, defaultItem, caption, min, max, step, onUpdate) {
this.controlType = ControlType.SizeBox;
this.id = id;
this.defaultItem = defaultItem;
this.caption = caption;
this.min = min;
this.max = max;
this.step = step;
this.onUpdate = onUpdate;
};
export function SizeRender() {
this._render = function (config, namespace, sideName, defaultItem) {
var rangeRender = new RangeRender();
var rangeConfig = new RangeConfig(config.id + "_" + sideName, defaultItem, sideName, config.min, config.max, config.step, config.onUpdate)
return rangeRender.render(rangeConfig, namespace, defaultItem);
}
this.render = function (config, namespace, defaultItem) {
var controlBody = ["p",
{
"title": config.id
},
config.caption,
["br"],
this._render(config, namespace, "Width", defaultItem && defaultItem.width),
this._render(config, namespace, "Height", defaultItem && defaultItem.height)
];
return controlBody;
};
this.getValue = function (item, namespace, formatters) {
var widthElement = document.getElementById(namespace + item.id + "_Width"),
width = widthElement.value,
heightElement = document.getElementById(namespace + item.id + "_Height"),
height = heightElement.value,
result = SizeFormatter(width, height);
return result;
};
};