From ab9c55689eaa383edbb6c61ee68d426211009fde Mon Sep 17 00:00:00 2001 From: Sam Date: Wed, 10 Apr 2013 17:49:25 +1000 Subject: [PATCH] don't error out if no range is selected --- .../discourse/controllers/quote_button_controller.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/assets/javascripts/discourse/controllers/quote_button_controller.js b/app/assets/javascripts/discourse/controllers/quote_button_controller.js index 79acd24b7..5662063b3 100644 --- a/app/assets/javascripts/discourse/controllers/quote_button_controller.js +++ b/app/assets/javascripts/discourse/controllers/quote_button_controller.js @@ -35,8 +35,13 @@ Discourse.QuoteButtonController = Discourse.Controller.extend({ // don't display the "quote-reply" button if we can't create a post if (!this.get('controllers.topic.content.can_create_post')) return; + var selection = window.getSelection(); + + // no selections + if (selection.type !== "Range") return; + // retrieve the selected range - var range = window.getSelection().getRangeAt(0), + var range = selection.getRangeAt(0), cloned = range.cloneRange(), $ancestor = $(range.commonAncestorContainer);