re-added 'mini-menu'
All checks were successful
Run Integration Tests / test (push) Successful in 34s

This commit is contained in:
partisan 2024-12-07 14:42:23 +01:00
parent 28a721887c
commit 7e573e6928
3 changed files with 214 additions and 15 deletions

144
static/css/style-menu.css Normal file
View file

@ -0,0 +1,144 @@
.settings-search-div-search {
right: 20px;
top: 25px;
position: fixed;
z-index: 9999;
}
.settings-icon-link-search {
font-size: 25px;
background-color: inherit;
border: none;
}
.search-menu {
position: fixed;
height: 420px;
width: 330px;
right: 0;
margin-top: 60px;
z-index: 9999;
margin-right: 20px;
background-color: var(--html-bg);
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.24);
border: 1px solid var(--border);
border-radius: 10px;
top: 24px;
/* Transition for fade in/out */
opacity: 0;
pointer-events: none;
transition: opacity 0.3s ease;
}
.search-menu h2 {
color: var(--font-fg);
display: flex;
justify-content: center;
font-size: 1.5rem;
margin: 14px;
}
.search-menu button {
margin-top: 10px;
color: var(--font-fg);
background-color: var(--button);
font-size: 14px;
border: 1px solid var(--border);
border-radius: 4px;
padding: 10px;
width: 90%;
transition: border 0.3s ease;
}
.search-menu button:hover {
border: 1px solid var(--font-fg);
cursor: pointer;
}
.settings-content {
display: flex;
flex-direction: column;
align-items: center;
}
/* Initially hidden state */
.settings-menu-hidden {
opacity: 0;
pointer-events: none;
}
/* Visible state triggers fade in */
.settings-menu-visible {
opacity: 1;
pointer-events: auto;
}
.theme-settings {
margin-top: 10px;
width: 90%;
border: 1px solid var(--snip-border);
background: var(--snip-background);
color: var(--font-fg);
border-radius: 4px;
height: 100%;
}
.theme-settings p {
margin: 0px;
padding-top: 5px;
margin-left: 3%;
}
.lang {
margin-top: 10px;
border: 1px solid var(--button);
border-radius: 4px;
padding: 6px;
font-size: 15px;
color: var(--font-fg);
width: 90%;
background: var(--button);
transition: border 0.3s ease;
}
.lang:hover {
border: 1px solid var(--font-fg);
cursor: pointer;
}
.view-image-search {
border: 1px solid var(--snip-border);
margin: 0;
height: 100%;
width: 100%;
object-fit: cover;
object-position: center;
vertical-align: bottom;
border-radius: 4px;
transition: border 0.3s ease;
}
.view-image-search:hover {
border: 1px solid var(--font-fg);
cursor: pointer;
}
.themes-settings-menu {
display: flex;
justify-content: center;
gap: 5px;
margin: 5px;
}
/* On screens 450px or less, make the menu cover the whole page */
@media (max-width: 450px) {
.search-menu {
width: 100%;
height: 100%;
right: 0;
margin-top: 50;
margin-right: 0;
border-radius: 0;
}
}

42
static/js/minimenu.js Normal file
View file

@ -0,0 +1,42 @@
document.addEventListener('DOMContentLoaded', function () {
// Define the updateSettings function first
function updateSettings(settingKey, settingValue) {
const xhr = new XMLHttpRequest();
xhr.open('POST', '/updateSettings', true);
xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
xhr.onload = function () {
if (this.status >= 200 && this.status < 300) {
console.log('Settings updated successfully!');
} else {
console.log('Failed to update settings.');
}
};
xhr.send(encodeURI(settingKey + '=' + settingValue));
}
const settingsIcon = document.querySelector('.settings-icon-link-search');
const searchMenu = document.querySelector('.search-menu');
settingsIcon.addEventListener('click', function () {
searchMenu.classList.toggle('settings-menu-hidden');
searchMenu.classList.toggle('settings-menu-visible');
});
// Theme change event listeners
document.getElementById('dark_theme').addEventListener('click', function () {
window.location.href = '/search?theme=dark';
});
document.getElementById('light_theme').addEventListener('click', function () {
window.location.href = '/search?theme=light';
});
// Event listener for Safe Search Selection
document.getElementById('safeSearchSelect').addEventListener('change', function () {
updateSettings('safe', this.value);
});
// Event listener for Language Selection
document.getElementById('languageSelect').addEventListener('change', function () {
updateSettings('lang', this.value);
});
});

View file

@ -22,6 +22,7 @@
</style>
<link rel="stylesheet" href="/static/css/style-search.css">
<link rel="stylesheet" href="/static/css/style-menu.css">
<link rel="stylesheet" href="/static/css/{{.Theme}}.css">
<link rel="stylesheet" href="/static/css/style-fonts.css">
<link rel="search" type="application/opensearchdescription+xml" title="{{ translate "site_name" }}" href="/opensearch.xml">
@ -32,28 +33,39 @@
<link rel="apple-touch-icon" href="{{ .IconPathPNG }}">
</head>
<body>
<!-- Menu Button -->
<div id="js-enabled">
<button class="material-icons-round settings-icon-link-search" onclick="openNav()">&#xe5d2;</button>
<div class="settings-search-div settings-search-div-search">
<button class="material-icons-round clickable settings-icon-link settings-icon-link-search">&#xe5d2;</button>
</div>
<div class="search-menu settings-menu-hidden">
<h2>Settings</h2>
<div class="settings-content">
<button id="settingsButton" onclick="window.location.href='/settings'">All settings</button>
<div class="theme-settings">
<p><span class="highlight">Current theme: </span> <span id="theme_name">{{.Theme}}</span></p>
<div class="themes-settings-menu">
<div><img class="view-image-search clickable" id="dark_theme" alt="Dark Theme" src="/static/images/dark.webp"></div>
<div><img class="view-image-search clickable" id="light_theme" alt="Light Theme" src="/static/images/light.webp"></div>
</div>
</div>
<select class="lang" name="safe" id="safeSearchSelect">
<option value="disabled" {{if eq .Safe "disabled"}}selected{{end}}>Safe Search Off</option>
<option value="active" {{if eq .Safe "active"}}selected{{end}}>Safe Search On</option>
</select>
<select class="lang" name="lang" id="languageSelect">
{{range .LanguageOptions}}
<option value="{{.Code}}" {{if eq .Code $.CurrentLang}}selected{{end}}>{{.Name}}</option>
{{end}}
</select>
<!-- <button id="settingsButton" onclick="window.location.href='/about'">About QGato</button> -->
</div>
</div>
</div>
<div id="js-disabled">
<a href="/settings" class="material-icons-round settings-icon-link-search">&#xe5d2;</a>
</div>
<!-- Side Navigation Menu -->
<div id="mySidenav" class="side-nav">
<button class="material-icons-round closebtn" onclick="closeNav()">&#xe5cd;</button>
<a href="/settings">{{ translate "all_settings" }}</a>
<button onclick="setTheme('dark')">{{ translate "theme_dark" }}</button>
<button onclick="setTheme('light')">{{ translate "theme_light" }}</button>
<select class="lang" name="site_lang" id="siteLanguageSelect" onchange="updateLanguage(this.value)">
{{range .LanguageOptions}}
<option value="{{.Code}}" {{if eq .Code $.CurrentLang}}selected{{end}}>{{.Name}}</option>
{{end}}
</select>
</div>
<!-- Search Form -->
<form action="/search" class="search-container" method="get" autocomplete="off">
<div class="search-page-content">
@ -117,6 +129,7 @@
<script defer src="/static/js/buttonsmove.js"></script>
<script defer src="/static/js/sidemenu.js"></script>
<script defer src="/static/js/autocomplete.js"></script>
<script defer src="/static/js/minimenu.js"></script>
<script>
// When JS is detected, update the DOM
document.getElementById('js-enabled').style.display = 'block';