Skip to content

Commit e08b3a5

Browse files
modmew8lafriks
authored andcommitted
Emoji Autocomplete (#3433)
* Implemented emoji autocomplete. * Changed emoji access url. * Reverted vendor css to default, moved all style changes to _tribute.less * Made no-results overwriteable, added missing autocomplete to edit issue field. Signed-off-by: modmew8 <modmew8@gmail.com>
1 parent b62ce2e commit e08b3a5

File tree

6 files changed

+64
-17
lines changed

6 files changed

+64
-17
lines changed

public/css/index.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

public/js/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -571,6 +571,7 @@ function initRepository() {
571571
$editContentZone.html($('#edit-content-form').html());
572572
$textarea = $segment.find('textarea');
573573
issuesTribute.attach($textarea.get());
574+
emojiTribute.attach($textarea.get());
574575

575576
// Give new write/preview data-tab name to distinguish from others
576577
var $editContentForm = $editContentZone.find('.ui.comment.form');

public/less/_tribute.less

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
.tribute-container {
2+
box-shadow: 0px 1px 3px 1px #c7c7c7;
3+
ul {
4+
background: #ffffff;
5+
}
6+
li {
7+
padding: 8px 12px;
8+
border-bottom: 1px solid #dcdcdc;
9+
img {
10+
display: inline-block;
11+
vertical-align: middle;
12+
width: 28px;
13+
height: 28px;
14+
margin-right: 5px;
15+
}
16+
span.fullname {
17+
font-weight: normal;
18+
font-size: 0.8rem;
19+
margin-left: 3px;
20+
}
21+
}
22+
li.highlight, li:hover {
23+
background: #2185D0;
24+
color: #ffffff;
25+
}
26+
}

public/less/index.less

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
@import "_tribute";
12
@import "_emojify";
23
@import "_base";
34
@import "_markdown";

public/vendor/plugins/tribute/tribute.css

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,33 +7,20 @@
77
max-width: 500px;
88
overflow: auto;
99
display: block;
10-
box-shadow: 0px 1px 3px 1px #c7c7c7;
1110
z-index: 999999; }
1211
.tribute-container ul {
1312
margin: 0;
1413
margin-top: 2px;
1514
padding: 0;
1615
list-style: none;
17-
background: #ffffff; }
16+
background: #efefef; }
1817
.tribute-container li {
19-
padding: 8px 12px;
20-
border-bottom: 1px solid #dcdcdc;
18+
padding: 5px 5px;
2119
cursor: pointer; }
2220
.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-
}
21+
background: #ddd; }
3122
.tribute-container li span {
3223
font-weight: bold; }
33-
.tribute-container li span.fullname {
34-
font-weight: normal;
35-
font-size: 0.8rem;
36-
margin-left: 3px;}
3724
.tribute-container li.no-match {
3825
cursor: default; }
3926
.tribute-container .menu-highlighted {

templates/base/footer.tmpl

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,38 @@
8989
issuesTribute.attach(document.getElementById('content'))
9090
</script>
9191
{{end}}
92+
<script>
93+
var emojiTribute = new Tribute({
94+
collection: [{
95+
trigger: ':',
96+
requireLeadingSpace: true,
97+
values: function (text, cb) {
98+
var array = emojify.emojiNames;
99+
var data = [];
100+
for(var j=0; j<array.length; j++) {
101+
if(array[j].indexOf(text) !== -1) {
102+
data.push(array[j]);
103+
if(data.length > 5) {
104+
break;
105+
}
106+
}
107+
}
108+
cb(data);
109+
},
110+
lookup: function (item) {
111+
return item;
112+
},
113+
selectTemplate: function (item) {
114+
if (typeof item === 'undefinied') return null;
115+
return ':' + item.original + ':';
116+
},
117+
menuItemTemplate: function (item) {
118+
return '<img class="emoji" src="{{AppSubUrl}}/vendor/plugins/emojify/images/' + item.original + '.png"/>' + item.original;
119+
}
120+
}]
121+
});
122+
emojiTribute.attach(document.getElementById('content'))
123+
</script>
92124
{{end}}
93125
<script src="{{AppSubUrl}}/vendor/plugins/autolink/autolink.js"></script>
94126
<script src="{{AppSubUrl}}/vendor/plugins/emojify/emojify.min.js"></script>

0 commit comments

Comments
 (0)