control prep work

This commit is contained in:
Vladimir Mandic
2023-12-16 13:25:25 -05:00
parent 936cf9786c
commit 86af00ce36
13 changed files with 94 additions and 51 deletions
+16 -7
View File
@@ -1,7 +1,16 @@
const getControlActiveTab = (...args) => {
const selectedTab = gradioApp().querySelector('#control-tabs > .tab-nav > .selected');
let activeTab = '';
if (selectedTab) activeTab = selectedTab.innerText.toLowerCase();
args.shift();
return [activeTab, ...args];
};
function setupControlUI() {
const tabs = ['input', 'output', 'preview'];
for (const tab of tabs) {
const btn = gradioApp().getElementById(`control-${tab}-button`);
btn.style.cursor = 'pointer';
btn.onclick = () => {
const t = gradioApp().getElementById(`control-tab-${tab}`);
t.style.display = t.style.display === 'none' ? 'block' : 'none';
const c = gradioApp().getElementById(`control-${tab}-column`);
c.style.flexGrow = c.style.flexGrow === '0' ? '9' : '0';
};
}
log('initControlUI');
}
onUiLoaded(setupControlUI);