Skip to content

Commit d15ae20

Browse files
committed
Add emoji to labels
Minor cleanup of tribute code in footer.tmpl Signed-off-by: jolheiser <[email protected]>
1 parent 7a72aa6 commit d15ae20

File tree

7 files changed

+25
-14
lines changed

7 files changed

+25
-14
lines changed

options/locale/locale_en-US.ini

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -690,8 +690,8 @@ issues.label_templates.info = No labels exist yet. Create a label with 'New Labe
690690
issues.label_templates.helper = Select a label set
691691
issues.label_templates.use = Use Label Set
692692
issues.label_templates.fail_to_load_file = Failed to load label template file '%s': %v
693-
issues.add_label_at = added the <div class="ui label" style="color: %s\; background-color: %s">%s</div> label %s
694-
issues.remove_label_at = removed the <div class="ui label" style="color: %s\; background-color: %s">%s</div> label %s
693+
issues.add_label_at = added the <div class="ui label has-emoji" style="color: %s\; background-color: %s">%s</div> label %s
694+
issues.remove_label_at = removed the <div class="ui label has-emoji" style="color: %s\; background-color: %s">%s</div> label %s
695695
issues.add_milestone_at = `added this to the <b>%s</b> milestone %s`
696696
issues.change_milestone_at = `modified the milestone from <b>%s</b> to <b>%s</b> %s`
697697
issues.remove_milestone_at = `removed this from the <b>%s</b> milestone %s`

routers/repo/issue_label.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ func Labels(ctx *context.Context) {
2222
ctx.Data["PageIsIssueList"] = true
2323
ctx.Data["PageIsLabels"] = true
2424
ctx.Data["RequireMinicolors"] = true
25+
ctx.Data["RequireTribute"] = true
2526
ctx.Data["LabelTemplates"] = models.LabelTemplates
2627
ctx.HTML(200, tplLabels)
2728
}

templates/base/footer.tmpl

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,11 @@
6868
}
6969
return itemStr;
7070
}
71-
})
72-
issuesTribute.attach(document.getElementById('content'))
71+
});
72+
var content = document.getElementById('content');
73+
if (content != null) {
74+
issuesTribute.attach(content);
75+
}
7376
</script>
7477
<script>
7578
var emojiTribute = new Tribute({
@@ -93,15 +96,22 @@
9396
return item;
9497
},
9598
selectTemplate: function (item) {
96-
if (typeof item === 'undefinied') return null;
99+
if (typeof item === 'undefined') return null;
97100
return ':' + item.original + ':';
98101
},
99102
menuItemTemplate: function (item) {
100103
return '<img class="emoji" src="{{AppSubUrl}}/vendor/plugins/emojify/images/' + item.original + '.png"/>' + item.original;
101104
}
102105
}]
103106
});
104-
emojiTribute.attach(document.getElementById('content'))
107+
var emojiInputs = document.querySelectorAll('.emoji-input');
108+
if (emojiInputs.length > 0) {
109+
emojiTribute.attach(emojiInputs);
110+
}
111+
var content = document.getElementById('content');
112+
if (content != null) {
113+
emojiTribute.attach(document.getElementById('content'));
114+
}
105115
</script>
106116
{{end}}
107117
<script src="{{AppSubUrl}}/vendor/plugins/emojify/emojify.min.js"></script>

templates/repo/issue/labels.tmpl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
<div class="ui grid">
1818
<div class="three wide column">
1919
<div class="ui small input">
20-
<input class="new-label-input" name="title" placeholder="{{.i18n.Tr "repo.issues.new_label_placeholder"}}" autofocus required>
20+
<input class="new-label-input emoji-input" name="title" placeholder="{{.i18n.Tr "repo.issues.new_label_placeholder"}}" autofocus required>
2121
</div>
2222
</div>
2323
<div class="five wide column">
@@ -98,7 +98,7 @@
9898
<li class="item">
9999
<div class="ui grid">
100100
<div class="three wide column">
101-
<div class="ui label" style="color: {{.ForegroundColor}}; background-color: {{.Color}}"><i class="octicon octicon-tag"></i> {{.Name}}</div>
101+
<div class="ui label has-emoji" style="color: {{.ForegroundColor}}; background-color: {{.Color}}"><i class="octicon octicon-tag"></i> {{.Name}}</div>
102102
</div>
103103
<div class="seven wide column">
104104
{{.Description}}
@@ -151,7 +151,7 @@
151151
<div class="ui grid">
152152
<div class="three wide column">
153153
<div class="ui small input">
154-
<input class="new-label-input" name="title" placeholder="{{.i18n.Tr "repo.issues.new_label_placeholder"}}" autofocus required>
154+
<input class="new-label-input emoji-input" name="title" placeholder="{{.i18n.Tr "repo.issues.new_label_placeholder"}}" autofocus required>
155155
</div>
156156
</div>
157157
<div class="five wide column">

templates/repo/issue/list.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@
192192
<a class="ui label" href="{{$.RepoLink}}/src/branch/{{.Ref}}">{{.Ref}}</a>
193193
{{end}}
194194
{{range .Labels}}
195-
<a class="ui label" href="{{$.Link}}?q={{$.Keyword}}&type={{$.ViewType}}&state={{$.State}}&labels={{.ID}}&milestone={{$.MilestoneID}}&assignee={{$.AssigneeID}}" style="color: {{.ForegroundColor}}; background-color: {{.Color}}" title="{{.Description}}">{{.Name}}</a>
195+
<a class="ui label has-emoji" href="{{$.Link}}?q={{$.Keyword}}&type={{$.ViewType}}&state={{$.State}}&labels={{.ID}}&milestone={{$.MilestoneID}}&assignee={{$.AssigneeID}}" style="color: {{.ForegroundColor}}; background-color: {{.Color}}" title="{{.Description}}">{{.Name}}</a>
196196
{{end}}
197197

198198
{{if .NumComments}}

templates/repo/issue/new_form.tmpl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,14 @@
4646
<div class="filter menu" data-id="#label_ids">
4747
<div class="no-select item">{{.i18n.Tr "repo.issues.new.clear_labels"}}</div>
4848
{{range .Labels}}
49-
<a class="{{if .IsChecked}}checked{{end}} item" href="#" data-id="{{.ID}}" data-id-selector="#label_{{.ID}}"><span class="octicon {{if .IsChecked}}octicon-check{{end}}"></span><span class="label color" style="background-color: {{.Color}}"></span> {{.Name}}</a>
49+
<a class="{{if .IsChecked}}checked{{end}} item has-emoji" href="#" data-id="{{.ID}}" data-id-selector="#label_{{.ID}}"><span class="octicon {{if .IsChecked}}octicon-check{{end}}"></span><span class="label color" style="background-color: {{.Color}}"></span> {{.Name}}</a>
5050
{{end}}
5151
</div>
5252
</div>
5353
<div class="ui labels list">
5454
<span class="no-select item {{if .HasSelectedLabel}}hide{{end}}">{{.i18n.Tr "repo.issues.new.no_label"}}</span>
5555
{{range .Labels}}
56-
<a class="{{if not .IsChecked}}hide{{end}} item" id="label_{{.ID}}" href="{{$.RepoLink}}/issues?labels={{.ID}}"><span class="label color" style="background-color: {{.Color}}"></span> <span class="text">{{.Name}}</span></a>
56+
<a class="{{if not .IsChecked}}hide{{end}} item" id="label_{{.ID}}" href="{{$.RepoLink}}/issues?labels={{.ID}}"><span class="label color" style="background-color: {{.Color}}"></span> <span class="text has-emoji">{{.Name}}</span></a>
5757
{{end}}
5858
</div>
5959

templates/repo/issue/view_content/sidebar.tmpl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<div class="filter menu" data-action="update" data-issue-id="{{$.Issue.ID}}" data-update-url="{{$.RepoLink}}/issues/labels">
1111
<div class="no-select item">{{.i18n.Tr "repo.issues.new.clear_labels"}}</div>
1212
{{range .Labels}}
13-
<a class="{{if .IsChecked}}checked{{end}} item" href="#" data-id="{{.ID}}" data-id-selector="#label_{{.ID}}"><span class="octicon {{if .IsChecked}}octicon-check{{end}}"></span><span class="label color" style="background-color: {{.Color}}"></span> {{.Name}}
13+
<a class="{{if .IsChecked}}checked{{end}} item has-emoji" href="#" data-id="{{.ID}}" data-id-selector="#label_{{.ID}}"><span class="octicon {{if .IsChecked}}octicon-check{{end}}"></span><span class="label color" style="background-color: {{.Color}}"></span> {{.Name}}
1414
{{if .Description }}<br><small class="desc">{{.Description}}</small>{{end}}</a>
1515
{{end}}
1616
</div>
@@ -19,7 +19,7 @@
1919
<span class="no-select item {{if .HasSelectedLabel}}hide{{end}}">{{.i18n.Tr "repo.issues.new.no_label"}}</span>
2020
{{range .Labels}}
2121
<div class="item">
22-
<a class="ui label {{if not .IsChecked}}hide{{end}}" id="label_{{.ID}}" href="{{$.RepoLink}}/issues?labels={{.ID}}" style="color: {{.ForegroundColor}}; background-color: {{.Color}}" title="{{.Description}}">{{.Name}}</a>
22+
<a class="ui label has-emoji {{if not .IsChecked}}hide{{end}}" id="label_{{.ID}}" href="{{$.RepoLink}}/issues?labels={{.ID}}" style="color: {{.ForegroundColor}}; background-color: {{.Color}}" title="{{.Description}}">{{.Name}}</a>
2323
</div>
2424

2525
{{end}}

0 commit comments

Comments
 (0)