Merge pull request #1254 from crob611/master

Prevent 'Quote reply' from appearing when using find in Chrome
This commit is contained in:
Robin Ward 2013-07-26 08:09:08 -07:00
commit d71e7cdfde
1 changed files with 11 additions and 1 deletions

View File

@ -10,6 +10,7 @@ Discourse.QuoteButtonView = Discourse.View.extend({
classNames: ['quote-button'],
classNameBindings: ['visible'],
isMouseDown: false,
isTouchInProgress: false,
/**
Determines whether the pop-up quote button should be visible.
@ -56,9 +57,16 @@ Discourse.QuoteButtonView = Discourse.View.extend({
view.selectText(e.target, controller);
view.set('isMouseDown', false);
})
.on('touchstart.quote-button', function(e){
view.set('isTouchInProgress', true);
})
.on('touchend.quote-button', function(e){
view.set('isTouchInProgress', false);
})
.on('selectionchange', function() {
// there is no need to handle this event when the mouse is down
if (view.get('isMouseDown')) return;
// or if there is not a touch in progress
if (view.get('isMouseDown') || !view.get('isTouchInProgress')) return;
// `selection.anchorNode` is used as a target
view.selectText(window.getSelection().anchorNode, controller);
});
@ -88,6 +96,8 @@ Discourse.QuoteButtonView = Discourse.View.extend({
$(document)
.off("mousedown.quote-button")
.off("mouseup.quote-button")
.off("touchstart.quote-button")
.off("touchend.quote-button")
.off("selectionchange");
},