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

46 lines
1.0 KiB
JavaScript
Raw Normal View History

import util from '../../util.js';
import _ from 'lodash';
import Q from 'q';
export default {
2014-12-07 22:38:24 +00:00
type: 'charset',
2014-12-17 21:04:55 +00:00
definedProperties: {
_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)
};
}
}
},
_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(() => {
util.spaceVertically(this.elements, {
padding: 5
});
2014-12-07 22:38:24 +00:00
2014-12-22 15:57:16 +00:00
return this.renderLabeledBox(this.label, this.partContainer, {
padding: 5
});
2014-12-16 03:00:24 +00:00
});
2014-12-07 22:38:24 +00:00
},
setup() {
2014-12-22 15:57:16 +00:00
this.label = (this.properties.invert.textValue === '^') ? 'None of:' : 'One of:';
this.elements = _.unique(this.properties.parts.elements, part => {
return [part.type, part.textValue].join(':');
});
2014-12-07 22:38:24 +00:00
}
};