2014-12-03 02:02:48 +00:00
|
|
|
import _ from 'lodash';
|
2014-12-13 14:09:58 +00:00
|
|
|
import Q from 'q';
|
2014-12-17 16:53:04 +00:00
|
|
|
export default {
|
2014-12-07 22:38:24 +00:00
|
|
|
type: 'charset',
|
|
|
|
|
2014-12-11 00:01:57 +00:00
|
|
|
_render() {
|
2014-12-15 00:08:14 +00:00
|
|
|
this.partContainer = this.container.group();
|
2014-12-07 22:38:24 +00:00
|
|
|
|
2014-12-17 19:44:48 +00:00
|
|
|
return Q.all(_.map(this.elements, part => {
|
2014-12-15 00:08:14 +00:00
|
|
|
return part.render(this.partContainer.group());
|
2014-12-16 03:00:24 +00:00
|
|
|
}))
|
|
|
|
.then(() => {
|
2014-12-17 19:44:48 +00:00
|
|
|
this.spaceVertically(this.elements, {
|
2014-12-13 17:55:03 +00:00
|
|
|
padding: 5
|
|
|
|
});
|
2014-12-07 22:38:24 +00:00
|
|
|
|
2014-12-17 19:44:48 +00:00
|
|
|
return this.renderLabeledBox(this.invert ? 'None of:' : 'One of:', this.partContainer, {
|
2014-12-13 17:55:03 +00:00
|
|
|
padding: 5
|
|
|
|
});
|
2014-12-16 03:00:24 +00:00
|
|
|
});
|
2014-12-07 22:38:24 +00:00
|
|
|
},
|
|
|
|
|
2014-12-17 19:44:48 +00:00
|
|
|
setup() {
|
|
|
|
this.invert = this.properties.invert !== '';
|
|
|
|
this.elements = _.unique(this.properties.parts.elements, part => {
|
|
|
|
if (part.literal) {
|
|
|
|
return part.literal.textValue;
|
|
|
|
} else {
|
|
|
|
return part.textValue;
|
|
|
|
}
|
|
|
|
});
|
2014-12-17 20:24:27 +00:00
|
|
|
|
|
|
|
Object.defineProperty(this, '_anchor', {
|
|
|
|
get: function() {
|
|
|
|
var box = this.container.getBBox(),
|
|
|
|
matrix = this.transform().localMatrix;
|
|
|
|
|
|
|
|
return {
|
|
|
|
ax: box.x,
|
|
|
|
ax2: box.x2,
|
|
|
|
ay: matrix.y(0, this.partContainer.getBBox().cy)
|
|
|
|
};
|
|
|
|
}
|
|
|
|
});
|
2014-12-07 22:38:24 +00:00
|
|
|
}
|
2014-12-17 16:53:04 +00:00
|
|
|
};
|