widget: clean

This commit is contained in:
jean-emmanuel 2017-05-31 00:01:10 +02:00
parent 000e34e9b7
commit f0ea10da9b
2 changed files with 10 additions and 7 deletions

View file

@ -125,19 +125,14 @@ module.exports.widgets = function(data, parentNode, parentWidget) {
// Backward compatibility patch: path -> address
if (props.path) props.address = props.path
// Genrate default address
props.address = props.address=='auto'?'/' + props.id:props.address
// Generate default address
props.address = props.address == 'auto' ? '/' + props.id : props.address
// Delete unrecognized options
for (let i in props) {
if (defaults[i]===undefined && i!='type') {delete props[i]}
}
if (parentNode.hasClass('strip')) {
delete props.top
delete props.left
}
// create container
var widgetContainer = $(`
<div class="widget ${props.type}-container">

View file

@ -33,9 +33,17 @@ module.exports = class _widgets_base {
this.props.target = [this.props.target]
}
// limit precision
if (this.props.precision) {
this.precision = Math.min(20,Math.max(this.getProp('precision'),0))
}
// strip parent ? no position
if (this.parent && this.parent.props.type == 'strip') {
delete this.props.top
delete this.props.left
}
}
sendValue(overrides) {