Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed higlight action in search results #52

Merged
merged 1 commit into from
Oct 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions internal/webserver/embedded/views/actions.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,10 @@

function highlightToggle(slug, el, method) {
event.preventDefault();
let highlightLinkParent = document.querySelector("#highlight");
let dehighlightLinkParent = document.querySelector("#dehighlight");
let parent = el.closest(".actions")

let highlightLinkParent = parent.querySelector(".highlight");
let dehighlightLinkParent = parent.querySelector(".dehighlight");
fetch(
el.getAttribute("href"), {
method: method,
Expand Down
4 changes: 2 additions & 2 deletions internal/webserver/embedded/views/document.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@
</a>

{{if and (.Session) (ne .Session.Name "")}}
<a href="/highlights" id="highlight" class='btn btn-outline-secondary {{if .Document.Highlighted}}visually-hidden{{end}}' onclick='highlightToggle("{{.Document.Slug}}", this, "POST")'>
<a href="/highlights" class='btn btn-outline-secondary highlight {{if .Document.Highlighted}}visually-hidden{{end}}' onclick='highlightToggle("{{.Document.Slug}}", this, "POST")'>
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-star" viewBox="0 0 16 16">
<path d="M2.866 14.85c-.078.444.36.791.746.593l4.39-2.256 4.389 2.256c.386.198.824-.149.746-.592l-.83-4.73 3.522-3.356c.33-.314.16-.888-.282-.95l-4.898-.696L8.465.792a.513.513 0 0 0-.927 0L5.354 5.12l-4.898.696c-.441.062-.612.636-.283.95l3.523 3.356-.83 4.73zm4.905-2.767-3.686 1.894.694-3.957a.565.565 0 0 0-.163-.505L1.71 6.745l4.052-.576a.525.525 0 0 0 .393-.288L8 2.223l1.847 3.658a.525.525 0 0 0 .393.288l4.052.575-2.906 2.77a.565.565 0 0 0-.163.506l.694 3.957-3.686-1.894a.503.503 0 0 0-.461 0z"/>
</svg>
&nbsp;&nbsp;{{t .Lang "Highlight"}}
</a>
<a href="/highlights" id="dehighlight" class='btn btn-outline-secondary {{if not .Document.Highlighted}}visually-hidden{{end}}' onclick='highlightToggle("{{.Document.Slug}}", this, "DELETE")'>
<a href="/highlights" class='btn btn-outline-secondary dehighlight {{if not .Document.Highlighted}}visually-hidden{{end}}' onclick='highlightToggle("{{.Document.Slug}}", this, "DELETE")'>
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-star-fill" viewBox="0 0 16 16">
<path d="M3.612 15.443c-.386.198-.824-.149-.746-.592l.83-4.73L.173 6.765c-.329-.314-.158-.888.283-.95l4.898-.696L7.538.792c.197-.39.73-.39.927 0l2.184 4.327 4.898.696c.441.062.612.636.282.95l-3.522 3.356.83 4.73c.078.443-.36.79-.746.592L8 13.187l-4.389 2.256z"/>
</svg>
Expand Down
1 change: 0 additions & 1 deletion internal/webserver/embedded/views/highlights.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,3 @@ <h1 class="text-center">{{t .Lang "%s highlights" .Session.Name}}</h1>

{{template "partials/delete-modal" .}}

<script type="text/javascript" src="/js/actions.js"></script>
4 changes: 2 additions & 2 deletions internal/webserver/embedded/views/partials/actions.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
</li>
{{if and (.Session) (ne .Session.Name "")}}
<li class="highlight {{if .Book.Highlighted}}visually-hidden{{end}}">
<a href="/highlights" class="dropdown-item" onclick='highlightToggle("{{.Book.Slug}}", this, "POST")'>
<a href="/highlights" class="dropdown-item highlight" onclick='highlightToggle("{{.Book.Slug}}", this, "POST")'>
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-star" viewBox="0 0 16 16">
<path d="M2.866 14.85c-.078.444.36.791.746.593l4.39-2.256 4.389 2.256c.386.198.824-.149.746-.592l-.83-4.73 3.522-3.356c.33-.314.16-.888-.282-.95l-4.898-.696L8.465.792a.513.513 0 0 0-.927 0L5.354 5.12l-4.898.696c-.441.062-.612.636-.283.95l3.523 3.356-.83 4.73zm4.905-2.767-3.686 1.894.694-3.957a.565.565 0 0 0-.163-.505L1.71 6.745l4.052-.576a.525.525 0 0 0 .393-.288L8 2.223l1.847 3.658a.525.525 0 0 0 .393.288l4.052.575-2.906 2.77a.565.565 0 0 0-.163.506l.694 3.957-3.686-1.894a.503.503 0 0 0-.461 0z"/>
</svg>
Expand All @@ -32,7 +32,7 @@
</li>

<li class="dehighlight {{if not .Book.Highlighted}}visually-hidden{{end}}">
<a href="/highlights" class="dropdown-item" onclick='highlightToggle("{{.Book.Slug}}", this, "DELETE")'>
<a href="/highlights" class="dropdown-item dehighlight" onclick='highlightToggle("{{.Book.Slug}}", this, "DELETE")'>
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-star-fill" viewBox="0 0 16 16">
<path d="M3.612 15.443c-.386.198-.824-.149-.746-.592l.83-4.73L.173 6.765c-.329-.314-.158-.888.283-.95l4.898-.696L7.538.792c.197-.39.73-.39.927 0l2.184 4.327 4.898.696c.441.062.612.636.282.95l-3.522 3.356.83 4.73c.078.443-.36.79-.746.592L8 13.187l-4.389 2.256z"/>
</svg>
Expand Down
Loading