Fix some 'quote reply' button quirks

This commit is contained in:
Régis Hanol 2013-04-02 10:35:22 +02:00
parent effb440de0
commit dd4f24919f
2 changed files with 12 additions and 1 deletions

View File

@ -64,7 +64,10 @@ Discourse.QuoteButtonController = Discourse.Controller.extend({
// move the quote button at the beginning of the selection
var $quoteButton = $('.quote-button');
$quoteButton.css({ top: top - $quoteButton.outerHeight(), left: left });
$quoteButton.css({
top: top - $quoteButton.outerHeight() - 5,
left: left
});
// remove the marker
markerElement.parentNode.removeChild(markerElement);

View File

@ -43,6 +43,10 @@ Discourse.PostView = Discourse.View.extend({
this.set('context', this.get('content'));
},
mouseDown: function(e) {
this.set('isMouseDown', true);
},
mouseUp: function(e) {
if (this.get('controller.multiSelect') && (e.metaKey || e.ctrlKey)) {
this.toggleProperty('post.selected');
@ -56,6 +60,8 @@ Discourse.PostView = Discourse.View.extend({
e.context = this.get('post');
qbc.selectText(e);
}
this.set('isMouseDown', false);
},
selectText: (function() {
@ -260,6 +266,8 @@ Discourse.PostView = Discourse.View.extend({
$(document).on('selectionchange', function(e) {
// quoting as been disabled by the user
if (!Discourse.get('currentUser.enable_quoting')) return;
// there is no need to handle this event when the mouse is down
if (postView.get('isMouseDown')) return;
// find out whether we currently are selecting inside a post
var closestPosts = $(window.getSelection().anchorNode).closest('.topic-post');
if (closestPosts.length === 0) return;