1
0
mirror of https://github.com/flarum/core.git synced 2025-08-02 22:47:33 +02:00

Show quote button when post text is selected

closes #19 closes flarum/core#320
This commit is contained in:
Sajjad Hasehmian
2016-04-16 00:44:33 +04:30
committed by Toby Zerner
parent 8c280b0b15
commit a05600b91e
7 changed files with 310 additions and 66 deletions

View File

@@ -0,0 +1,40 @@
import Button from 'flarum/components/Button';
import extract from 'flarum/utils/extract';
import reply from 'flarum/mentions/utils/reply';
export default class PostQuoteButton extends Button {
view() {
const post = extract(this.props, 'post');
const content = extract(this.props, 'content');
this.props.className = 'Button PostQuoteButton';
this.props.icon = 'quote-left';
this.props.children = app.translator.trans('flarum-mentions.forum.post.quote_button');
this.props.onclick = () => {
this.hide();
reply(post, content);
};
this.props.onmousedown = (e) => e.stopPropagation();
return super.view();
}
config(isInitialized) {
if (isInitialized) return;
$(document).on('mousedown', this.hide.bind(this));
}
show(left, top) {
const $this = this.$();
$this.show()
.css('top', top - $this.outerHeight() - 5)
.css('left', left);
}
hide() {
this.$().hide();
}
}