many fixes in design and add shirt story type for creation book
This commit is contained in:
+62
-2
@@ -34,7 +34,7 @@ include 'views/layouts/header.php';
|
||||
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<form method="post" enctype="multipart/form-data">
|
||||
<form method="post" enctype="multipart/form-data" id="book-form">
|
||||
<input type="hidden" name="csrf_token" value="<?= generate_csrf_token() ?>">
|
||||
|
||||
<div class="mb-3">
|
||||
@@ -94,6 +94,28 @@ include 'views/layouts/header.php';
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mb-4">
|
||||
<div class="form-check">
|
||||
<input class="form-check-input" type="checkbox" id="is_short_story" name="is_short_story" value="1"
|
||||
<?= (!empty($_POST['is_short_story']) && $_POST['is_short_story']) ? 'checked' : '' ?> onchange="toggleStoryEditor()">
|
||||
<label class="form-check-label" for="is_short_story">
|
||||
Это рассказ (без разбивки на главы)
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card mb-4" id="story-editor-card" style="display: none;">
|
||||
<div class="card-header">
|
||||
<h5 class="card-title mb-0">Содержание рассказа</h5>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div id="story-editor" style="height: 400px;" data-content="<?= htmlspecialchars($_POST['content'] ?? '', ENT_QUOTES) ?>">
|
||||
<?= $_POST['content'] ?? '' ?>
|
||||
</div>
|
||||
<input type="hidden" name="content" id="story-content" <?= !empty($_POST['content']) ? 'value="' . htmlspecialchars($_POST['content'], ENT_QUOTES) . '"' : '' ?>>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="d-flex gap-2">
|
||||
<button type="submit" class="btn btn-primary">
|
||||
<i class="bi bi-journal-plus"></i> Создать книгу
|
||||
@@ -107,6 +129,44 @@ include 'views/layouts/header.php';
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="<?= SITE_URL ?>/assets/js/editor.js"></script>
|
||||
<script src="<?= SITE_URL ?>/assets/js/autosave.js"></script>
|
||||
<script>
|
||||
function toggleStoryEditor() {
|
||||
var isShortStory = document.getElementById('is_short_story').checked;
|
||||
var storyCard = document.getElementById('story-editor-card');
|
||||
|
||||
if (storyCard) {
|
||||
storyCard.style.display = isShortStory ? 'block' : 'none';
|
||||
|
||||
if (isShortStory && !window.writerEditor) {
|
||||
initQuillEditor(true);
|
||||
} else if (!isShortStory && window.writerEditor) {
|
||||
window.writerEditor.quill.destroy();
|
||||
window.writerEditor = null;
|
||||
}
|
||||
|
||||
if (isShortStory && window.writerEditor && window.writerEditor.quill) {
|
||||
setTimeout(() => {
|
||||
window.writerEditor.quill.root.style.height = '400px';
|
||||
window.writerEditor.quill.container.style.height = '400px';
|
||||
}, 100);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
toggleStoryEditor();
|
||||
|
||||
window.addEventListener('resize', function() {
|
||||
var isShortStory = document.getElementById('is_short_story').checked;
|
||||
if (isShortStory && window.writerEditor && window.writerEditor.quill) {
|
||||
window.writerEditor.quill.root.style.height = '400px';
|
||||
window.writerEditor.quill.container.style.height = '400px';
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
<?php include 'views/layouts/footer.php'; ?>
|
||||
Reference in New Issue
Block a user