Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
AUTOMATIC1111
GitHub Repository: AUTOMATIC1111/stable-diffusion-webui
Path: blob/master/extensions-builtin/mobile/javascript/mobile.js
2448 views
1
var isSetupForMobile = false;
2
3
function isMobile() {
4
for (var tab of ["txt2img", "img2img"]) {
5
var imageTab = gradioApp().getElementById(tab + '_results');
6
if (imageTab && imageTab.offsetParent && imageTab.offsetLeft == 0) {
7
return true;
8
}
9
}
10
11
return false;
12
}
13
14
function reportWindowSize() {
15
if (gradioApp().querySelector('.toprow-compact-tools')) return; // not applicable for compact prompt layout
16
17
var currentlyMobile = isMobile();
18
if (currentlyMobile == isSetupForMobile) return;
19
isSetupForMobile = currentlyMobile;
20
21
for (var tab of ["txt2img", "img2img"]) {
22
var button = gradioApp().getElementById(tab + '_generate_box');
23
var target = gradioApp().getElementById(currentlyMobile ? tab + '_results' : tab + '_actions_column');
24
target.insertBefore(button, target.firstElementChild);
25
26
gradioApp().getElementById(tab + '_results').classList.toggle('mobile', currentlyMobile);
27
}
28
}
29
30
window.addEventListener("resize", reportWindowSize);
31
32
onUiLoaded(function() {
33
reportWindowSize();
34
});
35
36