Wait for DOMContentLoaded until checking whether localization should be disabled
Refs https://github.com/AUTOMATIC1111/stable-diffusion-webui/pull/9955#issuecomment-1546587143
This commit is contained in:
parent
9080af56dd
commit
999a03e4a7
|
@ -137,7 +137,11 @@ function download_localization() {
|
||||||
document.body.removeChild(element);
|
document.body.removeChild(element);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(hasLocalization()) {
|
document.addEventListener("DOMContentLoaded", function () {
|
||||||
|
if (!hasLocalization()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
onUiUpdate(function (m) {
|
onUiUpdate(function (m) {
|
||||||
m.forEach(function (mutation) {
|
m.forEach(function (mutation) {
|
||||||
mutation.addedNodes.forEach(function (node) {
|
mutation.addedNodes.forEach(function (node) {
|
||||||
|
@ -146,26 +150,23 @@ if(hasLocalization()) {
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
|
||||||
|
processNode(gradioApp())
|
||||||
|
|
||||||
document.addEventListener("DOMContentLoaded", function () {
|
if (localization.rtl) { // if the language is from right to left,
|
||||||
processNode(gradioApp())
|
(new MutationObserver((mutations, observer) => { // wait for the style to load
|
||||||
|
mutations.forEach(mutation => {
|
||||||
|
mutation.addedNodes.forEach(node => {
|
||||||
|
if (node.tagName === 'STYLE') {
|
||||||
|
observer.disconnect();
|
||||||
|
|
||||||
if (localization.rtl) { // if the language is from right to left,
|
for (const x of node.sheet.rules) { // find all rtl media rules
|
||||||
(new MutationObserver((mutations, observer) => { // wait for the style to load
|
if (Array.from(x.media || []).includes('rtl')) {
|
||||||
mutations.forEach(mutation => {
|
x.media.appendMedium('all'); // enable them
|
||||||
mutation.addedNodes.forEach(node => {
|
|
||||||
if (node.tagName === 'STYLE') {
|
|
||||||
observer.disconnect();
|
|
||||||
|
|
||||||
for (const x of node.sheet.rules) { // find all rtl media rules
|
|
||||||
if (Array.from(x.media || []).includes('rtl')) {
|
|
||||||
x.media.appendMedium('all'); // enable them
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
}
|
||||||
});
|
})
|
||||||
})).observe(gradioApp(), { childList: true });
|
});
|
||||||
}
|
})).observe(gradioApp(), { childList: true });
|
||||||
})
|
}
|
||||||
}
|
})
|
||||||
|
|
Loading…
Reference in New Issue