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

52 lines
1.1 KiB
JavaScript
Raw Normal View History

import _ from 'lodash';
import Base from './base.js';
export default _.extend({}, Base, {
type: 'root',
_render() {
2014-12-04 01:20:08 +00:00
this.start = this.container.circle()
.addClass('pin')
.attr({ r: 5 });
this.end = this.container.circle()
.addClass('pin')
.attr({ r: 5 });
return this.regexp.render(this.container.group())
.then((() => {
var contentBox;
this.regexp.transform(Snap.matrix()
.translate(10, 0));
contentBox = this.regexp.getBBox();
this.start.transform(Snap.matrix()
2014-12-15 00:29:45 +00:00
.translate(0, contentBox.ay));
this.end.transform(Snap.matrix()
2014-12-15 00:29:45 +00:00
.translate(contentBox.x2 + 10, contentBox.ay));
2014-12-15 02:37:56 +00:00
this.container.prepend(
this.container.path(Snap.format('M{box.ax},{box.ay}H0M{box.ax2},{box.ay}H{box.x2}h10', {
box: contentBox
})));
}).bind(this));
},
flags() {
var flags;
if (this._flags) {
flags = this._flags.textValue;
} else {
flags = '';
}
return {
global: /g/.test(flags),
ignore_case: /i/.test(flags),
multiline: /m/.test(flags)
};
}
});