mirror of
https://github.com/publiclab/image-sequencer.git
synced 2025-12-08 09:20:10 +01:00
* text alignment made easy * added description and removed id Co-authored-by: Jeffrey Warren <jeff@unterbahn.com>
37 lines
1.1 KiB
JavaScript
37 lines
1.1 KiB
JavaScript
/**
|
|
* @description Maps module input types to their respective html <input> tag types.
|
|
* @param {Object} inputInfo Object containing the type and optionally min/max for range type inputs.
|
|
*/
|
|
function mapHtmlTypes(inputInfo){
|
|
var htmlType;
|
|
switch(inputInfo.type.toLowerCase()){
|
|
case 'integer':
|
|
htmlType = inputInfo.min != undefined ? 'range' : 'number';
|
|
if (htmlType === 'range') inputInfo.step = inputInfo.step || 1; // default range step size for integer
|
|
break;
|
|
case 'string':
|
|
htmlType = 'text';
|
|
break;
|
|
case 'select':
|
|
htmlType = 'select';
|
|
break;
|
|
case 'percentage':
|
|
htmlType = 'number';
|
|
break;
|
|
case 'float':
|
|
htmlType = inputInfo.min != undefined ? 'range' : 'text';
|
|
if (htmlType === 'range') inputInfo.step = inputInfo.step || 0.1; // default range step size for float
|
|
break;
|
|
case 'coordinate-input':
|
|
htmlType = 'button';
|
|
break;
|
|
default:
|
|
htmlType = 'text';
|
|
break;
|
|
}
|
|
var response = Object.assign({}, inputInfo);
|
|
response.type = htmlType;
|
|
return response;
|
|
}
|
|
|
|
module.exports = mapHtmlTypes; |