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