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

47 lines
1.1 KiB
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() {
2014-12-15 00:08:14 +00:00
this.partContainer = this.container.group();
2014-12-07 22:38:24 +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(() => {
this.spaceVertically(this.elements, {
padding: 5
});
2014-12-07 22:38:24 +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
},
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
}
};