Skip to content

Commit

Permalink
add emotionsplus
Browse files Browse the repository at this point in the history
  • Loading branch information
skywalker512 committed Jul 6, 2018
1 parent 775b521 commit a71fa46
Show file tree
Hide file tree
Showing 6 changed files with 195 additions and 0 deletions.
Binary file added addons/plugins/EmoticonsPlus/icon.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file.
154 changes: 154 additions & 0 deletions addons/plugins/EmoticonsPlus/plugin.php
@@ -0,0 +1,154 @@
<?php

if (!defined("IN_ESOTALK")) exit;

ET::$pluginInfo["EmoticonsPlus"] = array(
"name" => "表情-增强版",
"description" => "添加表情图片到帖子中,并添加表情选择器到编辑器中",
"version" => "1.0",
"author" => "Ramouch0 (based on esotalk's version)",
"authorEmail" => "support@esotalk.org",
"authorURL" => "http://esotalk.org",
"license" => "GPLv2"
);

class ETPlugin_EmoticonsPlus extends ETPlugin {

private $icons;
private $iscon;

/**
* Class constructor.
*
* @return void
*/
public function __construct($rootDirectory)
{
parent::__construct($rootDirectory);
$this->icons = array();
$this->icons[":)"] = "background-position:0 0";
$this->icons[":-)"] = "background-position:0 0";
$this->icons["=)"] = "background-position:0 0";
$this->icons[":-D"] = "background-position:0 -20px";
$this->icons[":D"] = "background-position:0 -20px";
$this->icons["=D"] = "background-position:0 -20px";
$this->icons["^_^"] = "background-position:0 -40px";
$this->icons["^^"] = "background-position:0 -40px";
$this->icons[":("] = "background-position:0 -60px";
$this->icons[":-("] = "background-position:0 -60px";
$this->icons["=("] = "background-position:0 -60px";
$this->icons["-_-"] = "background-position:0 -80px";
$this->icons[";-)"] = "background-position:0 -100px";
$this->icons[";)"] = "background-position:0 -100px";
$this->icons["^_-"] = "background-position:0 -100px";
$this->icons["~_-"] = "background-position:0 -100px";
$this->icons["-_^"] = "background-position:0 -100px";
$this->icons["-_~"] = "background-position:0 -100px";
$this->icons["^_^;"] = "background-position:0 -120px; width:18px";
$this->icons["^^;"] = "background-position:0 -120px; width:18px";
$this->icons[">_<"] = "background-position:0 -140px";
$this->icons[":/"] = "background-position:0 -160px";
$this->icons[":-/"] = "background-position:0 -160px";
$this->icons["=/"] = "background-position:0 -160px";
$this->icons[":\\"] = "background-position:0 -160px";
$this->icons["=\\"] = "background-position:0 -160px";
$this->icons[":x"] = "background-position:0 -180px";
$this->icons["=x"] = "background-position:0 -180px";
$this->icons[":|"] = "background-position:0 -180px";
$this->icons["=|"] = "background-position:0 -180px";
$this->icons["'_'"] = "background-position:0 -180px";
$this->icons["<_<"] = "background-position:0 -200px";
$this->icons[">_>"] = "background-position:0 -220px";
$this->icons["x_x"] = "background-position:0 -240px";
$this->icons["o_O"] = "background-position:0 -260px";
$this->icons["O_o"] = "background-position:0 -260px";
$this->icons["o_0"] = "background-position:0 -260px";
$this->icons["0_o"] = "background-position:0 -260px";
$this->icons[";_;"] = "background-position:0 -280px";
$this->icons[":'("] = "background-position:0 -280px";
$this->icons[":O"] = "background-position:0 -300px";
$this->icons["=O"] = "background-position:0 -300px";
$this->icons[":o"] = "background-position:0 -300px";
$this->icons["=o"] = "background-position:0 -300px";
$this->icons[":-P"] = "background-position:0 -320px";
$this->icons[":P"] = "background-position:0 -320px";
$this->icons[":p"] = "background-position:0 -320px";
$this->icons[":-p"] = "background-position:0 -320px";
$this->icons["=P"] = "background-position:0 -320px";
$this->icons[";P"] = "background-position:0 -320px";
$this->icons[";-P"] = "background-position:0 -320px";
$this->icons[":["] = "background-position:0 -340px";
$this->icons["=["] = "background-position:0 -340px";
$this->icons[":3"] = "background-position:0 -360px";
$this->icons["=3"] = "background-position:0 -360px";
$this->icons["._.;"] = "background-position:0 -380px; width:18px";
$this->icons["<(^.^)>"] = "background-position:0 -400px; width:19px";
$this->icons["(>'.')>"] = "background-position:0 -400px; width:19px";
$this->icons["(>^.^)>"] = "background-position:0 -400px; width:19px";
$this->icons["-_-;"] = "background-position:0 -420px; width:18px";
$this->icons["(o^_^o)"] = "background-position:0 -440px";
$this->icons["(^_^)/"] = "background-position:0 -460px; width:19px";
$this->icons[">:("] = "background-position:0 -480px";
$this->icons[">:["] = "background-position:0 -480px";
$this->icons["._."] = "background-position:0 -500px";
$this->icons["T_T"] = "background-position:0 -520px";
$this->icons["XD"] = "background-position:0 -540px";
$this->icons["('<"] = "background-position:0 -560px";
$this->icons["B)"] = "background-position:0 -580px";
$this->icons["XP"] = "background-position:0 -600px";
$this->icons[":S"] = "background-position:0 -620px";
$this->icons["=S"] = "background-position:0 -620px";
$this->icons[">:)"] = "background-position:0 -640px";
$this->icons[">:D"] = "background-position:0 -640px";
}

/**
* Add an event handler to the "getEditControls" method of the conversation controller to add BBCode
* formatting buttons to the edit controls.
*
* @return void
*/
public function handler_conversationController_getEditControls($sender, &$controls, $id)
{

addToArrayString($controls, "smileys", "<a href='javascript:EmoticonAdv.showDropDown(\"$id\");void(0)' title='".T("Smileys")."' class='control-smile'><i class='icon-smile'></i></a>", 0);
}

public function handler_conversationController_renderBefore($sender)
{
$sender->addJSFile($this->Resource("emoticon.js"));
$sender->addCSSFile($this->Resource("emoticon.css"));
$this->iscon = true;

}

public function handler_memberController_renderBefore($sender)
{
$this->handler_conversationController_renderBefore($sender);
}

public function handler_pageEnd(){

if($this->iscon){
$div ="<div id='emoticonDropDown' style='display: none;'><div><ul>";
foreach(array_unique($this->icons) as $k => $v){
$alt = htmlentities($k, ENT_QUOTES);
$div.="<li><a href=\"javascript:EmoticonAdv.insertSmiley('".str_replace("'","\'",$k)."');void(0)\" title=\"$alt\" style=\"$v\" class=\"emoticon\" alt=\"$alt\">\"$alt\"</a></li>";
}
$div .="</ul></div></div>";
echo $div;
}
}

public function handler_format_format($sender)
{
$from = $to = array();
foreach ($this->icons as $k => $v) {
$quoted = preg_quote(sanitizeHTML($k), "/");
$from[] = "/(?<=^|[\s.,!<>]){$quoted}(?=[\s.,!<>)]|$)/i";
$to[] = "<span class='emoticon' style='$v'>$k</span>";
}
$sender->content = preg_replace($from, $to, $sender->content);
}

}
9 changes: 9 additions & 0 deletions addons/plugins/EmoticonsPlus/resources/emoticon.css
@@ -0,0 +1,9 @@
.emoticon {display:inline-block; text-indent:-9999px; width:16px; height:16px; background:url(emoticons.png); background-repeat:no-repeat;}
.formattingButtons .emoticon{background-position:0 0; margin-top:-2px;}
#emoticonDropDown {position:absolute; padding: 12px 2px 2px 2px; z-index:100;}
#emoticonDropDown div{border:1px solid #eee;background-color: #fff; padding:2px}
#emoticonDropDown li{display: inline;float:left;list-style-type: none;padding: 0;margin:0;height:20px;width:20px;}
#emoticonDropDown ul{line-height:16px;width: 120px;margin: 0;padding: 0;}
#emoticonDropDown a{display: block;text-align: center;text-decoration: none;color: #000;height:16px;width:16px;padding-top:2px}
#emoticonDropDown a:hover{ background-color: #888;}
#emoticonDropDown a.closeLink{color:#aaa;clear: both;width:100%;height:10px;font-size:0.6em;padding:0;margin:0}
32 changes: 32 additions & 0 deletions addons/plugins/EmoticonsPlus/resources/emoticon.js
@@ -0,0 +1,32 @@
var EmoticonAdv = {
activeTextAreaId:"",
showDropDown: function(id){
this.activeTextAreaId = id;
buttonPosition = $("#"+id+" .formattingButtons .control-smile").offset();
$("#emoticonDropDown").css( {
left: buttonPosition.left,
top: buttonPosition.top+6
} );

$("#emoticonDropDown").fadeIn();
},
hideDropDown: function(){
$("#emoticonDropDown").fadeOut();

},
insertSmiley : function(smiley){
ETConversation.wrapText($("#"+this.activeTextAreaId+" textarea"), " "+smiley+" ", "");
//ETConversation.insertText($("#"+this.activeTextAreaId+" textarea"), " "+smiley+" ");

}
};

//bind mouse out event to automatically close the menu
$(function(){
$("#emoticonDropDown").bind("mouseleave",function(){
EmoticonAdv.hideDropDown();
});
$("#emoticonDropDown *").click(function(event){
event.stopPropagation(); //this is needed to prevent the reply area to collapse on click outside it
});
});
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit a71fa46

Please sign in to comment.