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

52 lines
868 B
JavaScript
Raw Normal View History

export default {
render(container) {
2014-11-30 18:14:31 +00:00
container.attr({ 'class': 'placeholder' });
this.rect = container.rect().attr({
rx: 10,
2014-11-30 18:14:31 +00:00
ry: 10
});
2014-11-30 18:14:31 +00:00
this.text = container.text().attr({
text: this.textValue
});
},
position() {
2014-11-30 18:14:31 +00:00
var box = this.text.getBBox(),
margin = 5;
2014-11-30 18:14:31 +00:00
this.text.transform(Snap.matrix()
.translate(margin, box.height + margin));
this.rect.attr({
2014-11-30 18:14:31 +00:00
width: box.width + 2 * margin,
height: box.height + 2 * margin
});
},
flags() {
var flags;
if (this.fl) {
flags = this.fl.textValue;
} else {
flags = '';
}
return {
global: /g/.test(flags),
ignore_case: /i/.test(flags),
multiline: /m/.test(flags)
};
},
expression() {
if (this.regexp) {
return this.regexp;
} else {
return this;
}
}
};