New Commit: Replace note prompt with reader modal Switched inline text highlighting from using `prompt()` to a custom study-note modal in the reader UI. The highlighting script now opens the modal, focuses the textarea, wires Save/Cancel actions, and cleans up handlers after close. Added the modal markup to `reader_template.php` and removed the `read-realistic-single.css` import from `reader-main.css`.
Repository: Hestenb62/_legacy_backup
Author: Hesten Berger
Commit Message: Replace note prompt with reader modal Switched inline text highlighting from using to a custom study-note modal in the reader UI. The highlighting script now opens the modal, focuses the textarea, wires Save/Cancel actions, and cleans up handlers after close. Added the modal markup to and removed the import from .
URL: https://github.com/Hestenb62/_legacy_backup/commit/6ce5c65d80371e955505ccb9872fd955330427a0
Code Changes:
diff --git a/assets/css/reader-main.css b/assets/css/reader-main.css
index 4bfc6cc..1e36c11 100644
--- a/assets/css/reader-main.css
+++ b/assets/css/reader-main.css
@@ -12,7 +12,7 @@
@import url('./reader/read-reader-academic-citation-modal.css');
@import url('./reader/read-book-sourcing-information-moda.css');
@import url('./reader/read-responsive-breakpoints-for-rea.css');
-@import url('./reader/read-realistic-single.css');
+
/* Inline Page Markers for Scroll Mode */
.inline-page-marker {
display: flex;
diff --git a/assets/js/reader/read-inline-text-highlighting.js b/assets/js/reader/read-inline-text-highlighting.js
index 47bf32e..e60d4bb 100644
--- a/assets/js/reader/read-inline-text-highlighting.js
+++ b/assets/js/reader/read-inline-text-highlighting.js
@@ -99,9 +99,33 @@
if (hlNote) {
hlNote.addEventListener("click", () => {
if (currentSelectedRange) {
- const note = prompt("Add a study note for this selection:");
- if (note) {
- applyHighlight("hl-yellow", note);
+ const noteModal = document.getElementById("note-input-modal");
+ const noteTextarea = document.getElementById("study-note-textarea");
+ const saveBtn = document.getElementById("save-note-btn");
+ const cancelBtn = document.getElementById("cancel-note-btn");
+
+ if (noteModal && noteTextarea) {
+ noteTextarea.value = '';
+ noteModal.classList.remove("hidden");
+ noteModal.style.display = "flex";
+ noteTextarea.focus();
+
+ const cleanup = () => {
+ noteModal.classList.add("hidden");
+ noteModal.style.display = "none";
+ saveBtn.onclick = null;
+ cancelBtn.onclick = null;
+ };
+
+ cancelBtn.onclick = cleanup;
+
+ saveBtn.onclick = () => {
+ const note = noteTextarea.value.trim();
+ if (note) {
+ applyHighlight("hl-yellow", note);
+ }
+ cleanup();
+ };
}
}
});
diff --git a/library/read/reader_template.php b/library/read/reader_template.php
index bb464ca..9650d56 100644
--- a/library/read/reader_template.php
+++ b/library/read/reader_template.php
@@ -1,4 +1,4 @@
-<?php
+<?php
/**
* library/read/reader_template.php - Unified Digital Reader Template
* Implements distraction-free editorial reading, customizable typography,
@@ -522,6 +522,26 @@ include ABSPATH . 'src/header.php';
</div>
</div>
+
+<!-- Custom Study Note Modal -->
+<div id="note-input-modal" class="modal-overlay hidden" role="dialog" aria-modal="true" aria-labelledby="note-modal-title" style="z-index: 9999;">
+ <div class="modal-card" style="max-width: 400px; padding: 1.5rem;">
+ <div class="modal-card-header" style="border-bottom: none; margin-bottom: 0.5rem; padding-bottom: 0;">
+ <div class="modal-card-title">
+ <div>
+ <h3 id="note-modal-title" style="margin: 0; font-size: 1.25rem;">Add a Study Note</h3>
+ </div>
+ </div>
+ </div>
+ <div class="modal-body">
+ <textarea id="study-note-textarea" rows="4" style="width: 100%; padding: 0.75rem; border-radius: 0.5rem; border: 1px solid var(--color-border); font-family: inherit; margin-bottom: 1rem; resize: none;" placeholder="Type your insights here..."></textarea>
+ <div style="display: flex; justify-content: flex-end; gap: 0.5rem;">
+ <button type="button" id="cancel-note-btn" style="padding: 0.5rem 1rem; border-radius: 0.5rem; border: none; background: transparent; cursor: pointer; font-weight: 600; color: var(--color-text-secondary);">Cancel</button>
+ <button type="button" id="save-note-btn" style="padding: 0.5rem 1.25rem; border-radius: 0.5rem; border: none; background: var(--color-primary, #4f46e5); color: white; cursor: pointer; font-weight: 700; box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);">Save Note</button>
+ </div>
+ </div>
+ </div>
+</div>
<!-- Send metadata to client window context -->
<script>
window.BOOK_METADATA = {
@@ -548,4 +568,4 @@ include ABSPATH . 'src/header.php';
<script src="../../assets/js/reader/read-chapter-citation-generator.js" defer></script>
<script src="../../assets/js/reader/read-scroll-markers.js" defer></script>
-<?php include ABSPATH . 'src/footer.php'; ?>
\ No newline at end of file
+<?php include ABSPATH . 'src/footer.php'; ?>