mirror of
https://github.com/zulip/zulip.git
synced 2025-11-07 15:33:30 +00:00
js: Remove ancient IE createTextRange API.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
committed by
Tim Abbott
parent
fa81ae3aa4
commit
9518545128
@@ -181,8 +181,7 @@ export function initialize() {
|
|||||||
// on the other hand, on mobile it should be done with a long tap.
|
// on the other hand, on mobile it should be done with a long tap.
|
||||||
} else {
|
} else {
|
||||||
$("#main_div").on("longtap", ".messagebox", function (e) {
|
$("#main_div").on("longtap", ".messagebox", function (e) {
|
||||||
// find the correct selection API for the browser.
|
const sel = window.getSelection();
|
||||||
const sel = window.getSelection ? window.getSelection() : document.selection;
|
|
||||||
// if one matches, remove the current selections.
|
// if one matches, remove the current selections.
|
||||||
// after a longtap that is valid, there should be no text selected.
|
// after a longtap that is valid, there should be no text selected.
|
||||||
if (sel) {
|
if (sel) {
|
||||||
|
|||||||
@@ -117,20 +117,12 @@ export function get_active_data() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function selectText(element) {
|
function selectText(element) {
|
||||||
let range;
|
const sel = window.getSelection();
|
||||||
let sel;
|
const range = document.createRange();
|
||||||
if (window.getSelection) {
|
range.selectNodeContents(element);
|
||||||
sel = window.getSelection();
|
|
||||||
range = document.createRange();
|
|
||||||
range.selectNodeContents(element);
|
|
||||||
|
|
||||||
sel.removeAllRanges();
|
sel.removeAllRanges();
|
||||||
sel.addRange(range);
|
sel.addRange(range);
|
||||||
} else if (document.body.createTextRange) {
|
|
||||||
range = document.body.createTextRange();
|
|
||||||
range.moveToElementText(element);
|
|
||||||
range.select();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function should_list_all_streams() {
|
function should_list_all_streams() {
|
||||||
|
|||||||
@@ -11,19 +11,12 @@ export function change_tab_to(tabname) {
|
|||||||
export function place_caret_at_end(el) {
|
export function place_caret_at_end(el) {
|
||||||
el.focus();
|
el.focus();
|
||||||
|
|
||||||
if (window.getSelection !== undefined && document.createRange !== undefined) {
|
const range = document.createRange();
|
||||||
const range = document.createRange();
|
range.selectNodeContents(el);
|
||||||
range.selectNodeContents(el);
|
range.collapse(false);
|
||||||
range.collapse(false);
|
const sel = window.getSelection();
|
||||||
const sel = window.getSelection();
|
sel.removeAllRanges();
|
||||||
sel.removeAllRanges();
|
sel.addRange(range);
|
||||||
sel.addRange(range);
|
|
||||||
} else if (document.body.createTextRange !== undefined) {
|
|
||||||
const textRange = document.body.createTextRange();
|
|
||||||
textRange.moveToElementText(el);
|
|
||||||
textRange.collapse(false);
|
|
||||||
textRange.select();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function blur_active_element() {
|
export function blur_active_element() {
|
||||||
|
|||||||
Reference in New Issue
Block a user