From b6a09c9ebb448584bb469206bf1aaab7638c6d4e Mon Sep 17 00:00:00 2001 From: cuom1999 Date: Sat, 19 Nov 2022 17:30:07 -0600 Subject: [PATCH] Update actionbar share and comment --- resources/libs/clipboard/tooltip.js | 4 ++-- templates/actionbar/list.html | 8 ++++---- templates/actionbar/media-js.html | 14 ++++++++++++++ templates/base.html | 1 + templates/blog/content.html | 1 + templates/comments/list.html | 11 ++++++++--- templates/comments/media-js.html | 17 ++--------------- templates/common-content.html | 1 - templates/problem/feed.html | 1 + templates/submission/status-testcases.html | 4 ++-- 10 files changed, 35 insertions(+), 27 deletions(-) diff --git a/resources/libs/clipboard/tooltip.js b/resources/libs/clipboard/tooltip.js index 6333457..9cce976 100644 --- a/resources/libs/clipboard/tooltip.js +++ b/resources/libs/clipboard/tooltip.js @@ -1,5 +1,5 @@ -function showTooltip(elem, msg) { - elem.setAttribute('class', 'btn-clipboard tooltipped tooltipped-s'); +function showTooltip(elem, msg, direction='s') { + $(elem).addClass('tooltipped tooltipped-' + direction); elem.setAttribute('aria-label', msg); } function fallbackMessage(action) { diff --git a/templates/actionbar/list.html b/templates/actionbar/list.html index 64b8389..d3ca294 100644 --- a/templates/actionbar/list.html +++ b/templates/actionbar/list.html @@ -17,8 +17,8 @@ {% if not hide_actionbar_comment %} - - + + {{_("Comment")}} @@ -33,8 +33,8 @@ {{_("Bookmark")}} - - + + {{_("Share")}} diff --git a/templates/actionbar/media-js.html b/templates/actionbar/media-js.html index 9144ea1..1e3b083 100644 --- a/templates/actionbar/media-js.html +++ b/templates/actionbar/media-js.html @@ -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(); + }) }); {% endcompress %} \ No newline at end of file diff --git a/templates/base.html b/templates/base.html index b771565..a9b3d6b 100644 --- a/templates/base.html +++ b/templates/base.html @@ -91,6 +91,7 @@ {% include "extra_js.html" %} + {% endcompress %} diff --git a/templates/common-content.html b/templates/common-content.html index c809252..52f195b 100644 --- a/templates/common-content.html +++ b/templates/common-content.html @@ -7,7 +7,6 @@ {% block js_media %} {% compress js %} -