mirror of
https://github.com/oobabooga/text-generation-webui.git
synced 2024-10-01 01:26:03 -04:00
Close the menu on second click. (#5110)
This commit is contained in:
parent
e4d724eb3f
commit
3bb4b0504e
14
js/main.js
14
js/main.js
@ -193,6 +193,7 @@ for (i = 0; i < slimDropdownElements.length; i++) {
|
|||||||
var buttonsInChat = document.querySelectorAll("#chat-tab:not(.old-ui) #chat-buttons button");
|
var buttonsInChat = document.querySelectorAll("#chat-tab:not(.old-ui) #chat-buttons button");
|
||||||
var button = document.getElementById("hover-element-button");
|
var button = document.getElementById("hover-element-button");
|
||||||
var menu = document.getElementById("hover-menu");
|
var menu = document.getElementById("hover-menu");
|
||||||
|
var istouchscreen = (navigator.maxTouchPoints > 0) || "ontouchstart" in document.documentElement;
|
||||||
|
|
||||||
function showMenu() {
|
function showMenu() {
|
||||||
menu.style.display = "flex"; // Show the menu
|
menu.style.display = "flex"; // Show the menu
|
||||||
@ -200,7 +201,9 @@ function showMenu() {
|
|||||||
|
|
||||||
function hideMenu() {
|
function hideMenu() {
|
||||||
menu.style.display = "none"; // Hide the menu
|
menu.style.display = "none"; // Hide the menu
|
||||||
document.querySelector("#chat-input textarea").focus();
|
if (!istouchscreen) {
|
||||||
|
document.querySelector("#chat-input textarea").focus(); // Focus on the chat input
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (buttonsInChat.length > 0) {
|
if (buttonsInChat.length > 0) {
|
||||||
@ -235,11 +238,18 @@ function isMouseOverButtonOrMenu() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
button.addEventListener("mouseenter", function () {
|
button.addEventListener("mouseenter", function () {
|
||||||
showMenu();
|
if (!istouchscreen) {
|
||||||
|
showMenu();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
button.addEventListener("click", function () {
|
button.addEventListener("click", function () {
|
||||||
|
if (menu.style.display === "flex") {
|
||||||
|
hideMenu();
|
||||||
|
}
|
||||||
|
else {
|
||||||
showMenu();
|
showMenu();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Add event listener for mouseleave on the button
|
// Add event listener for mouseleave on the button
|
||||||
|
Loading…
Reference in New Issue
Block a user