diff options
author | Lauris BH <lauris@nix.lv> | 2017-12-04 01:14:26 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-12-04 01:14:26 +0200 |
commit | 5dc37b187c8b839a15ff73758799f218ddeb3bc9 (patch) | |
tree | b63e5ca72c7b9e72c79408ace82dfcba992b5793 /public/js | |
parent | e59adcde655aac0e8afd3249407c9a0a2b1b1d6b (diff) | |
download | gitea-5dc37b187c8b839a15ff73758799f218ddeb3bc9.tar.gz gitea-5dc37b187c8b839a15ff73758799f218ddeb3bc9.zip |
Add reactions to issues/PR and comments (#2856)
Diffstat (limited to 'public/js')
-rw-r--r-- | public/js/index.js | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/public/js/index.js b/public/js/index.js index fb31387544..c56030f349 100644 --- a/public/js/index.js +++ b/public/js/index.js @@ -117,6 +117,54 @@ function updateIssuesMeta(url, action, issueIds, elementId, afterSuccess) { }) } +function initReactionSelector(parent) { + var reactions = ''; + if (!parent) { + parent = $(document); + reactions = '.reactions > '; + } + + parent.find(reactions + 'a.label').popup({'position': 'bottom left', 'metadata': {'content': 'title', 'title': 'none'}}); + + parent.find('.select-reaction > .menu > .item, ' + reactions + 'a.label').on('click', function(e){ + var vm = this; + e.preventDefault(); + + if ($(this).hasClass('disabled')) return; + + var actionURL = $(this).hasClass('item') ? + $(this).closest('.select-reaction').data('action-url') : + $(this).data('action-url'); + var url = actionURL + '/' + ($(this).hasClass('blue') ? 'unreact' : 'react'); + $.ajax({ + type: 'POST', + url: url, + data: { + '_csrf': csrf, + 'content': $(this).data('content') + } + }).done(function(resp) { + if (resp && (resp.html || resp.empty)) { + var content = $(vm).closest('.content'); + var react = content.find('.segment.reactions'); + if (react.length > 0) { + react.remove(); + } + if (!resp.empty) { + react = $('<div class="ui attached segment reactions"></div>').appendTo(content); + react.html(resp.html); + var hasEmoji = react.find('.has-emoji'); + for (var i = 0; i < hasEmoji.length; i++) { + emojify.run(hasEmoji.get(i)); + } + react.find('.dropdown').dropdown(); + initReactionSelector(react); + } + } + }); + }); +} + function initCommentForm() { if ($('.comment.form').length == 0) { return @@ -594,6 +642,7 @@ function initRepository() { $('#status').val($statusButton.data('status-val')); $('#comment-form').submit(); }); + initReactionSelector(); } // Diff |