when clicking the reply button, limit the selection to the post's

content.
v1.18.x
Ben Lubar 9 years ago
parent 87bd0c69d7
commit c50f228acc

@ -199,13 +199,23 @@ define('forum/topic/postTools', ['share', 'navigator', 'components', 'translator
if (!proceed) {
var selectionText = '';
var selection = window.getSelection ? window.getSelection() : document.selection.createRange();
var selectionNode = $(selection.baseNode || selection.anchorNode);
if (selectionNode.parents('[component="post/content"]').length > 0) {
selectionText = selection.toString();
var content = button.parents('[component="post"]').find('[component="post/content"]').get(0);
if (selection.containsNode(content, true)) {
var bounds = document.createRange();
bounds.selectNodeContents(content);
var range = selection.getRangeAt(0).cloneRange();
if (range.compareBoundaryPoints(Range.START_TO_START, bounds) < 0) {
range.setStart(bounds.startContainer, bounds.startOffset);
}
if (range.compareBoundaryPoints(Range.END_TO_END, bounds) > 0) {
range.setEnd(bounds.endContainer, bounds.endOffset);
}
bounds.detach();
selectionText = range.toString();
range.detach();
}
button = selectionText ? selectionNode : button;
var username = getUserName(button);
if (getData(button, 'data-uid') === '0' || !getData(button, 'data-userslug')) {
username = '';

Loading…
Cancel
Save