1
0
mirror of https://github.com/flarum/core.git synced 2025-07-29 20:50:28 +02:00

Support quote button on mobile; make reply button behaviour consistent

closes flarum/core#972
This commit is contained in:
Toby Zerner
2016-06-03 11:24:33 +09:30
parent 999ef82d55
commit bfa9a1d68e
3 changed files with 28 additions and 30 deletions

View File

@@ -660,7 +660,7 @@ System.register('flarum/mentions/addPostQuoteButton', ['flarum/extend', 'flarum/
// button into it. // button into it.
var $container = $('<div class="Post-quoteButtonContainer"></div>'); var $container = $('<div class="Post-quoteButtonContainer"></div>');
this.$().after($container).on('mouseup', function (e) { var handler = function handler(e) {
setTimeout(function () { setTimeout(function () {
var content = selectedText($postBody); var content = selectedText($postBody);
if (content) { if (content) {
@@ -678,7 +678,10 @@ System.register('flarum/mentions/addPostQuoteButton', ['flarum/extend', 'flarum/
} }
} }
}, 1); }, 1);
}); };
this.$().after($container).on('mouseup', handler);
document.addEventListener('selectionchange', handler, false);
}); });
} }
@@ -699,14 +702,13 @@ System.register('flarum/mentions/addPostQuoteButton', ['flarum/extend', 'flarum/
});; });;
'use strict'; 'use strict';
System.register('flarum/mentions/addPostReplyAction', ['flarum/extend', 'flarum/components/Button', 'flarum/components/CommentPost', 'flarum/mentions/utils/reply', 'flarum/mentions/utils/selectedText'], function (_export, _context) { System.register('flarum/mentions/addPostReplyAction', ['flarum/extend', 'flarum/components/Button', 'flarum/components/CommentPost', 'flarum/mentions/utils/reply'], function (_export, _context) {
"use strict"; "use strict";
var extend, Button, CommentPost, reply, selectedText; var extend, Button, CommentPost, reply;
_export('default', function () { _export('default', function () {
extend(CommentPost.prototype, 'actionItems', function (items) { extend(CommentPost.prototype, 'actionItems', function (items) {
var _this = this;
var post = this.props.post; var post = this.props.post;
@@ -716,7 +718,7 @@ System.register('flarum/mentions/addPostReplyAction', ['flarum/extend', 'flarum/
className: 'Button Button--link', className: 'Button Button--link',
children: app.translator.trans('flarum-mentions.forum.post.reply_link'), children: app.translator.trans('flarum-mentions.forum.post.reply_link'),
onclick: function onclick() { onclick: function onclick() {
reply(post, selectedText(_this.$('.Post-body'))); return reply(post);
} }
})); }));
}); });
@@ -731,8 +733,6 @@ System.register('flarum/mentions/addPostReplyAction', ['flarum/extend', 'flarum/
CommentPost = _flarumComponentsCommentPost.default; CommentPost = _flarumComponentsCommentPost.default;
}, function (_flarumMentionsUtilsReply) { }, function (_flarumMentionsUtilsReply) {
reply = _flarumMentionsUtilsReply.default; reply = _flarumMentionsUtilsReply.default;
}, function (_flarumMentionsUtilsSelectedText) {
selectedText = _flarumMentionsUtilsSelectedText.default;
}], }],
execute: function () {} execute: function () {}
}; };

View File

@@ -16,9 +16,7 @@ export default function addPostQuoteButton() {
// button into it. // button into it.
const $container = $('<div class="Post-quoteButtonContainer"></div>'); const $container = $('<div class="Post-quoteButtonContainer"></div>');
this.$() const handler = function(e) {
.after($container)
.on('mouseup', function(e) {
setTimeout(() => { setTimeout(() => {
const content = selectedText($postBody); const content = selectedText($postBody);
if (content) { if (content) {
@@ -36,6 +34,9 @@ export default function addPostQuoteButton() {
} }
} }
}, 1); }, 1);
}); };
this.$().after($container).on('mouseup', handler);
document.addEventListener('selectionchange', handler, false);
}); });
} }

View File

@@ -3,7 +3,6 @@ import Button from 'flarum/components/Button';
import CommentPost from 'flarum/components/CommentPost'; import CommentPost from 'flarum/components/CommentPost';
import reply from 'flarum/mentions/utils/reply'; import reply from 'flarum/mentions/utils/reply';
import selectedText from 'flarum/mentions/utils/selectedText';
export default function () { export default function () {
extend(CommentPost.prototype, 'actionItems', function (items) { extend(CommentPost.prototype, 'actionItems', function (items) {
@@ -16,9 +15,7 @@ export default function () {
Button.component({ Button.component({
className: 'Button Button--link', className: 'Button Button--link',
children: app.translator.trans('flarum-mentions.forum.post.reply_link'), children: app.translator.trans('flarum-mentions.forum.post.reply_link'),
onclick: () => { onclick: () => reply(post)
reply(post, selectedText(this.$('.Post-body')));
}
}) })
); );
}); });