Skip to content

Commit 03ec35e

Browse files
harryxulunny
authored andcommitted
Mention completion for issue editor. (#3136)
* new issue mention * Mention completion on new issue and view issue page. * Code format. * Require tribute in pull request page.
1 parent f2e20c8 commit 03ec35e

File tree

7 files changed

+76
-0
lines changed

7 files changed

+76
-0
lines changed

public/js/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -570,6 +570,7 @@ function initRepository() {
570570
if ($editContentZone.html().length == 0) {
571571
$editContentZone.html($('#edit-content-form').html());
572572
$textarea = $segment.find('textarea');
573+
issuesTribute.attach($textarea.get());
573574

574575
// Give new write/preview data-tab name to distinguish from others
575576
var $editContentForm = $editContentZone.find('.ui.comment.form');
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
.tribute-container {
2+
position: absolute;
3+
top: 0;
4+
left: 0;
5+
height: auto;
6+
max-height: 300px;
7+
max-width: 500px;
8+
overflow: auto;
9+
display: block;
10+
box-shadow: 0px 1px 3px 1px #c7c7c7;
11+
z-index: 999999; }
12+
.tribute-container ul {
13+
margin: 0;
14+
margin-top: 2px;
15+
padding: 0;
16+
list-style: none;
17+
background: #ffffff; }
18+
.tribute-container li {
19+
padding: 8px 12px;
20+
border-bottom: 1px solid #dcdcdc;
21+
cursor: pointer; }
22+
.tribute-container li.highlight, .tribute-container li:hover {
23+
background: #2185D0;
24+
color: #ffffff;}
25+
.tribute-container li img {
26+
display: inline-block;
27+
vertical-align: middle;
28+
width: 28px;
29+
margin-right: 5px;
30+
}
31+
.tribute-container li span {
32+
font-weight: bold; }
33+
.tribute-container li span.fullname {
34+
font-weight: normal;
35+
font-size: 0.8rem;
36+
margin-left: 3px;}
37+
.tribute-container li.no-match {
38+
cursor: default; }
39+
.tribute-container .menu-highlighted {
40+
font-weight: bold; }

public/vendor/plugins/tribute/tribute.min.js

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

routers/repo/issue.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,7 @@ func NewIssue(ctx *context.Context) {
351351
ctx.Data["PageIsIssueList"] = true
352352
ctx.Data["RequireHighlightJS"] = true
353353
ctx.Data["RequireSimpleMDE"] = true
354+
ctx.Data["RequireTribute"] = true
354355
setTemplateIfExists(ctx, issueTemplateKey, IssueTemplateCandidates)
355356
renderAttachmentSettings(ctx)
356357

@@ -478,6 +479,7 @@ func NewIssuePost(ctx *context.Context, form auth.CreateIssueForm) {
478479
func ViewIssue(ctx *context.Context) {
479480
ctx.Data["RequireHighlightJS"] = true
480481
ctx.Data["RequireDropzone"] = true
482+
ctx.Data["RequireTribute"] = true
481483
renderAttachmentSettings(ctx)
482484

483485
issue, err := models.GetIssueByIndex(ctx.Repo.Repository.ID, ctx.ParamsInt64(":index"))

routers/repo/pull.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -701,6 +701,7 @@ func CompareAndPullRequest(ctx *context.Context) {
701701
ctx.Data["PageIsComparePull"] = true
702702
ctx.Data["IsDiffCompare"] = true
703703
ctx.Data["RequireHighlightJS"] = true
704+
ctx.Data["RequireTribute"] = true
704705
setTemplateIfExists(ctx, pullRequestTemplateKey, pullRequestTemplateCandidates)
705706
renderAttachmentSettings(ctx)
706707

templates/base/footer.tmpl

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,32 @@
5757
{{end}}
5858
{{if .RequireDropzone}}
5959
<script src="{{AppSubUrl}}/vendor/plugins/dropzone/dropzone.js"></script>
60+
{{end}}
61+
{{if .RequireTribute}}
62+
<script src="{{AppSubUrl}}/vendor/plugins/tribute/tribute.min.js"></script>
63+
64+
{{if .Assignees}}
65+
<script>
66+
var issuesTribute = new Tribute({
67+
values: [
68+
{{ range .Assignees }}
69+
{key: '{{.Name}} {{.FullName}}', value: '{{.Name}}',
70+
name: '{{.Name}}', fullname: '{{.FullName}}', avatar: '{{.RelAvatarLink}}'},
71+
{{ end }}
72+
],
73+
noMatchTemplate: function () { return null },
74+
menuItemTemplate: function (item) {
75+
var user = item.original;
76+
var itemStr = '<img src="' + user.avatar + '"/><span class="name">' + user.name + '</span>';
77+
if (user.fullname && user.fullname != '') {
78+
itemStr += '<span class="fullname">' + user.fullname + '</span>';
79+
}
80+
return itemStr;
81+
}
82+
})
83+
issuesTribute.attach(document.getElementById('content'))
84+
</script>
85+
{{end}}
6086
{{end}}
6187
<script src="{{AppSubUrl}}/vendor/plugins/autolink/autolink.js"></script>
6288
<script src="{{AppSubUrl}}/vendor/plugins/emojify/emojify.min.js"></script>

templates/base/head.tmpl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,10 @@
7474
<link rel="stylesheet" href="{{AppSubUrl}}/vendor/plugins/gitgraph/gitgraph.css">
7575
{{end}}
7676

77+
{{if .RequireTribute}}
78+
<link rel="stylesheet" href="{{AppSubUrl}}/vendor/plugins/tribute/tribute.css">
79+
{{end}}
80+
7781
<!-- Stylesheet -->
7882
<link rel="stylesheet" href="{{AppSubUrl}}/vendor/plugins/semantic/semantic.min.css">
7983
<link rel="stylesheet" href="{{AppSubUrl}}/css/index.css?v={{MD5 AppVer}}">

0 commit comments

Comments
 (0)