regexper-static/src/js/parser/javascript/charset.js

47 lines
987 B
JavaScript
Raw Normal View History

import _ from 'lodash';
import Q from 'q';
export default {
2014-12-07 22:38:24 +00:00
type: 'charset',
_render() {
var elements = _.unique(this.parts.elements, part => {
if (part.literal) {
return part.literal.textValue;
} else {
return part.textValue;
}
});
2014-12-15 00:08:14 +00:00
this.partContainer = this.container.group();
2014-12-07 22:38:24 +00:00
2014-12-16 03:00:24 +00:00
return Q.all(_.map(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(() => {
this.spaceVertically(elements, {
padding: 5
});
2014-12-07 22:38:24 +00:00
2014-12-15 00:08:14 +00:00
return this.renderLabeledBox(this.invert() ? 'None of:' : 'One of:', this.partContainer, {
padding: 5
});
2014-12-16 03:00:24 +00:00
});
2014-12-07 22:38:24 +00:00
},
2014-12-15 00:08:14 +00:00
_getAnchor() {
var box = this.container.getBBox(),
matrix = this.transform().localMatrix;
2014-12-15 00:08:14 +00:00
return {
atype: this.type,
ax: box.x,
ax2: box.x2,
2014-12-15 00:08:14 +00:00
ay: matrix.y(0, this.partContainer.getBBox().cy)
};
2014-12-15 00:08:14 +00:00
},
2014-12-07 22:38:24 +00:00
invert() {
return this._invert.textValue !== '';
}
};