Its very easy to add emoji icons/images to your rails application.
It seems complex but its all easy using javascript.The steps can be simplified as shown below:-
first you need to add this wonderful js which works really great and nice from home page.It seems complex but its all easy using javascript.The steps can be simplified as shown below:-
- add the javascript(download jemotion)
- include it in your view file(where you want :) to be shown as this ----------------------->
- thats it....done
We are interested in only the js and emotions folder(containing the smileys/GIF images).
once you download just include it in your view file and copy/dump the emotions folder(containing images) to app/assets/images for RAILS 3+. as i did where i want the users to view their comments after they submit their comment.
You also need to give a unique id to make the js understand where it needs to convert your symbols to icons.see below code and hope you will understand how to use it.
Keep in mind two thing:-
- dont forget to give an id to your div/p tag where user enter their comments
- include it in your view and not your layout file.
Here comes the js and the code:-
===============javascript===============================
<%= javascript_include_tag "jemotion/jemotion"%>
//add this in your script tag
$(document).ready(function(){
var opt = {
handle: '#emotion',
//i dumped the emotions folder to app/assets/images and changed this path
dir: 'assets/emotions/',
label_on: 'On Emotions',
label_off: 'Off Emotions',
style: 'background: #eee',
css: 'class2'
}
$('.emotion').emotions(opt);
});
##my id emotion to show all :) as emotions mapped in jemotion.js
##snippet from js file: {syntax: ':D',title: 'big grin',icon: '6.gif'}
<%= content_tag :div, id: "emotion" do -%>
<%= comment.description%>
<%end%>
<%end%>
<%end%>
<% if !@video.comments.empty?%>
<% @video.comments.each do |comment|%>