2014-11-26 23:24:40 +00:00
|
|
|
export default {
|
2014-11-30 15:48:33 +00:00
|
|
|
render(container) {
|
2014-11-30 18:14:31 +00:00
|
|
|
container.attr({ 'class': 'placeholder' });
|
|
|
|
|
|
|
|
this.rect = container.rect().attr({
|
2014-11-30 15:48:33 +00:00
|
|
|
rx: 10,
|
2014-11-30 18:14:31 +00:00
|
|
|
ry: 10
|
2014-11-30 15:48:33 +00:00
|
|
|
});
|
2014-11-30 18:14:31 +00:00
|
|
|
|
|
|
|
this.text = container.text().attr({
|
|
|
|
text: this.textValue
|
2014-11-30 15:48:33 +00:00
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
position() {
|
2014-11-30 18:14:31 +00:00
|
|
|
var box = this.text.getBBox(),
|
|
|
|
margin = 5;
|
2014-11-30 15:48:33 +00:00
|
|
|
|
2014-11-30 18:14:31 +00:00
|
|
|
this.text.transform(Snap.matrix()
|
|
|
|
.translate(margin, box.height + margin));
|
2014-11-30 15:48:33 +00:00
|
|
|
|
|
|
|
this.rect.attr({
|
2014-11-30 18:14:31 +00:00
|
|
|
width: box.width + 2 * margin,
|
|
|
|
height: box.height + 2 * margin
|
2014-11-30 15:48:33 +00:00
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2014-11-26 23:24:40 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|