FIX: text was impossible to quote on Windows Phone

This commit is contained in:
Sam 2015-04-30 15:43:39 +10:00
parent f3188ab8f2
commit 9e16e03198
2 changed files with 14 additions and 2 deletions

View File

@ -57,7 +57,7 @@ export default DiscourseController.extend({
// and insert it at the start of our selection range
range.insertNode(markerElement);
// retrieve the position of the market
// retrieve the position of the marker
const markerOffset = $(markerElement).offset(),
$quoteButton = $('.quote-button');

View File

@ -26,6 +26,18 @@ export default Discourse.View.extend({
const controller = this.get('controller'),
view = this;
var onSelectionChanged = function() {
view.selectText(window.getSelection().anchorNode, controller);
};
// Windows Phone hack, it is not firing the touch events
// best we can do is debounce this so we dont keep locking up
// the selection when we add the caret to measure where we place
// the quote reply widget
if (navigator.userAgent.match(/Windows Phone/)) {
onSelectionChanged = _.debounce(onSelectionChanged, 500);
}
$(document)
.on("mousedown.quote-button", function(e) {
view.set('isMouseDown', true);
@ -55,7 +67,7 @@ export default Discourse.View.extend({
// or if there 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);
onSelectionChanged();
});
},