Merge pull request #621 from ZogStriP/fix-some-quote-reply-button-quirks

Fix some 'quote reply' button quirks
This commit is contained in:
Sam 2013-04-02 01:41:50 -07:00
commit 9bb950ab37
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;