diff options
author | Aarni Koskela <akx@iki.fi> | 2023-05-13 12:10:35 +0000 |
---|---|---|
committer | Aarni Koskela <akx@iki.fi> | 2023-05-13 12:12:30 +0000 |
commit | 999a03e4a770217395b5eb8f8165ed0d8ebe5656 (patch) | |
tree | 667896d19a4fe34a5ae3876c02c3f216ac5abf83 /javascript/localization.js | |
parent | 9080af56ddbe4128326a1007ac20bcf214d5b6a7 (diff) | |
download | stable-diffusion-webui-gfx803-999a03e4a770217395b5eb8f8165ed0d8ebe5656.tar.gz stable-diffusion-webui-gfx803-999a03e4a770217395b5eb8f8165ed0d8ebe5656.tar.bz2 stable-diffusion-webui-gfx803-999a03e4a770217395b5eb8f8165ed0d8ebe5656.zip |
Wait for DOMContentLoaded until checking whether localization should be disabled
Refs https://github.com/AUTOMATIC1111/stable-diffusion-webui/pull/9955#issuecomment-1546587143
Diffstat (limited to 'javascript/localization.js')
-rw-r--r-- | javascript/localization.js | 41 |
1 files changed, 21 insertions, 20 deletions
diff --git a/javascript/localization.js b/javascript/localization.js index 0123b877..d0bdfc16 100644 --- a/javascript/localization.js +++ b/javascript/localization.js @@ -137,7 +137,11 @@ function download_localization() { document.body.removeChild(element);
}
-if(hasLocalization()) {
+document.addEventListener("DOMContentLoaded", function () {
+ if (!hasLocalization()) {
+ return;
+ }
+
onUiUpdate(function (m) {
m.forEach(function (mutation) {
mutation.addedNodes.forEach(function (node) {
@@ -146,26 +150,23 @@ if(hasLocalization()) { });
})
+ processNode(gradioApp())
- document.addEventListener("DOMContentLoaded", function () {
- processNode(gradioApp())
+ if (localization.rtl) { // if the language is from right to left,
+ (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,
- (new MutationObserver((mutations, observer) => { // wait for the style to load
- mutations.forEach(mutation => {
- 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
- }
+ 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 });
+ }
+})
|