FIX: Shift+Click to select text does not work in topics

This commit is contained in:
Régis Hanol 2013-04-30 03:16:38 +02:00
parent 50349e84fe
commit 52bad538a1
2 changed files with 6 additions and 2 deletions

View file

@ -45,7 +45,10 @@ Discourse.QuoteButtonController = Discourse.Controller.extend({
// don't display the "quote reply" button if you select text spanning two posts // don't display the "quote reply" button if you select text spanning two posts
// note: the ".contents" is here to prevent selection of the topic summary // note: the ".contents" is here to prevent selection of the topic summary
if ($ancestor.closest('.topic-body > .contents').length === 0) return; if ($ancestor.closest('.topic-body > .contents').length === 0) {
this.set('buffer', '');
return;
}
var selectedText = Discourse.Utilities.selectedText(); var selectedText = Discourse.Utilities.selectedText();
if (this.get('buffer') === selectedText) return; if (this.get('buffer') === selectedText) return;

View file

@ -49,7 +49,8 @@ Discourse.QuoteButtonView = Discourse.View.extend({
view.set('isMouseDown', true); view.set('isMouseDown', true);
if ($(e.target).hasClass('quote-button') || $(e.target).hasClass('create')) return; if ($(e.target).hasClass('quote-button') || $(e.target).hasClass('create')) return;
// deselects only when the user left-click // deselects only when the user left-click
if (e.which === 1) controller.deselectText(); // this also allow anyone to `extend` their selection using a shift+click
if (e.which === 1 && !e.shiftKey) controller.deselectText();
}) })
.on('mouseup.quote-button', function(e) { .on('mouseup.quote-button', function(e) {
view.selectText(e.target, controller); view.selectText(e.target, controller);