better units / round handling. fix ruler in inches
This commit is contained in:
parent
622ad01c87
commit
2118098be9
5 changed files with 27 additions and 20 deletions
|
|
@ -1499,8 +1499,8 @@
|
|||
|
||||
device: UC.newGroup(LANG.dv_gr_dev, $('device1'), {group:"ddev", inline:true, class:"noshow"}),
|
||||
deviceName: UC.newInput(LANG.dv_name_s, {title:LANG.dv_name_l, size:"65%", text:true, action:updateDeviceName}),
|
||||
bedWidth: UC.newInput(LANG.dv_bedw_s, {title:LANG.dv_bedw_l, convert:UC.toFloat, size:6, units:true}),
|
||||
bedDepth: UC.newInput(LANG.dv_bedd_s, {title:LANG.dv_bedd_l, convert:UC.toFloat, size:6, units:true}),
|
||||
bedWidth: UC.newInput(LANG.dv_bedw_s, {title:LANG.dv_bedw_l, convert:UC.toFloat, size:6, units:true, round:2}),
|
||||
bedDepth: UC.newInput(LANG.dv_bedd_s, {title:LANG.dv_bedd_l, convert:UC.toFloat, size:6, units:true, round:2}),
|
||||
maxHeight: UC.newInput(LANG.dv_bedh_s, {title:LANG.dv_bedh_l, convert:UC.toFloat, size:6, modes:FDM_SLA}),
|
||||
spindleMax: UC.newInput(LANG.dv_spmx_s, {title:LANG.dv_spmx_l, convert:UC.toInt, size: 6, modes:CAM}),
|
||||
deviceOrigin: UC.newBoolean(LANG.dv_orgc_s, onBooleanClick, {title:LANG.dv_orgc_l, modes:FDM_LASER_SLA}),
|
||||
|
|
|
|||
|
|
@ -379,10 +379,13 @@
|
|||
function toFloat() {
|
||||
let nv = this.value !== '' ? parseFloat(this.value) : null;
|
||||
if (nv !== null && this.bound) nv = this.bound(nv);
|
||||
this.value = nv;
|
||||
// this.value = nv;
|
||||
if (this.setv) {
|
||||
return this.real = nv * units;
|
||||
};
|
||||
return this.setv(nv * units);
|
||||
// return this.real = (nv * units);
|
||||
} else {
|
||||
this.value = nv;
|
||||
}
|
||||
return nv;
|
||||
}
|
||||
|
||||
|
|
@ -686,7 +689,7 @@
|
|||
}
|
||||
});
|
||||
if (opt.units) {
|
||||
addUnits(ip);
|
||||
addUnits(ip, opt.round || 3);
|
||||
}
|
||||
}
|
||||
if (!ip.convert) ip.convert = raw.bind(ip);
|
||||
|
|
@ -695,15 +698,16 @@
|
|||
return ip;
|
||||
}
|
||||
|
||||
function addUnits(input) {
|
||||
function addUnits(input, round) {
|
||||
setters.push(input);
|
||||
input.setv = function(value) {
|
||||
if (typeof(value) === 'number') {
|
||||
input.real = value;
|
||||
input.value = value / units;
|
||||
input.value = (value / units).round(round);
|
||||
} else {
|
||||
input.value = value;
|
||||
}
|
||||
return input.real;
|
||||
};
|
||||
return input;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue