mirror of
https://github.com/discourse/discourse.git
synced 2024-11-28 11:25:45 +08:00
Prevent 'Quote reply' from appearing when using find in Chrome
This commit is contained in:
parent
cc79d22f82
commit
d25d1f777c
|
@ -10,6 +10,7 @@ Discourse.QuoteButtonView = Discourse.View.extend({
|
||||||
classNames: ['quote-button'],
|
classNames: ['quote-button'],
|
||||||
classNameBindings: ['visible'],
|
classNameBindings: ['visible'],
|
||||||
isMouseDown: false,
|
isMouseDown: false,
|
||||||
|
isTouchInProgress: false,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Determines whether the pop-up quote button should be visible.
|
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.selectText(e.target, controller);
|
||||||
view.set('isMouseDown', false);
|
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() {
|
.on('selectionchange', function() {
|
||||||
// there is no need to handle this event when the mouse is down
|
// 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
|
// `selection.anchorNode` is used as a target
|
||||||
view.selectText(window.getSelection().anchorNode, controller);
|
view.selectText(window.getSelection().anchorNode, controller);
|
||||||
});
|
});
|
||||||
|
@ -88,6 +96,8 @@ Discourse.QuoteButtonView = Discourse.View.extend({
|
||||||
$(document)
|
$(document)
|
||||||
.off("mousedown.quote-button")
|
.off("mousedown.quote-button")
|
||||||
.off("mouseup.quote-button")
|
.off("mouseup.quote-button")
|
||||||
|
.off("touchstart.quote-button")
|
||||||
|
.off("touchend.quote-button")
|
||||||
.off("selectionchange");
|
.off("selectionchange");
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user