Merge pull request #792 from ZogStriP/fix-shift-click-to-select-text-does-not-work-in-topics

FIX: Shift+Click to select text does not work in topics
This commit is contained in:
Sam 2013-04-29 19:35:13 -07:00
commit fc56e51cc6
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);