mirror of
https://github.com/zulip/zulip.git
synced 2025-11-04 05:53:43 +00:00
This commit was originally automatically generated using `tools/lint --only=eslint --fix`. It was then modified by tabbott to contain only changes to a set of files that are unlikely to result in significant merge conflicts with any open pull request, excluding about 20 files. His plan is to merge the remaining changes with more precise care, potentially involving merging parts of conflicting pull requests before running the `eslint --fix` operation. Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
34 lines
1.1 KiB
JavaScript
34 lines
1.1 KiB
JavaScript
// Add functions to this that have no non-trivial
|
|
// dependencies other than jQuery.
|
|
|
|
exports.change_tab_to = function (tabname) {
|
|
$('#gear-menu a[href="' + tabname + '"]').tab('show');
|
|
};
|
|
|
|
// http://stackoverflow.com/questions/4233265/contenteditable-set-caret-at-the-end-of-the-text-cross-browser
|
|
exports.place_caret_at_end = function (el) {
|
|
el.focus();
|
|
|
|
if (typeof window.getSelection !== "undefined"
|
|
&& typeof document.createRange !== "undefined") {
|
|
const range = document.createRange();
|
|
range.selectNodeContents(el);
|
|
range.collapse(false);
|
|
const sel = window.getSelection();
|
|
sel.removeAllRanges();
|
|
sel.addRange(range);
|
|
} else if (typeof document.body.createTextRange !== "undefined") {
|
|
const textRange = document.body.createTextRange();
|
|
textRange.moveToElementText(el);
|
|
textRange.collapse(false);
|
|
textRange.select();
|
|
}
|
|
};
|
|
|
|
exports.blur_active_element = function () {
|
|
// this blurs anything that may perhaps be actively focused on.
|
|
document.activeElement.blur();
|
|
};
|
|
|
|
window.ui_util = exports;
|