De-duplicating code to render subexp and charset containers
This commit is contained in:
@@ -5,18 +5,7 @@ export default _.extend({}, Base, {
|
||||
type: 'charset',
|
||||
|
||||
render() {
|
||||
this.label = this.container.text()
|
||||
.addClass('charset-label')
|
||||
.attr({
|
||||
text: this.invert() ? 'None of:' : 'One of:'
|
||||
});
|
||||
|
||||
this.box = this.container.rect()
|
||||
.addClass('charset-box')
|
||||
.attr({
|
||||
rx: 3,
|
||||
ry: 3
|
||||
});
|
||||
this.renderLabeledBox(this.invert() ? 'None of:' : 'One of:');
|
||||
|
||||
this.partContainer = this.container.group();
|
||||
|
||||
@@ -27,30 +16,14 @@ export default _.extend({}, Base, {
|
||||
},
|
||||
|
||||
position() {
|
||||
var box;
|
||||
|
||||
_.invoke(this.parts.elements, 'position');
|
||||
|
||||
this.spaceVertically(this.parts.elements, {
|
||||
padding: 5
|
||||
});
|
||||
|
||||
box = this.label.getBBox();
|
||||
|
||||
this.label.transform(Snap.matrix()
|
||||
.translate(0, box.height));
|
||||
|
||||
this.partContainer.transform(Snap.matrix()
|
||||
.translate(5, 5 + box.height));
|
||||
|
||||
this.box.transform(Snap.matrix()
|
||||
.translate(0, box.height));
|
||||
|
||||
box = this.partContainer.getBBox();
|
||||
|
||||
this.box.attr({
|
||||
width: box.width + 10,
|
||||
height: box.height + 10
|
||||
this.positionLabeledBox(this.partContainer, {
|
||||
padding: 5
|
||||
});
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user