HTML comment box with emoticons. The emoticons are loaded through Json data, and you can change the emoticons according to your own preferences. The code of this comment box is HTML, CSS, and JQ code. Figure 1 shows the original state, and Figure 2 shows the list of expressions that appears when you click on the expression. You can select one or more at will. Let's take a look at the implemented code.
Picture 1
Picture 2
Implemented code:
html code:
XML/HTML CodeCopy content to clipboard
- <div class="Main" >
-
<div class="Input_Box" >
-
<textarea class="Input_text" >textarea>
-
<div class="faceDiv" > div>
-
<div class="Input_Foot" > <a class="imgBtn" href="javascript:void(0);"> ;a><a class="postBtn">OKa > div>
- div>
- div>
css3 code:
CSS Code
Copy content to clipboard
Javascript code:
JavaScript Code
Copy content to clipboard
- var ImgIputHandler={
- facePath:[
-
{faceName:"smile",facePath:"0_smile.gif"},
- {FACENAME: "🎜> , Facepath: " 1_ 撇 撇 .gif " >
{faceName:
"色"-
,facePath:"2_色.gif"},
{FACENAME: "Duke"
- , Facepath: "3_ Duke .gif" },
{faceName:"Deyi"
- ,facePath:"4_Deyi.gif"},
>
{faceName:-
"shy",facePath:"6_shy.gif"},
{faceName:-
"Shut up", facePath:"7_Shut up.gif"},
{faceName:-
"crying", facePath:"9_crying.gif"},
{faceName:-
"Awkward",facePath:"10_awkward.gif"},
{faceName:-
"angry",facePath:"11_angry.gif"},
{FACENAME:
- "Naughty" , FacePath: "12_ 皮 .gif" },
{faceName:
- "Barteeth",facePath:"13_Bargain.gif"},
{faceName:
- "surprise",facePath:"14_surprise.gif"},
{faceName:
- "sad",facePath:"15_sad.gif"},
{faceName:
- "Cool",facePath:"16_cool.gif"},
{faceName:
- "Cold Sweat",facePath:"17_Cold Sweat.gif"}, >
{faceName:
"Crazy"-
,facePath:"18_Crazy.gif"},
-
{faceName:"vomit",facePath:"19_vomit.gif"},
- {FACENAME: "Smiling" , FacePath: "20_linking .gif" },
- {faceName:"cute",facePath:"21_cute.gif"},
- {faceName:"White Eyes",facePath:"22_White Eyes.gif"},
- {faceName:"arrogance",facePath:"23_arrogance.gif"},
- {faceName:"hunger",facePath:"24_hunger.gif"},
- {faceName:"trapped",facePath:"25_trapped.gif"},
- {faceName:"Horror",facePath:"26_Horror.gif"},
- {faceName:"sweat", facePath:"27_sweat.gif"},
{FACENAME: - "憨" , facepath: "28_ 憨 笑 .gif" },
{faceName:-
"GI",facePath:"29_GI.gif"},
{faceName:-
"struggle",facePath:"30_struggle.gif"},
{faceName:-
"curse",facePath:"31_curse.gif"},
{faceName:-
"question",facePath:"32_question.gif"},
{faceName:-
"Sh",facePath:"33_boo.gif"},
{faceName:-
"halo",facePath:"34_halo.gif"},
{faceName:-
"torture",facePath:"35_torture.gif"},
{FACENAME:
- "decline" , FacePath: "36_ 衰 .gif" },
{faceName:
- "Skeleton",facePath:"37_skeleton.gif"},
- {FACENAME: "Tap" , Facepath: "38_ hit .gif" },
- {faceName:"Goodbye",facePath:"39_Goodbye.gif"},
- {faceName:"wipe sweat", facePath:"40_wipe sweat.gif"},
-
{faceName:
- "picking your nose", facePath:"41_picking your nose.gif"},
{faceName:
- "Applause",facePath:"42_Applause.gif"},
{faceName:
- "I'm so embarrassed", facePath:"43_I'm embarrassed.gif" },
{faceName:
- "bad smile", facePath:"44_bad smile.gif"},
{faceName:
- "Zuo Hengheng", facePath:"45_left Hengheng.gif" },
{FACENAME:
"Right Hum" - , FacePath: "46_ right hum .gif" },
{faceName:
"Yawn"-
,facePath:"47_yawn.gif"},
{faceName:
"Contempt"-
,facePath:"48_Contempt.gif"},
{faceName:
"grievance"-
,facePath:"49_grievance.gif"},
{faceName:
"I'm about to cry"-
, facePath:"50_I'm about to cry.gif" },
{faceName:
"insidious"-
,facePath:"51_insidious.gif"},
{faceName:
"Kiss"-
, facePath:"52_Kiss.gif"},
{FACENAME: "Scared"
- , Facepath: "53_ <.gif class="string"> },
{faceName:"Poor"
- ,facePath:"54_Poor.gif"},
{faceName:"Chop Knife"
- ,facePath:"55_Chop Knife.gif"},
{faceName:"Watermelon"
- ,facePath:"56_watermelon.gif"},
-
{faceName:"Beer",facePath:"57_beer.gif"},
-
{faceName:"Basketball",facePath:"58_basketball.gif"},
-
{faceName:"pingpong",facePath:"59_pingpong.gif"},
-
{faceName:"Hug",facePath:"78_hug.gif"},
-
{faceName:"Handshake",facePath:"81_Handshake.gif"},
-
{faceName:"smiling smugly", facePath:"smiling smugly.gif"},
-
{faceName:"Listen to music",facePath:"Listen to music.gif"}
- ]
- , ,
-
Init:function(){
-
var isShowImg=false;
-
$(".Input_text").focusout(function(){
-
$(this).parent().css("border-color", "#cccccc");
$(-
this).parent().css("box-shadow", "none");
$(-
this).parent().css("-moz-box-shadow", "none");
$(
this-
).parent().css("-webkit-box-shadow", "none");
});
-
$(".Input_text").focus(function(){
-
$(this).parent().css("border-color", "rgba(19,105,172,.75)");
-
$(this).parent().css("box-shadow", "0 0 3px rgba(19,105,192,.5)");
-
$(this).parent().css("-moz-box-shadow", "0 0 3px rgba(241,39,232,.5)");
-
$(this).parent().css("-webkit-box-shadow", "0 0 3px rgba(19,105,252,3)");
- });
-
$(".imgBtn").click(function(){
-
if(isShowImg==false){
-
isShowImg=true;
-
$(this).parent().prev().animate({marginTop:"-125px"},300);
-
if($(".faceDiv").children().length==0){
-
for(var i=0;i
- $(".faceDiv").append(" ImgIputHandler.facePath[i].faceName "" src="face/" ImgIputHandler.facePath[i].facePath "" />");
- }
-
$(".faceDiv>img").click(function(){
-
-
isShowImg=false;
-
$(this).parent().animate({marginTop:"0px"},300);
-
ImgIputHandler.insertAtCursor($(".Input_text")[0],"[" $(this).attr("title") "]");
- });
- }
-
}else{
-
isShowImg=false;
-
$(this).parent().prev().animate({marginTop:"0px"},300);
- }
- });
-
$(".postBtn").click(function(){
-
alert($(".Input_text").val());
- });
- },
-
insertAtCursor:function(myField, myValue) {
-
if (document.selection) {
- myField.focus();
- sel = document.selection.createRange();
- sel.text = myValue;
- sel.select();
-
} else if (myField.selectionStart || myField.selectionStart == "0") {
-
var startPos = myField.selectionStart;
-
var endPos = myField.selectionEnd;
-
var restoreTop = myField.scrollTop;
- myField.value = myField.value.substring(0, startPos) myValue myField.value.substring(endPos, myField.value.length);
-
if (restoreTop > 0) {
- myField.scrollTop = restoreTop;
- }
- myField.focus();
- myField.selectionStart = startPos myValue.length;
- myField.selectionEnd = startPos myValue.length;
-
} else {
- myField.value = myValue;
- myField.focus();
- }
- }
- }