js: Remove ancient IE createTextRange API.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg
2021-06-25 13:56:06 -07:00
committed by Tim Abbott
parent fa81ae3aa4
commit 9518545128
3 changed files with 12 additions and 28 deletions

View File

@@ -181,8 +181,7 @@ export function initialize() {
// on the other hand, on mobile it should be done with a long tap.
} else {
$("#main_div").on("longtap", ".messagebox", function (e) {
// find the correct selection API for the browser.
const sel = window.getSelection ? window.getSelection() : document.selection;
const sel = window.getSelection();
// if one matches, remove the current selections.
// after a longtap that is valid, there should be no text selected.
if (sel) {

View File

@@ -117,20 +117,12 @@ export function get_active_data() {
}
function selectText(element) {
let range;
let sel;
if (window.getSelection) {
sel = window.getSelection();
range = document.createRange();
range.selectNodeContents(element);
const sel = window.getSelection();
const range = document.createRange();
range.selectNodeContents(element);
sel.removeAllRanges();
sel.addRange(range);
} else if (document.body.createTextRange) {
range = document.body.createTextRange();
range.moveToElementText(element);
range.select();
}
sel.removeAllRanges();
sel.addRange(range);
}
function should_list_all_streams() {

View File

@@ -11,19 +11,12 @@ export function change_tab_to(tabname) {
export function place_caret_at_end(el) {
el.focus();
if (window.getSelection !== undefined && document.createRange !== undefined) {
const range = document.createRange();
range.selectNodeContents(el);
range.collapse(false);
const sel = window.getSelection();
sel.removeAllRanges();
sel.addRange(range);
} else if (document.body.createTextRange !== undefined) {
const textRange = document.body.createTextRange();
textRange.moveToElementText(el);
textRange.collapse(false);
textRange.select();
}
const range = document.createRange();
range.selectNodeContents(el);
range.collapse(false);
const sel = window.getSelection();
sel.removeAllRanges();
sel.addRange(range);
}
export function blur_active_element() {