DEV: Remove JQuery from discourse/lib/text-direction (#15014)
This commit is contained in:
parent
9955f1774d
commit
254689b1fb
|
@ -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",
|
||||
});
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue