From d25d1f777cc1cbeb000c2e7dc46c69ca7255995e Mon Sep 17 00:00:00 2001 From: Corey Robertson Date: Thu, 25 Jul 2013 22:57:03 -0500 Subject: [PATCH] Prevent 'Quote reply' from appearing when using find in Chrome --- .../javascripts/discourse/views/quote_button_view.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/app/assets/javascripts/discourse/views/quote_button_view.js b/app/assets/javascripts/discourse/views/quote_button_view.js index 905080cec71..f7c4378b5ad 100644 --- a/app/assets/javascripts/discourse/views/quote_button_view.js +++ b/app/assets/javascripts/discourse/views/quote_button_view.js @@ -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"); },