Keldos commited on
Commit
2f1ac44
1 Parent(s): d9bd9f8

WIP: refactor蒙版写法

Browse files
web_assets/html/chatbot_more.html CHANGED
@@ -39,7 +39,7 @@
39
 
40
  <!-- get more button -->
41
  <div id="chatbot-input-more-btn-div">
42
- <button class="chatbot-input-more-btn">
43
  <!-- <svg width="32px" height="32px" viewBox="0 0 32 32" version="1.1" xmlns="http://www.w3.org/2000/svg"
44
  xmlns:xlink="http://www.w3.org/1999/xlink">
45
  <g stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
 
39
 
40
  <!-- get more button -->
41
  <div id="chatbot-input-more-btn-div">
42
+ <button class="chatbot-input-more-btn" onclick="chatMoreBtnClick()">
43
  <!-- <svg width="32px" height="32px" viewBox="0 0 32 32" version="1.1" xmlns="http://www.w3.org/2000/svg"
44
  xmlns:xlink="http://www.w3.org/1999/xlink">
45
  <g stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
web_assets/javascript/updater.js CHANGED
@@ -140,6 +140,7 @@ function cancelUpdate() {
140
  function openUpdateToast() {
141
  showingUpdateInfo = true;
142
  updateToast.style.setProperty('top', '0px');
 
143
  }
144
  function closeUpdateToast() {
145
  updateToast.style.setProperty('top', '-500px');
@@ -147,6 +148,7 @@ function closeUpdateToast() {
147
  if (updatingInfoElement.classList.contains('hideK') === false) {
148
  updatingInfoElement.classList.add('hideK');
149
  }
 
150
  }
151
  function manualCheckUpdate() {
152
  openUpdateToast();
 
140
  function openUpdateToast() {
141
  showingUpdateInfo = true;
142
  updateToast.style.setProperty('top', '0px');
143
+ showMask("update-toast");
144
  }
145
  function closeUpdateToast() {
146
  updateToast.style.setProperty('top', '-500px');
 
148
  if (updatingInfoElement.classList.contains('hideK') === false) {
149
  updatingInfoElement.classList.add('hideK');
150
  }
151
+ document.querySelector('.chuanhu-mask')?.remove();
152
  }
153
  function manualCheckUpdate() {
154
  openUpdateToast();
web_assets/javascript/webui.js CHANGED
@@ -8,7 +8,7 @@ function openSettingBox() {
8
  popupWrapper.classList.add('showBox');
9
  settingBox.classList.remove('hideBox');
10
  trainingBox.classList.add('hideBox');
11
- showMask();
12
 
13
  }
14
 
@@ -17,19 +17,57 @@ function openTrainingBox() {
17
  popupWrapper.classList.add('showBox');
18
  trainingBox.classList.remove('hideBox');
19
  settingBox.classList.add('hideBox');
20
- showMask();
21
  }
22
 
23
- function showMask() {
 
 
 
 
 
 
 
 
 
 
 
24
  const mask = document.createElement('div');
25
  mask.classList.add('chuanhu-mask');
26
- popupWrapper.appendChild(mask);
27
- document.body.classList.add('popup-open');
 
 
 
 
 
 
 
 
 
 
 
 
 
28
  mask.addEventListener('click', () => {
29
- closeBox();
 
 
 
 
 
 
30
  });
31
  }
32
 
 
 
 
 
 
 
 
 
33
  function closeBtnClick(obj) {
34
  if (obj == "box") {
35
  closeBox();
@@ -191,6 +229,14 @@ function checkChatbotWidth() {
191
  } else {
192
  chatbotArea.classList.remove('chatbot-full-width');
193
  }
 
 
 
 
 
 
 
 
194
  }
195
 
196
  /*
 
8
  popupWrapper.classList.add('showBox');
9
  settingBox.classList.remove('hideBox');
10
  trainingBox.classList.add('hideBox');
11
+ showMask("box");
12
 
13
  }
14
 
 
17
  popupWrapper.classList.add('showBox');
18
  trainingBox.classList.remove('hideBox');
19
  settingBox.classList.add('hideBox');
20
+ showMask("box");
21
  }
22
 
23
+ function openChatMore() {
24
+ chatbotArea.classList.add('show-chat-more');
25
+ showMask("chat-more");
26
+ }
27
+
28
+ function closeChatMore() {
29
+ chatbotArea.classList.remove('show-chat-more');
30
+ chatbotArea.querySelector('.chuanhu-mask')?.remove();
31
+ }
32
+
33
+
34
+ function showMask(obj) {
35
  const mask = document.createElement('div');
36
  mask.classList.add('chuanhu-mask');
37
+ if (obj == "box") {
38
+ mask.classList.add('mask-blur');
39
+ document.body.classList.add('popup-open');
40
+ popupWrapper.appendChild(mask);
41
+ } else if (obj == "chat-more") {
42
+ mask.classList.add('transparent-mask');
43
+ chatbotArea.querySelector('#chatbot-input-more-area').parentNode.appendChild(mask);
44
+ } else if (obj == "update-toast") {
45
+ mask.classList.add('chuanhu-top-mask');
46
+ document.body.appendChild(mask);
47
+ // mask.classList.add('transparent-mask');
48
+ }
49
+
50
+
51
+
52
  mask.addEventListener('click', () => {
53
+ if (obj == "box") {
54
+ closeBox();
55
+ } else if (obj == "chat-more") {
56
+ closeChatMore();
57
+ } else if (obj == "update-toast") {
58
+ closeUpdateToast();
59
+ }
60
  });
61
  }
62
 
63
+ function chatMoreBtnClick() {
64
+ if (chatbotArea.classList.contains('show-chat-more')) {
65
+ closeChatMore();
66
+ } else {
67
+ openChatMore();
68
+ }
69
+ }
70
+
71
  function closeBtnClick(obj) {
72
  if (obj == "box") {
73
  closeBox();
 
229
  } else {
230
  chatbotArea.classList.remove('chatbot-full-width');
231
  }
232
+ checkChatMoreMask();
233
+ }
234
+
235
+ function checkChatMoreMask() {
236
+ if (!chatbotArea.classList.contains('chatbot-full-width')) {
237
+ chatbotArea.querySelector('.chuanhu-mask')?.remove();
238
+ chatbotArea.classList.remove('show-chat-more');
239
+ }
240
  }
241
 
242
  /*
web_assets/stylesheet/ChuanhuChat.css CHANGED
@@ -170,15 +170,18 @@ body.popup-open {
170
  z-index: 999;
171
  /* background-color: transparent; */
172
  }
173
- .chuanhu-mask {
174
  background-color: rgba(0, 0, 0, 0.5);
175
- -webkit-backdrop-filter: blur(2px);
176
- backdrop-filter: blur(2px);
177
- }
178
  .mask-blur {
179
  -webkit-backdrop-filter: blur(2px);
180
  backdrop-filter: blur(2px);
181
  }
 
 
 
182
 
183
  .chuanhu-side-mask {
184
  background-color: rgba(0, 0, 0, 0);
@@ -401,6 +404,7 @@ button.chatbot-input-more-btn {
401
  height: 32px;
402
  width: 32px;
403
  border-radius: 50%;
 
404
  }
405
  button.chatbot-input-more-btn:hover .sm-round-bg {
406
  fill-opacity: 0.2125;
@@ -410,14 +414,17 @@ button.chatbot-input-more-btn:active .sm-round-bg {
410
  }
411
 
412
  /* 三个点号点开! */
 
 
 
413
  /* no!屏幕宽度窄的时候! */
414
  #chatbot-input-more-area {
 
415
  position: absolute;
416
- display: flex;
417
  flex-direction: column;
418
  bottom: 60px;
419
  min-width: 120px;
420
- z-index: 5000;
421
  border-radius: 6px;
422
  box-shadow: var(--shadow-sm);
423
  background: var(--chatbot-input-more-background-color);
@@ -468,6 +475,7 @@ button.chatbot-input-more-btn:active .sm-round-bg {
468
  justify-items: start;
469
  }
470
  .chatbot-full-width #chatbot-input-more-area {
 
471
  position: relative;
472
  flex-direction: row-reverse;
473
  justify-content: space-between;
 
170
  z-index: 999;
171
  /* background-color: transparent; */
172
  }
173
+ /* .chuanhu-mask {
174
  background-color: rgba(0, 0, 0, 0.5);
175
+ /* -webkit-backdrop-filter: blur(2px);
176
+ backdrop-filter: blur(2px);
177
+ } */
178
  .mask-blur {
179
  -webkit-backdrop-filter: blur(2px);
180
  backdrop-filter: blur(2px);
181
  }
182
+ .transparent-mask {
183
+ background-color: transparent !important;
184
+ }
185
 
186
  .chuanhu-side-mask {
187
  background-color: rgba(0, 0, 0, 0);
 
404
  height: 32px;
405
  width: 32px;
406
  border-radius: 50%;
407
+ z-index: 1001;
408
  }
409
  button.chatbot-input-more-btn:hover .sm-round-bg {
410
  fill-opacity: 0.2125;
 
414
  }
415
 
416
  /* 三个点号点开! */
417
+ .show-chat-more #chatbot-input-more-area {
418
+ display: flex;
419
+ }
420
  /* no!屏幕宽度窄的时候! */
421
  #chatbot-input-more-area {
422
+ display: none;
423
  position: absolute;
 
424
  flex-direction: column;
425
  bottom: 60px;
426
  min-width: 120px;
427
+ z-index: 1001;
428
  border-radius: 6px;
429
  box-shadow: var(--shadow-sm);
430
  background: var(--chatbot-input-more-background-color);
 
475
  justify-items: start;
476
  }
477
  .chatbot-full-width #chatbot-input-more-area {
478
+ display: flex;
479
  position: relative;
480
  flex-direction: row-reverse;
481
  justify-content: space-between;