Spaces:
Sleeping
Sleeping
Keldos
commited on
Commit
·
455961c
1
Parent(s):
0e5af6a
fix both side open
Browse files
web_assets/javascript/ChuanhuChat.js
CHANGED
|
@@ -31,11 +31,15 @@ var settingBox = null;
|
|
| 31 |
var trainingBox = null;
|
| 32 |
var popupWrapper = null;
|
| 33 |
var chuanhuHeader = null;
|
|
|
|
|
|
|
| 34 |
|
| 35 |
var isInIframe = (window.self !== window.top);
|
| 36 |
var currentTime = new Date().getTime();
|
| 37 |
var initialized = false;
|
| 38 |
|
|
|
|
|
|
|
| 39 |
// gradio 页面加载好了么??? 我能动你的元素了么??
|
| 40 |
function gradioLoaded(mutations) {
|
| 41 |
for (var i = 0; i < mutations.length; i++) {
|
|
@@ -75,7 +79,8 @@ function initialize() {
|
|
| 75 |
trainingBox = gradioApp().querySelector('#chuanhu-training');
|
| 76 |
popupWrapper = gradioApp().querySelector('#popup-wrapper');
|
| 77 |
chuanhuHeader = gradioApp().querySelector('#chuanhu-header');
|
| 78 |
-
|
|
|
|
| 79 |
|
| 80 |
if (loginUserForm) {
|
| 81 |
localStorage.setItem("userLogged", true);
|
|
@@ -335,7 +340,11 @@ window.addEventListener("DOMContentLoaded", function () {
|
|
| 335 |
isInIframe = (window.self !== window.top);
|
| 336 |
historyLoaded = false;
|
| 337 |
});
|
| 338 |
-
window.addEventListener('resize', ()=>{
|
|
|
|
|
|
|
|
|
|
|
|
|
| 339 |
window.addEventListener('scroll', ()=>{setChatbotHeight(); setUpdateWindowHeight();setPopupBoxPosition();});
|
| 340 |
window.matchMedia("(prefers-color-scheme: dark)").addEventListener("change", adjustDarkMode);
|
| 341 |
|
|
|
|
| 31 |
var trainingBox = null;
|
| 32 |
var popupWrapper = null;
|
| 33 |
var chuanhuHeader = null;
|
| 34 |
+
var menu = null;
|
| 35 |
+
var toolbox = null;
|
| 36 |
|
| 37 |
var isInIframe = (window.self !== window.top);
|
| 38 |
var currentTime = new Date().getTime();
|
| 39 |
var initialized = false;
|
| 40 |
|
| 41 |
+
let windowWidth = window.innerWidth; // 初始窗口宽度
|
| 42 |
+
|
| 43 |
// gradio 页面加载好了么??? 我能动你的元素了么??
|
| 44 |
function gradioLoaded(mutations) {
|
| 45 |
for (var i = 0; i < mutations.length; i++) {
|
|
|
|
| 79 |
trainingBox = gradioApp().querySelector('#chuanhu-training');
|
| 80 |
popupWrapper = gradioApp().querySelector('#popup-wrapper');
|
| 81 |
chuanhuHeader = gradioApp().querySelector('#chuanhu-header');
|
| 82 |
+
menu = gradioApp().querySelector('#menu-area');
|
| 83 |
+
toolbox = gradioApp().querySelector('#toolbox-area');
|
| 84 |
|
| 85 |
if (loginUserForm) {
|
| 86 |
localStorage.setItem("userLogged", true);
|
|
|
|
| 340 |
isInIframe = (window.self !== window.top);
|
| 341 |
historyLoaded = false;
|
| 342 |
});
|
| 343 |
+
window.addEventListener('resize', ()=>{
|
| 344 |
+
setChatbotHeight();
|
| 345 |
+
setPopupBoxPosition();
|
| 346 |
+
windowWidth = window.innerWidth;
|
| 347 |
+
});
|
| 348 |
window.addEventListener('scroll', ()=>{setChatbotHeight(); setUpdateWindowHeight();setPopupBoxPosition();});
|
| 349 |
window.matchMedia("(prefers-color-scheme: dark)").addEventListener("change", adjustDarkMode);
|
| 350 |
|
web_assets/javascript/webui.js
CHANGED
|
@@ -32,14 +32,14 @@ function showSideMask() {
|
|
| 32 |
showOrHideSideMask(oldSideMask);
|
| 33 |
return;
|
| 34 |
}
|
| 35 |
-
|
|
|
|
| 36 |
function showOrHideSideMask(sideMask) {
|
| 37 |
-
const windowWidth = window.innerWidth;
|
| 38 |
if (document.querySelector('.showSide')) {
|
| 39 |
|
| 40 |
if (windowWidth < 1024) {
|
| 41 |
-
if (
|
| 42 |
-
|
| 43 |
chuanhuHeader.classList.remove('under-box');
|
| 44 |
// if both menu and toolbox are open, close toolbox...
|
| 45 |
}
|
|
@@ -81,7 +81,8 @@ function showSideMask() {
|
|
| 81 |
|
| 82 |
|
| 83 |
sideMask.addEventListener('click', () => {
|
| 84 |
-
closeSide();
|
|
|
|
| 85 |
});
|
| 86 |
}
|
| 87 |
|
|
@@ -94,25 +95,23 @@ function closeBox() {
|
|
| 94 |
document.body.classList.remove('popup-open');
|
| 95 |
}
|
| 96 |
|
| 97 |
-
function closeSide() {
|
| 98 |
|
| 99 |
document.querySelector('.chuanhu-side-mask').style.opacity = '0';
|
| 100 |
setTimeout(() => {document.querySelector('.chuanhu-side-mask').remove();}, 300);
|
| 101 |
document.body.classList.remove('popup-open');
|
| 102 |
|
| 103 |
-
|
| 104 |
-
gradioApp().querySelector('#toolbox-area').classList.remove('showSide');
|
| 105 |
|
| 106 |
chuanhuHeader.classList.remove('under-box');
|
| 107 |
|
| 108 |
}
|
| 109 |
|
| 110 |
function menuClick() {
|
| 111 |
-
var menu = gradioApp().querySelector('#menu-area');
|
| 112 |
// var menuBtn = gradioApp().querySelector('.menu-btn');
|
| 113 |
if (menu.classList.contains('showSide')) {
|
| 114 |
menu.classList.remove('showSide');
|
| 115 |
-
closeSide();
|
| 116 |
} else {
|
| 117 |
menu.classList.add('showSide');
|
| 118 |
showSideMask();
|
|
@@ -120,14 +119,12 @@ function menuClick() {
|
|
| 120 |
}
|
| 121 |
|
| 122 |
function toolboxClick() {
|
| 123 |
-
var toolbox = gradioApp().querySelector('#toolbox-area');
|
| 124 |
-
var menu = gradioApp().querySelector('#menu-area');
|
| 125 |
if (toolbox.classList.contains('showSide')) {
|
| 126 |
toolbox.classList.remove('showSide');
|
| 127 |
chuanhuHeader.classList.remove('under-box');
|
| 128 |
-
closeSide();
|
| 129 |
} else {
|
| 130 |
-
if (menu.classList.contains('showSide')) {
|
| 131 |
menu.classList.remove('showSide');
|
| 132 |
}
|
| 133 |
toolbox.classList.add('showSide');
|
|
|
|
| 32 |
showOrHideSideMask(oldSideMask);
|
| 33 |
return;
|
| 34 |
}
|
| 35 |
+
|
| 36 |
+
|
| 37 |
function showOrHideSideMask(sideMask) {
|
|
|
|
| 38 |
if (document.querySelector('.showSide')) {
|
| 39 |
|
| 40 |
if (windowWidth < 1024) {
|
| 41 |
+
if (menu.classList.contains('showSide') && toolbox.classList.contains('showSide')) {
|
| 42 |
+
toolbox.classList.remove('showSide');
|
| 43 |
chuanhuHeader.classList.remove('under-box');
|
| 44 |
// if both menu and toolbox are open, close toolbox...
|
| 45 |
}
|
|
|
|
| 81 |
|
| 82 |
|
| 83 |
sideMask.addEventListener('click', () => {
|
| 84 |
+
closeSide(menu);
|
| 85 |
+
closeSide(toolbox);
|
| 86 |
});
|
| 87 |
}
|
| 88 |
|
|
|
|
| 95 |
document.body.classList.remove('popup-open');
|
| 96 |
}
|
| 97 |
|
| 98 |
+
function closeSide(sideArea) {
|
| 99 |
|
| 100 |
document.querySelector('.chuanhu-side-mask').style.opacity = '0';
|
| 101 |
setTimeout(() => {document.querySelector('.chuanhu-side-mask').remove();}, 300);
|
| 102 |
document.body.classList.remove('popup-open');
|
| 103 |
|
| 104 |
+
sideArea.classList.remove('showSide');
|
|
|
|
| 105 |
|
| 106 |
chuanhuHeader.classList.remove('under-box');
|
| 107 |
|
| 108 |
}
|
| 109 |
|
| 110 |
function menuClick() {
|
|
|
|
| 111 |
// var menuBtn = gradioApp().querySelector('.menu-btn');
|
| 112 |
if (menu.classList.contains('showSide')) {
|
| 113 |
menu.classList.remove('showSide');
|
| 114 |
+
closeSide(menu);
|
| 115 |
} else {
|
| 116 |
menu.classList.add('showSide');
|
| 117 |
showSideMask();
|
|
|
|
| 119 |
}
|
| 120 |
|
| 121 |
function toolboxClick() {
|
|
|
|
|
|
|
| 122 |
if (toolbox.classList.contains('showSide')) {
|
| 123 |
toolbox.classList.remove('showSide');
|
| 124 |
chuanhuHeader.classList.remove('under-box');
|
| 125 |
+
closeSide(toolbox);
|
| 126 |
} else {
|
| 127 |
+
if (menu.classList.contains('showSide') && windowWidth < 1024) {
|
| 128 |
menu.classList.remove('showSide');
|
| 129 |
}
|
| 130 |
toolbox.classList.add('showSide');
|