modernui fixes

Signed-off-by: Vladimir Mandic <mandic00@live.com>
This commit is contained in:
Vladimir Mandic
2025-02-13 09:10:55 -05:00
parent 9ce34b4c8c
commit 00be489030
4 changed files with 17 additions and 17 deletions
+1 -1
View File
@@ -132,7 +132,7 @@ div#extras_scale_to_tab div.form { flex-direction: row; }
width: 22em; min-height: 1.3em; font-size: var(--text-xs); transition: opacity 0.2s ease-in; pointer-events: none; opacity: 0; z-index: 999; }
.tooltip-show { opacity: 0.9; }
.toolbutton-selected { background: var(--background-fill-primary) !important; }
.locale { position: fixed; top: 1em; right: 1em; background-color: none; padding: 0.1em; width: 1.2em; height: 1.2em; cursor: pointer; font-size: 0.8em; font-weight: 800; font-family: monospace; }
.locale { position: fixed; top: 0.5em; right: 0.5em; background-color: var(--input-background-fill); color: var(--body-text-color); padding: 0.1em; width: 1.2em; height: 1.2em; cursor: pointer; font-size: 0.8em; font-weight: 800; font-family: monospace; opacity: 50%; }
#txt2img_hdr_color_row > div { min-width: unset !important; max-width: unset !important; }
#txt2img_advanced_options, #img2img_advanced_options, #control_advanced_options { min-width: 100%; }
#txt2img_advanced_options .gradio-checkbox, #img2img_advanced_options .gradio-checkbox, #control_advanced_options .gradio-checkbox { min-width: unset !important; max-width: fit-content; }
+14 -14
View File
@@ -5,6 +5,7 @@ const localeData = {
data: [],
timeout: null,
finished: false,
initial: true,
type: 2,
hint: null,
btn: null,
@@ -15,7 +16,7 @@ async function cycleLocale() {
const index = allLocales.indexOf(localeData.prev);
localeData.locale = allLocales[(index + 1) % allLocales.length];
localeData.btn.innerText = localeData.locale;
localeData.btn.style.backgroundColor = localeData.locale !== 'en' ? 'var(--primary-500)' : '';
// localeData.btn.style.backgroundColor = localeData.locale !== 'en' ? 'var(--primary-500)' : '';
localeData.finished = false;
localeData.data = [];
localeData.prev = localeData.locale;
@@ -29,12 +30,15 @@ async function tooltipCreate() {
localeData.hint.id = 'tooltip-container';
localeData.hint.innerText = 'this is a hint';
gradioApp().appendChild(localeData.hint);
localeData.btn = document.createElement('div');
localeData.btn.className = 'locale';
localeData.btn.id = 'locale-container';
localeData.btn = gradioApp().getElementById('locale-container');
if (!localeData.btn) {
localeData.btn = document.createElement('div');
localeData.btn.className = 'locale';
localeData.btn.id = 'locale-container';
gradioApp().appendChild(localeData.btn);
}
localeData.btn.innerText = localeData.locale;
localeData.btn.onclick = cycleLocale;
gradioApp().appendChild(localeData.btn);
if (window.opts.tooltips === 'None') localeData.type = 0;
if (window.opts.tooltips === 'Browser default') localeData.type = 1;
if (window.opts.tooltips === 'UI tooltips') localeData.type = 2;
@@ -169,7 +173,6 @@ async function setHints(analyze = false) {
if (!localeData.hint) tooltipCreate();
let localized = 0;
let hints = 0;
localeData.finished = true;
const t0 = performance.now();
for (const el of elements) {
let found;
@@ -179,6 +182,8 @@ async function setHints(analyze = false) {
if (!el.dataset.original) el.dataset.original = el.textContent;
localized++;
el.textContent = found.localized;
} else if (found?.label && !localeData.initial && (localeData.locale === 'en')) { // reset to english
el.textContent = found.label;
}
// replaceButtonText(el);
if (found?.hint?.length > 0) {
@@ -194,8 +199,10 @@ async function setHints(analyze = false) {
}
}
}
localeData.finished = true;
localeData.initial = false;
const t1 = performance.now();
localeData.btn.style.backgroundColor = localeData.locale !== 'en' ? 'var(--primary-500)' : '';
// localeData.btn.style.backgroundColor = localeData.locale !== 'en' ? 'var(--primary-500)' : '';
log('setHints', { type: localeData.type, locale: localeData.locale, elements: elements.length, localized, hints, data: localeData.data.length, override: overrideData.length, time: Math.round(t1 - t0) });
// sortUIElements();
if (analyze) {
@@ -210,10 +217,3 @@ const analyzeHints = async () => {
localeData.data = [];
await setHints(true);
};
/*
onAfterUiUpdate(async () => {
if (localeData.timeout) clearTimeout(localeData.timeout);
localeData.timeout = setTimeout(setHints, 250);
});
*/