Admin/Public: simplify admin menu labels and remove comment autofocus

This commit is contained in:
Alexander Andreev 2026-02-21 13:49:55 +03:00
parent def543f813
commit 2ed10f7b63
2 changed files with 8 additions and 13 deletions

View File

@ -143,7 +143,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
if ($action === 'update_welcome') { if ($action === 'update_welcome') {
$text = trim((string)($_POST['welcome_text'] ?? '')); $text = trim((string)($_POST['welcome_text'] ?? ''));
settingSet('welcome_text', $text); settingSet('welcome_text', $text);
$message = 'Приветственное сообщение сохранено'; $message = 'Настройки сохранены';
} }
if ($action === 'upload_before_bulk') { if ($action === 'upload_before_bulk') {
@ -794,17 +794,17 @@ function nextUniqueCodeName(string $base): string
<h3>Меню</h3> <h3>Меню</h3>
<div class="sec"> <div class="sec">
<a class="<?= $adminMode==='sections'?'active':'' ?>" href="?token=<?= urlencode($tokenIncoming) ?>&mode=sections<?= $activeSectionId>0 ? '&section_id='.(int)$activeSectionId : '' ?>">Разделы</a> <a class="<?= $adminMode==='sections'?'active':'' ?>" href="?token=<?= urlencode($tokenIncoming) ?>&mode=sections<?= $activeSectionId>0 ? '&section_id='.(int)$activeSectionId : '' ?>">Разделы</a>
<a class="<?= $adminMode==='photos'?'active':'' ?>" href="?token=<?= urlencode($tokenIncoming) ?>&mode=photos<?= $activeSectionId>0 ? '&section_id='.(int)$activeSectionId : '' ?>">Фото</a>
<a class="<?= $adminMode==='topics'?'active':'' ?>" href="?token=<?= urlencode($tokenIncoming) ?>&mode=topics">Тематики</a> <a class="<?= $adminMode==='topics'?'active':'' ?>" href="?token=<?= urlencode($tokenIncoming) ?>&mode=topics">Тематики</a>
<a class="<?= $adminMode==='welcome'?'active':'' ?>" href="?token=<?= urlencode($tokenIncoming) ?>&mode=welcome">Приветственное сообщение</a> <a class="<?= $adminMode==='photos'?'active':'' ?>" href="?token=<?= urlencode($tokenIncoming) ?>&mode=photos<?= $activeSectionId>0 ? '&section_id='.(int)$activeSectionId : '' ?>">Фото</a>
<a class="<?= $adminMode==='commenters'?'active':'' ?>" href="?token=<?= urlencode($tokenIncoming) ?>&mode=commenters">Пользователи комментариев</a> <a class="<?= $adminMode==='commenters'?'active':'' ?>" href="?token=<?= urlencode($tokenIncoming) ?>&mode=commenters">Пользователи</a>
<a class="<?= $adminMode==='comments'?'active':'' ?>" href="?token=<?= urlencode($tokenIncoming) ?>&mode=comments">Комментарии</a> <a class="<?= $adminMode==='comments'?'active':'' ?>" href="?token=<?= urlencode($tokenIncoming) ?>&mode=comments">Комментарии</a>
<a class="<?= $adminMode==='welcome'?'active':'' ?>" href="?token=<?= urlencode($tokenIncoming) ?>&mode=welcome">Настройки</a>
</div> </div>
</section> </section>
<?php if ($adminMode === 'sections' || $adminMode === 'photos'): ?> <?php if ($adminMode === 'sections' || $adminMode === 'photos'): ?>
<section class="card"> <section class="card">
<h3><?= $adminMode === 'sections' ? 'Разделы' : 'Выбор раздела для фото' ?></h3> <h3>Разделы</h3>
<div class="sec"> <div class="sec">
<?php foreach($sections as $s): ?> <?php foreach($sections as $s): ?>
<a class="<?= (int)$s['id']===$activeSectionId?'active':'' ?>" href="?token=<?= urlencode($tokenIncoming) ?>&mode=<?= h($adminMode) ?>&section_id=<?= (int)$s['id'] ?>"><?= h((string)$s['name']) ?> <span class="small">(<?= (int)$s['photos_count'] ?>)</span></a> <a class="<?= (int)$s['id']===$activeSectionId?'active':'' ?>" href="?token=<?= urlencode($tokenIncoming) ?>&mode=<?= h($adminMode) ?>&section_id=<?= (int)$s['id'] ?>"><?= h((string)$s['name']) ?> <span class="small">(<?= (int)$s['photos_count'] ?>)</span></a>
@ -834,11 +834,11 @@ function nextUniqueCodeName(string $base): string
<main> <main>
<?php if ($adminMode === 'welcome'): ?> <?php if ($adminMode === 'welcome'): ?>
<section class="card"> <section class="card">
<h3>Приветственное сообщение (публичная часть)</h3> <h3>Настройки</h3>
<form method="post" action="?token=<?= urlencode($tokenIncoming) ?>&mode=welcome"> <form method="post" action="?token=<?= urlencode($tokenIncoming) ?>&mode=welcome">
<input type="hidden" name="action" value="update_welcome"><input type="hidden" name="token" value="<?= h($tokenIncoming) ?>"> <input type="hidden" name="action" value="update_welcome"><input type="hidden" name="token" value="<?= h($tokenIncoming) ?>">
<p><textarea class="in" name="welcome_text" rows="5" placeholder="Текст приветствия"><?= h($welcomeText) ?></textarea></p> <p><textarea class="in" name="welcome_text" rows="5" placeholder="Текст приветствия"><?= h($welcomeText) ?></textarea></p>
<button class="btn" type="submit">Сохранить приветствие</button> <button class="btn" type="submit">Сохранить настройки</button>
</form> </form>
</section> </section>
<?php endif; ?> <?php endif; ?>

View File

@ -563,7 +563,7 @@ function outputWatermarked(string $path, string $mime): never
<input type="hidden" name="section_id" value="<?= $isSectionMode ? (int)$detailSectionId : 0 ?>"> <input type="hidden" name="section_id" value="<?= $isSectionMode ? (int)$detailSectionId : 0 ?>">
<input type="hidden" name="topic_id" value="<?= $isTopicMode ? (int)$activeTopicId : 0 ?>"> <input type="hidden" name="topic_id" value="<?= $isTopicMode ? (int)$activeTopicId : 0 ?>">
<input type="hidden" name="viewer" value="<?= h($viewerToken) ?>"> <input type="hidden" name="viewer" value="<?= h($viewerToken) ?>">
<textarea class="js-comment-textarea comment-input" name="comment_text" required autofocus></textarea> <textarea class="js-comment-textarea comment-input" name="comment_text" required></textarea>
<p class="comment-actions"><button class="btn" type="submit">Отправить</button></p> <p class="comment-actions"><button class="btn" type="submit">Отправить</button></p>
</form> </form>
<?php else: ?> <?php else: ?>
@ -764,11 +764,6 @@ function outputWatermarked(string $path, string $mime): never
const commentTextarea = document.querySelector('.js-comment-textarea'); const commentTextarea = document.querySelector('.js-comment-textarea');
const commentForm = commentTextarea ? commentTextarea.closest('.js-comment-form') : null; const commentForm = commentTextarea ? commentTextarea.closest('.js-comment-form') : null;
if (commentTextarea) { if (commentTextarea) {
requestAnimationFrame(() => {
commentTextarea.focus();
commentTextarea.setSelectionRange(commentTextarea.value.length, commentTextarea.value.length);
});
commentTextarea.addEventListener('keydown', (e) => { commentTextarea.addEventListener('keydown', (e) => {
if (!e.shiftKey || e.key !== 'Enter' || e.isComposing) { if (!e.shiftKey || e.key !== 'Enter' || e.isComposing) {
return; return;