Skip to content

Commit

Permalink
fix: Share view bugs (#390)
Browse files Browse the repository at this point in the history
* fix: Prevent adblock killing share buttons

* fix: Order of execution bug in firing events
  • Loading branch information
yammesicka authored Apr 6, 2024
1 parent fb6bdb0 commit c972d23
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
3 changes: 3 additions & 0 deletions lms/static/shared.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
window.addEventListener('load', () => {
window.dispatchEvent(new Event('defined-window-variables'));
});
2 changes: 1 addition & 1 deletion lms/static/solution.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ function addLineSpansToPre(items) {

window.addEventListener('defined-window-variables', () => {
addLineSpansToPre(document.getElementsByTagName('code'));
});
}, { once: true });
8 changes: 5 additions & 3 deletions lms/templates/view.html
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ <h1>{{ _('Exercise view') }} {{ solution['exercise']['number'] }}: {{ solution['
<button id="share-action" title="Share solution"><i class="fa fa-share-alt"></i></button>
</div>
<div id="shared-box" class="glowing d-none">
<button id="cancel-share" class="share-button" title="Disable share solution"><i class="fa fa-trash"></i></button>
<button id="copy-link" class="share-button" title="Copy shared link"><i class="fa fa-copy"></i></button>
<button id="cancel-share" title="Disable share solution"><i class="fa fa-trash"></i></button>
<button id="copy-link" title="Copy shared link"><i class="fa fa-copy"></i></button>
<input id="shareable-link" class="form-control" type="text" readonly>
</div>
</div>
Expand Down Expand Up @@ -151,7 +151,9 @@ <h2>{{ _('Comments for this exercise') }}</h2>
</div>
<script src="{{ url_for('static', filename='prism.js') }}"></script>
<script src="{{ url_for('static', filename='solution.js') }}"></script>
{% if not shared_url %}
{% if shared_url %}
<script src="{{ url_for('static', filename='shared.js') }}"></script>
{% else %}
{% include 'comment-template.html' %}
<script src="{{ url_for('static', filename='purify.js') }}"></script>
<script src="{{ url_for('static', filename='markdown.js') }}"></script>
Expand Down

0 comments on commit c972d23

Please sign in to comment.