Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Emoji autocomplete #2832

Merged
merged 7 commits into from
Jun 18, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/assets/javascripts/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
//= require short-code-forms/dist/short-code-prompts.js
//= require wikis.js
//= require chart.js/dist/Chart.js
//= require horsey.js
//= require header_footer.js
// require turbolinks // Temporarily removed while fixing

12 changes: 11 additions & 1 deletion app/assets/stylesheets/comments.css
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,14 @@

#question-comment-form {
width: 90%;
}
}

.sey-item b {
font-weight: 300;
font-size: 20px;
}

.sey-item span {
margin-bottom: 0;
margin-left: 4px;
}
12 changes: 12 additions & 0 deletions app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,18 @@ def emojify(content)
end if content.present?
end

def emoji_names_list
emojis = []
image_map = {}
Emoji.all.each do |e|
next unless e.raw
val = ":#{e.name}:"
emojis<<{ value: val, text: e.name }
image_map[e.name] = e.raw
end
{ emojis: emojis, image_map: image_map }
end

def feature(title)
features = Node.where(type: 'feature', title: title)
if !features.empty?
Expand Down
3 changes: 0 additions & 3 deletions app/views/comments/_edit.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@

</div>
</div>

<script type="application/javascript">
jQuery(document).ready(function() {
$E.initialize();
Expand Down Expand Up @@ -148,5 +147,3 @@
<%= t('comments._edit.email_notifications') %>
</p>
</form>


16 changes: 15 additions & 1 deletion app/views/comments/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@

<div class="well col-md-11" id="preview" style="background:white;display: none">
</div>
<link href="/lib/horsey/dist/horsey.min.css" rel="stylesheet">

<script>
jQuery(document).ready(function() {
Expand All @@ -64,11 +65,24 @@
</script>

<%= javascript_include_tag "dragdrop" %>
<script>
<script>
$('#comment-form').bind('ajax:beforeSend', function(event){
$("#text-input").prop('disabled',true)
$("#comment-form .btn-primary").button('loading',true);
});
<% emoji_names = emoji_names_list %>
<% emojis = emoji_names[:emojis] %>
<% image_map = emoji_names[:image_map] %>
var image_map = <%= raw image_map.to_json %>
horsey(document.querySelector('textarea#text-input'), {
suggestions: (<%= raw emojis.to_json %>),
anchor: ':',
render: function (li, suggestion) {
var image = image_map[suggestion.text];
li.innerHTML = "<b>"+image+"</b><span>"+suggestion.text+"</span>";
},
limit: 6
});

$('#comment-form').bind('ajax:success', function(e, data, status, xhr){
$('#text-input').prop('disabled',false);
Expand Down
4 changes: 3 additions & 1 deletion config/initializers/assets.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@
'style.css',
'tags.css',
'user_tags.css.scss',
'wiki.css'
'wiki.css',
'horsey.js',
'comment-autocomplete'
]