HTML-Kommentarfeld mit Emoticons. Die Emoticons werden über Json-Daten geladen, und Sie können die Emoticons nach Ihren eigenen Vorlieben ändern. Der Code dieses Kommentarfelds ist HTML-, CSS- und JQ-Code. Abbildung 1 zeigt den Originalzustand und Abbildung 2 zeigt die Liste der Ausdrücke, die angezeigt wird, wenn Sie auf den Ausdruck klicken. Sie können nach Belieben einen oder mehrere auswählen. Werfen wir einen Blick auf den implementierten Code.
Bild 1
Bild 2
Implementierter Code:
HTML-Code:
XML/HTML-CodeInhalt in die Zwischenablage kopieren
- <div class="Main" >
-
<div class="Input_Box" >
-
<textarea class="Input_text" >textarea>
-
<div class="faceDiv" > div>
-
<div class="Input_Foot" > <a Klasse="imgBtn" href="javascript:void(0);"> ;a><a Klasse="postBtn">OKa > div>
- div>
- div>
CSS3-Code:
CSS-Code
Inhalt in die Zwischenablage kopieren
Javascript-Code:
JavaScript-Code
Inhalt in die Zwischenablage kopieren
- 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:-
"cuss",facePath:"31_curse.gif"},
{faceName:-
"question",facePath:"32_question.gif"},
{faceName:-
"Sh",facePath:"33_boo.gif"},
{faceName:-
"halo",facePath:"34_halo.gif"},
{faceName:-
"folter",facePath:"35_torture.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:
- "Es ist mir so peinlich", facePath:"43_Es ist mir peinlich.gif" },
{faceName:
- "bad smile", facePath:"44_bad smile.gif"},
{faceName:
- "Zuo Hengheng", facePath:"45_left Hengheng.gif" },
{faceName:
- "Right Heng Heng", facePath:"46_Right Heng Heng.gif" },
{faceName:
- "Yawn",facePath:"47_yawn.gif"},
{faceName:
- "Contempt",facePath:"48_Contempt.gif"},
{faceName:
- "Grief",facePath:"49_Grief.gif"},
{faceName:
- "Ich werde gleich weinen", facePath:"50_Ich werde gleich weinen.gif" },
{faceName:
- "insidious",facePath:"51_insidious.gif"},
{faceName:
- "Kiss", facePath:"52_Kiss.gif"},
{FACENAME:
„Scared“ - , Facepath: „53_ <.gif> },
{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:"Musik hören",facePath:"Musik hören.gif"}
- ]
- , ,
-
Init:Funktion(){
-
var isShowImg=false;
-
$(".Input_text").focusout(function(){
-
$(this).parent().css("border-color", "#cccccc");
$(-
this).parent().css("box-shadow", "keine");
$(-
this).parent().css("-moz-box-shadow", "keine");
$(
this-
).parent().css("-webkit-box-shadow", "keine");
});
-
$(".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);
-
>
$(".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],"[" $( dieses).attr("title") "]");
- });
- }
-
}sonst{
-
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();
- }
- }
- }