summaryrefslogtreecommitdiffstats
path: root/web_src
diff options
context:
space:
mode:
authorJohn Olheiser <42128690+jolheiser@users.noreply.github.com>2019-11-19 12:33:42 -0600
committerLauris BH <lauris@nix.lv>2019-11-19 20:33:42 +0200
commiteb0359cad4b725553c8bca3e95ada9c789c5da0b (patch)
tree2c0fe67141d8d4bafe785c5bf22f0d3b35d64866 /web_src
parentaf7f08bca87852d453848be93e2044e697820b87 (diff)
downloadgitea-eb0359cad4b725553c8bca3e95ada9c789c5da0b.tar.gz
gitea-eb0359cad4b725553c8bca3e95ada9c789c5da0b.zip
Context menus for comments (#9043)
* Add quote replies Signed-off-by: jolheiser <john.olheiser@gmail.com>
Diffstat (limited to 'web_src')
-rw-r--r--web_src/js/index.js40
-rw-r--r--web_src/less/_repository.less4
2 files changed, 39 insertions, 5 deletions
diff --git a/web_src/js/index.js b/web_src/js/index.js
index 671c66f689..7ef036885b 100644
--- a/web_src/js/index.js
+++ b/web_src/js/index.js
@@ -732,10 +732,41 @@ function initRepository() {
return false;
});
+ // Issue/PR Context Menus
+ $('.context-dropdown').dropdown({
+ action: 'hide'
+ });
+
+ // Quote reply
+ $('.quote-reply').click(function (event) {
+ $(this).closest('.dropdown').find('.menu').toggle('visible');
+ const target = $(this).data('target');
+
+ let $content;
+ if ($(this).hasClass('quote-reply-diff')) {
+ const $parent = $(this).closest('.comment-code-cloud');
+ $parent.find('button.comment-form-reply').click();
+ $content = $parent.find('[name="content"]');
+ } else {
+ $content = $('#content');
+ }
+
+ const quote = $(`#comment-${target}`).text().replace(/\n/g, '\n> ');
+ const content = `> ${quote}\n\n`;
+
+ if ($content.val() !== '') {
+ $content.val(`${$content.val()}\n\n${content}`);
+ } else {
+ $content.val(`${content}`);
+ }
+ $content.focus();
+ event.preventDefault();
+ });
+
// Edit issue or comment content
- $('.edit-content').click(function () {
- const $segment = $(this).parent().parent().parent()
- .next();
+ $('.edit-content').click(function (event) {
+ $(this).closest('.dropdown').find('.menu').toggle('visible');
+ const $segment = $(this).closest('.header').next();
const $editContentZone = $segment.find('.edit-content-zone');
const $renderContent = $segment.find('.render-content');
const $rawContent = $segment.find('.raw-content');
@@ -881,7 +912,7 @@ function initRepository() {
$textarea.val($rawContent.text());
}
$textarea.focus();
- return false;
+ event.preventDefault();
});
// Delete comment
@@ -931,7 +962,6 @@ function initRepository() {
$(this).closest('.form').hide();
$mergeButton.parent().show();
});
-
initReactionSelector();
}
diff --git a/web_src/less/_repository.less b/web_src/less/_repository.less
index 86661af428..e0537245ef 100644
--- a/web_src/less/_repository.less
+++ b/web_src/less/_repository.less
@@ -748,6 +748,10 @@
.item {
float: left;
+ &.context {
+ float: none;
+ }
+
&.tag {
margin-right: 5px;
}