DEV: Remove JQuery from discourse/lib/text-direction (#15014)

This commit is contained in:
David Taylor 2021-11-19 01:09:36 +00:00 committed by GitHub
parent 9955f1774d
commit 254689b1fb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 9 deletions

View File

@ -32,7 +32,7 @@ export default {
);
api.decorateCookedElement(lightbox, { id: "discourse-lightbox" });
if (siteSettings.support_mixed_text_direction) {
api.decorateCooked(setTextDirections, {
api.decorateCookedElement(setTextDirections, {
id: "discourse-text-direction",
});
}

View File

@ -13,19 +13,19 @@ export function isLTR(text) {
return ltrDirCheck.test(text);
}
export function setTextDirections($elem) {
$elem.find("*").each((i, e) => {
let $e = $(e),
textContent = $e.text();
if (textContent) {
isRTL(textContent) ? $e.attr("dir", "rtl") : $e.attr("dir", "ltr");
export function setTextDirections(elem) {
for (let e of elem.children) {
if (e.textContent) {
e.setAttribute("dir", isRTL(e.textContent) ? "rtl" : "ltr");
}
});
}
}
export function siteDir() {
if (!_siteDir) {
_siteDir = $("html").hasClass("rtl") ? "rtl" : "ltr";
_siteDir = document.documentElement.classList.contains("rtl")
? "rtl"
: "ltr";
}
return _siteDir;
}