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

44 lines
1.0 KiB
JavaScript
Raw Normal View History

import _ from 'lodash';
import Base from './base.js';
export default _.extend({}, Base, {
type: 'match-fragment',
_render() {
if (this._repeat.textValue === '') {
this.proxy(this._content);
} else {
this._content.render(this.container.group());
}
},
_position() {
var box, paths = [];
this._content.position();
2014-12-11 01:28:02 +00:00
this._content.transform(this._repeat.contentPosition());
box = this._content.getBBox();
if (this._repeat.hasSkip()) {
2014-12-11 00:09:31 +00:00
paths.push(Snap.format('M0,{box.cy}q10,0 10,-10v-{vert}q0,-10 10,-10h{horiz}q10,0 10,10v{vert}q0,10 10,10', {
box,
vert: box.height / 2 - 10,
horiz: box.width - 10
2014-12-11 00:09:31 +00:00
}));
}
if (this._repeat.hasLoop()) {
2014-12-11 00:09:31 +00:00
paths.push(Snap.format('M{box.x},{box.cy}q-10,0 -10,10v{vert}q0,10 10,10h{box.width}q10,0 10,-10v-{vert}q0,-10 -10,-10', {
box,
vert: box.height / 2 - 10
2014-12-11 00:09:31 +00:00
}));
}
if (paths.length) {
2014-12-11 00:09:31 +00:00
this.container.prepend(
this.container.path(paths.join('')));
}
}
});