mirror of
https://github.com/sissbruecker/linkding
synced 2024-11-10 06:04:15 +00:00
Enhance delete links with inline confirmation (#74)
This commit is contained in:
parent
b6b7d3f662
commit
3bab7db023
2 changed files with 43 additions and 2 deletions
|
@ -56,6 +56,13 @@ ul.bookmark-list {
|
||||||
color: darken($gray-color, 10%);
|
color: darken($gray-color, 10%);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.actions .btn-link.bm-remove-confirm {
|
||||||
|
color: $error-color;
|
||||||
|
&:hover {
|
||||||
|
text-decoration: underline;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.bookmark-pagination {
|
.bookmark-pagination {
|
||||||
|
|
|
@ -32,8 +32,7 @@
|
||||||
class="btn btn-link btn-sm">Archive</a>
|
class="btn btn-link btn-sm">Archive</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<a href="{% url 'bookmarks:remove' bookmark.id %}?return_url={{ return_url }}"
|
<a href="{% url 'bookmarks:remove' bookmark.id %}?return_url={{ return_url }}"
|
||||||
class="btn btn-link btn-sm"
|
class="btn btn-link btn-sm bm-remove">Remove</a>
|
||||||
onclick="return confirm('Do you really want to delete this bookmark?')">Remove</a>
|
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
@ -42,3 +41,38 @@
|
||||||
<div class="bookmark-pagination">
|
<div class="bookmark-pagination">
|
||||||
{% pagination bookmarks %}
|
{% pagination bookmarks %}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{# Enhance delete links to show inline confirmation #}
|
||||||
|
<script type="application/javascript">
|
||||||
|
window.addEventListener("load", function () {
|
||||||
|
const linkEls = document.querySelectorAll('.bookmark-list a.bm-remove');
|
||||||
|
|
||||||
|
function showConfirmation(linkEl) {
|
||||||
|
const cancelEl = document.createElement('span');
|
||||||
|
cancelEl.innerText = 'Cancel';
|
||||||
|
cancelEl.className = 'btn btn-link btn-sm bm-remove-confirm mr-1';
|
||||||
|
cancelEl.addEventListener('click', function() {
|
||||||
|
container.remove();
|
||||||
|
linkEl.style = '';
|
||||||
|
});
|
||||||
|
|
||||||
|
const confirmEl = document.createElement('a');
|
||||||
|
confirmEl.innerText = 'Confirm';
|
||||||
|
confirmEl.className = 'btn btn-link btn-delete btn-sm bm-remove-confirm';
|
||||||
|
confirmEl.href = linkEl.href;
|
||||||
|
|
||||||
|
const container = document.createElement('span');
|
||||||
|
container.appendChild(cancelEl);
|
||||||
|
container.appendChild(confirmEl);
|
||||||
|
linkEl.parentElement.appendChild(container);
|
||||||
|
linkEl.style = 'display: none';
|
||||||
|
}
|
||||||
|
|
||||||
|
linkEls.forEach(function (linkEl) {
|
||||||
|
linkEl.addEventListener('click', function (e) {
|
||||||
|
e.preventDefault();
|
||||||
|
showConfirmation(linkEl);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
Loading…
Reference in a new issue