Simplifying more code
This commit is contained in:
parent
407167a4ae
commit
d216c0fe5f
@ -6,19 +6,19 @@ export default _.extend({}, Base, {
|
||||
type: 'charset-range',
|
||||
|
||||
_render() {
|
||||
var hyphen = this.container.text()
|
||||
.attr({
|
||||
text: '-'
|
||||
});
|
||||
var contents = [
|
||||
this.first,
|
||||
this.container.text()
|
||||
.attr({ text: '-' }),
|
||||
this.last
|
||||
];
|
||||
|
||||
return Q.all([
|
||||
this.first.render(this.container.group()),
|
||||
this.last.render(this.container.group())
|
||||
])
|
||||
.then((() => {
|
||||
this.spaceHorizontally([this.first, hyphen, this.last], {
|
||||
padding: 5
|
||||
});
|
||||
}).bind(this));
|
||||
.then(this.spaceHorizontally.bind(this, contents, {
|
||||
padding: 5
|
||||
}));
|
||||
}
|
||||
});
|
||||
|
@ -13,12 +13,13 @@ export default _.extend({}, Base, {
|
||||
},
|
||||
|
||||
_render() {
|
||||
return this.renderLabel(_.result(this, this.code())).then(label => {
|
||||
label.select('rect').attr({
|
||||
rx: 3,
|
||||
ry: 3
|
||||
return this.renderLabel(_.result(this, this.code()))
|
||||
.then(label => {
|
||||
label.select('rect').attr({
|
||||
rx: 3,
|
||||
ry: 3
|
||||
});
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
// Escape code mappings
|
||||
|
@ -5,11 +5,12 @@ export default _.extend({}, Base, {
|
||||
type: 'literal',
|
||||
|
||||
_render() {
|
||||
return this.renderLabel('"' + this.literal.textValue + '"').then(label => {
|
||||
label.select('rect').attr({
|
||||
rx: 3,
|
||||
ry: 3
|
||||
return this.renderLabel('"' + this.literal.textValue + '"')
|
||||
.then(label => {
|
||||
label.select('rect').attr({
|
||||
rx: 3,
|
||||
ry: 3
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
|
@ -11,15 +11,13 @@ export default _.extend({}, Base, {
|
||||
partPromises;
|
||||
|
||||
if (this.anchorStart()) {
|
||||
start = this.renderLabel('Start of line').then(label => {
|
||||
return label.addClass('anchor');
|
||||
});
|
||||
start = this.renderLabel('Start of line')
|
||||
.invoke('addClass', 'anchor');
|
||||
}
|
||||
|
||||
if (this.anchorEnd()) {
|
||||
end = this.renderLabel('End of line').then(label => {
|
||||
return label.addClass('anchor');
|
||||
});
|
||||
end = this.renderLabel('End of line')
|
||||
.invoke('addClass', 'anchor');
|
||||
}
|
||||
|
||||
if (start || end || parts.length !== 1) {
|
||||
|
Loading…
Reference in New Issue
Block a user