Update actionbar share and comment

This commit is contained in:
cuom1999 2022-11-19 17:30:07 -06:00
parent a5c045986b
commit b6a09c9ebb
10 changed files with 35 additions and 27 deletions

View file

@ -1,5 +1,5 @@
function showTooltip(elem, msg) { function showTooltip(elem, msg, direction='s') {
elem.setAttribute('class', 'btn-clipboard tooltipped tooltipped-s'); $(elem).addClass('tooltipped tooltipped-' + direction);
elem.setAttribute('aria-label', msg); elem.setAttribute('aria-label', msg);
} }
function fallbackMessage(action) { function fallbackMessage(action) {

View file

@ -17,8 +17,8 @@
</span> </span>
</span> </span>
{% if not hide_actionbar_comment %} {% if not hide_actionbar_comment %}
<span class="actionbar-block" id="comment-button"> <span class="actionbar-block">
<span class="actionbar-button"> <span class="actionbar-button actionbar-comment">
<i class="fa fa-comment-o" style="font-size: large;"></i> <i class="fa fa-comment-o" style="font-size: large;"></i>
<span class="actionbar-text">{{_("Comment")}}</span> <span class="actionbar-text">{{_("Comment")}}</span>
</span> </span>
@ -33,8 +33,8 @@
<span class="actionbar-text">{{_("Bookmark")}}</span> <span class="actionbar-text">{{_("Bookmark")}}</span>
</span> </span>
</span> </span>
<span class="actionbar-block" id="share-button" > <span class="actionbar-block" >
<span class="actionbar-button"> <span class="actionbar-button actionbar-share" style="position: relative" {{"share-url=" + share_url if share_url else ""}}>
<i class="fa fa-share" style="font-size: large;"></i> <i class="fa fa-share" style="font-size: large;"></i>
<span class="actionbar-text">{{_("Share")}}</span> <span class="actionbar-text">{{_("Share")}}</span>
</span> </span>

View file

@ -104,7 +104,21 @@
} }
} }
}; };
$(".actionbar-share").click( function() {
link = $(this).attr("share-url") || window.location.href;
navigator.clipboard
.writeText(link)
.then(() => {
showTooltip(this, "Copied link", 'n');
});
});
$('.actionbar-comment').on('click', function() {
if ($('#comment-announcement').length) {
$('#comment-announcement').click();
}
$('#write-comment').click();
})
}); });
</script> </script>
{% endcompress %} {% endcompress %}

View file

@ -91,6 +91,7 @@
<script src="{{ static('libs/select2/select2.js') }}"></script> <script src="{{ static('libs/select2/select2.js') }}"></script>
{% include "extra_js.html" %} {% include "extra_js.html" %}
<script src="{{ static('common.js') }}"></script> <script src="{{ static('common.js') }}"></script>
<script src="{{ static('libs/clipboard/tooltip.js') }}"></script>
<script> <script>
moment.locale('{{ LANGUAGE_CODE }}'); moment.locale('{{ LANGUAGE_CODE }}');
$(function () { $(function () {

View file

@ -46,6 +46,7 @@
{% set bookmark = post.bookmark %} {% set bookmark = post.bookmark %}
{% set hide_actionbar_comment = True %} {% set hide_actionbar_comment = True %}
{% set include_hr = True %} {% set include_hr = True %}
{% set share_url = request.build_absolute_uri(post.get_absolute_url()) %}
{% include "actionbar/list.html" %} {% include "actionbar/list.html" %}
</div> </div>
</section> </section>

View file

@ -1,7 +1,12 @@
{% set can_comment = request.user.is_authenticated and comment_form and not comment_lock %}
<div id="comments" class="comment-area"> <div id="comments" class="comment-area">
<h2 id="comment-header"><i style="padding-right: 0.3em" class="fa fa-comments"></i>{{ _('Comments') }}</h2> <h2 id="comment-header">
<p> <a href="" id="write-comments" > Write comments </a> </p> <i style="padding-right: 0.3em" class="fa fa-comments"></i>{{ _('Comments') }}
{% if request.user.is_authenticated and comment_form and not comment_lock %} {% if can_comment %}
<a href="" id="write-comment" style="float: right; font-size: 0.6em; margin-right: -26px;"> {{ _('Write comment') }} </a>
{% endif %}
</h2>
{% if can_comment %}
<div id="new-comment" class="form-area comment-submit" style="display: none;" > <div id="new-comment" class="form-area comment-submit" style="display: none;" >
{% block comment_submit_title %} {% block comment_submit_title %}
<h3>{{ _('New comment') }}</h3> <h3>{{ _('New comment') }}</h3>

View file

@ -212,25 +212,12 @@
$comment.find('.bad-comment-body').hide(); $comment.find('.bad-comment-body').hide();
}; };
$("#share-button").click( function() { $("#write-comment").click( function(event) {
navigator.clipboard
.writeText(window.location.href)
.then( () => {
alert("Copied link to this post");
});
});
$("#write-comments").click( function(event) {
event.preventDefault(); event.preventDefault();
$("#new-comment").show("slow"); $("#new-comment").show("slow");
$("#write-comments").hide(); $("#write-comment").hide();
}); });
$('#comment-button').click( function() {
$('#comment-section').show();
$('#comment-announcement').hide();
})
}); });
</script> </script>
{% endcompress %} {% endcompress %}

View file

@ -7,7 +7,6 @@
{% block js_media %} {% block js_media %}
{% compress js %} {% compress js %}
<script src="{{ static('libs/clipboard/clipboard.js') }}"></script> <script src="{{ static('libs/clipboard/clipboard.js') }}"></script>
<script src="{{ static('libs/clipboard/tooltip.js') }}"></script>
<script type="text/javascript"> <script type="text/javascript">
$(function () { $(function () {
var info_float = $('.info-float'); var info_float = $('.info-float');

View file

@ -65,6 +65,7 @@
{% set hide_actionbar_comment = True %} {% set hide_actionbar_comment = True %}
{% set pagevote = problem.pagevote %} {% set pagevote = problem.pagevote %}
{% set bookmark = problem.bookmark %} {% set bookmark = problem.bookmark %}
{% set share_url = request.build_absolute_uri(problem.get_absolute_url()) %}
{% include "actionbar/list.html" %} {% include "actionbar/list.html" %}
{% if feed_type=='volunteer' and request.user.has_perm('judge.suggest_problem_changes') %} {% if feed_type=='volunteer' and request.user.has_perm('judge.suggest_problem_changes') %}

View file

@ -28,7 +28,7 @@
{% for batch in batches %} {% for batch in batches %}
<div style="margin-top: 0.5em;"> <div style="margin-top: 0.5em;">
{% if batch.id %} {% if batch.id %}
<b>{{ _('Batch ') }}#{{ loop.index }}: </b> <b>{{ _('Batch ') }}#{{ batch.id }}: </b>
{% endif %} {% endif %}
{% for case in batch.cases %} {% for case in batch.cases %}
<span class="case-{{ case.status }} case-icons"> <span class="case-{{ case.status }} case-icons">
@ -86,7 +86,7 @@
{% set batch_AC = (batch.points == batch.total) %} {% set batch_AC = (batch.points == batch.total) %}
<tr class="case-row" style="background-color: {{ '#d6e8f7' if batch.points == batch.total else 'bisque'}}"> <tr class="case-row" style="background-color: {{ '#d6e8f7' if batch.points == batch.total else 'bisque'}}">
<td> <td>
<b>{{ _('Batch ') }}#{{ loop.index }}</b> <b>{{ _('Batch ') }}#{{ batch.id }}</b>
</td> </td>
<td> <td>
{% if batch_AC %} {% if batch_AC %}