FIX: hide quote button when the selection is expanded to more than 1 post
This commit is contained in:
parent
47553f5e57
commit
e3b47a3998
|
@ -18,19 +18,24 @@ export default Ember.Component.extend({
|
|||
|
||||
_selectionChanged() {
|
||||
const selection = window.getSelection();
|
||||
if (selection.isCollapsed) { return; }
|
||||
if (selection.isCollapsed) {
|
||||
if (this.get("visible")) this.sendAction("deselectText");
|
||||
return;
|
||||
}
|
||||
|
||||
// ensure we selected content inside 1 post
|
||||
// ensure we selected content inside 1 post *only*
|
||||
let firstRange, postId;
|
||||
for (let r = 0; r < selection.rangeCount; r++) {
|
||||
const range = selection.getRangeAt(r);
|
||||
firstRange = firstRange || range;
|
||||
|
||||
const $ancestor = $(range.commonAncestorContainer);
|
||||
if ($ancestor.closest(".contents").length === 0) { return; }
|
||||
|
||||
firstRange = firstRange || range;
|
||||
postId = postId || $ancestor.closest('.boxed, .reply').data('post-id');
|
||||
if (!postId) { return; }
|
||||
|
||||
if ($ancestor.closest(".contents").length === 0 || !postId) {
|
||||
if (this.get("visible")) this.sendAction("deselectText");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
this.get("quoteState").setProperties({ postId, buffer: selectedText() });
|
||||
|
|
Loading…
Reference in New Issue