Skip to content

Commit

Permalink
0.999.beta.2
Browse files Browse the repository at this point in the history
  • Loading branch information
solstice23 committed Aug 11, 2020
1 parent eda20ea commit b8f4848
Show file tree
Hide file tree
Showing 42 changed files with 865 additions and 438 deletions.
63 changes: 62 additions & 1 deletion argontheme.js
Original file line number Diff line number Diff line change
Expand Up @@ -828,6 +828,7 @@ if (argonConfig.headroom){
timeout: 5000
});
//插入新评论
result.html = result.html.replace(/<img class='comment-sticker lazyload'(.*?)\/>/g, "").replace(/<(\/).noscript>/g, "");
let parentID = result.parentID;
if (parentID == "" || parentID == null){
parentID = 0;
Expand Down Expand Up @@ -977,6 +978,7 @@ if (argonConfig.headroom){
}

//发送成功,替换原评论
result.new_comment = result.new_comment.replace(/<img class='comment-sticker lazyload'(.*?)\/>/g, "").replace(/<(\/).noscript>/g, "");
$("#comment-" + editID + " .comment-item-text").html(result.new_comment);
$("#comment-" + editID + " .comment-item-source").html(result.new_comment_source);
if ($("#comment-" + editID + " .comment-info .comment-edited").length == 0){
Expand Down Expand Up @@ -1043,6 +1045,62 @@ if (argonConfig.headroom){
}
});
}();
/*评论表情面板*/
function lazyloadStickers(){
$(".emotion-keyboard .emotion-group:not(d-none) .emotion-item > img.lazyload").lazyload({threshold: 500, effect: "fadeIn"}).removeClass("lazyload");
$("html").trigger("scroll");
}
$(document).on("click" , "#comment_emotion_btn" , function(){
$("#comment_emotion_btn").toggleClass("comment-emotion-keyboard-open");
lazyloadStickers();
});
$(document).on("click" , ".emotion-keyboard .emotion-group-name" , function(){
$(".emotion-keyboard .emotion-group-name.active").removeClass("active");
$(this).addClass("active");
$(".emotion-keyboard .emotion-group:not(d-none)").addClass("d-none");
$(".emotion-keyboard .emotion-group[index='" + $(this).attr("index") + "']").removeClass("d-none");
lazyloadStickers();
});
function inputInsertText(text, input){
$(input).focus();
let isSuccess = document.execCommand("insertText", false, text);
if (!isSuccess) { //FF
if (typeof input.setRangeText === "function"){
const start = input.selectionStart;
input.setRangeText(text);
input.selectionStart = input.selectionEnd = start + input.length;
const e = document.createEvent("UIEvent");
e.initEvent("input", true, false);
input.dispatchEvent(e);
}else{
let value = $(input).val();
let startPos = input.selectionStart, endPos = input.selectionEnd;
$(input).val(value.substring(0, startPos) + text + value.substring(endPos));
input.selectionStart = startPos + text.length;
input.selectionEnd = startPos + text.length;
}
}
$(input).focus();
}
$(document).on("click" , ".emotion-keyboard .emotion-item" , function(){
$("#comment_emotion_btn").removeClass("comment-emotion-keyboard-open");
if ($(this).hasClass("emotion-item-sticker")){
inputInsertText(":" + $(this).attr("code") + ":", document.getElementById("post_comment_content"));
}else{
inputInsertText($(this).text(), document.getElementById("post_comment_content"));
}
});
$(document).on("dragstart" , ".emotion-keyboard .emotion-item > img, .comment-sticker" , function(e){
e.preventDefault();
});
document.addEventListener('click', (e) => {
if (document.getElementById("comment_emotion_btn") == null){
return;
}
  if(e.target.id != "comment_emotion_btn" && e.target.id != "emotion_keyboard" && !document.getElementById("comment_emotion_btn").contains(e.target) && !document.getElementById("emotion_keyboard").contains(e.target)){
$("#comment_emotion_btn").removeClass("comment-emotion-keyboard-open");
  }
})
/*查看评论编辑记录*/
function showCommentEditHistory(id){
let requestID = parseInt(new Date().getTime());
Expand Down Expand Up @@ -1129,6 +1187,7 @@ $(document).on("submit" , ".post-password-form" , function(){
foldLongComments();
calcHumanTimesOnPage();
panguInit();
$(".comment-item-text .comment-sticker.lazyload").lazyload(argonConfig.lazyload).removeClass("lazyload");
},
error : function(){
window.location.href = url;
Expand Down Expand Up @@ -1160,6 +1219,7 @@ $(document).on("submit" , ".post-password-form" , function(){
foldLongComments();
calcHumanTimesOnPage();
panguInit();
$(".comment-item-text .comment-sticker.lazyload").lazyload(argonConfig.lazyload).removeClass("lazyload");
},
error : function(){
window.location.href = url;
Expand Down Expand Up @@ -1233,7 +1293,8 @@ function lazyloadInit(){
if (argonConfig.lazyload.effect == "none"){
delete argonConfig.lazyload.effect;
}
$("article img.lazyload").lazyload(argonConfig.lazyload);
$("article img.lazyload:not(.lazyload-loaded) , .post-thumbnail.lazyload:not(.lazyload-loaded)").lazyload(argonConfig.lazyload).addClass("lazyload-loaded");
$(".comment-item-text .comment-sticker.lazyload").lazyload(argonConfig.lazyload).removeClass("lazyload");
}
lazyloadInit();

Expand Down
10 changes: 8 additions & 2 deletions comments.php
Original file line number Diff line number Diff line change
Expand Up @@ -184,16 +184,22 @@
<label class="custom-control-label" for="comment_post_mailnotice"><?php _e('邮件提醒', 'argon');?></label>
</div>
<?php } ?>
<button id="post_comment_send" class="btn btn-icon btn-primary pull-right" type="button">
<button id="post_comment_send" class="btn btn-icon btn-primary comment-btn pull-right mr-0" type="button">
<span class="btn-inner--icon hide-on-comment-editing"><i class="fa fa-send"></i></span>
<span class="btn-inner--icon hide-on-comment-not-editing"><i class="fa fa-pencil"></i></span>
<span class="btn-inner--text hide-on-comment-editing" style="margin-right: 0;"><?php _e('发送', 'argon');?></span>
<span class="btn-inner--text hide-on-comment-not-editing" style="margin-right: 0;"><?php _e('编辑', 'argon');?></span>
</button>
<button id="post_comment_edit_cancel" class="btn btn-icon btn-danger pull-right hide-on-comment-not-editing" type="button" style="margin-right: 8px;">
<button id="post_comment_edit_cancel" class="btn btn-icon btn-danger comment-btn pull-right hide-on-comment-not-editing" type="button" style="margin-right: 8px;">
<span class="btn-inner--icon"><i class="fa fa-close"></i></span>
<span class="btn-inner--text"><?php _e('取消', 'argon');?></span>
</button>
<?php if (get_option("argon_comment_emotion_keyboard", "true") != "false"){ ?>
<button id="comment_emotion_btn" class="btn btn-icon btn-primary pull-right" type="button" title="<?php _e('表情', 'argon');?>">
<i class="fa fa-smile-o" aria-hidden="true"></i>
</button>
<?php get_template_part( 'template-parts/emotion-keyboard' ); ?>
<?php } ?>
</div>
</div>
<input id="post_comment_captcha_seed" value="<?php echo $commentCaptchaSeed;?>" style="display: none;"></input>
Expand Down
118 changes: 118 additions & 0 deletions emotions.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
<?php
$emotionListDefault = array(
array(
'groupname' => __('颜文字', 'argon'),
'list' => array(
array('type' => 'text', 'text' => "|´・ω・)ノ"),
array('type' => 'text', 'text' => "ヾ(≧∇≦*)ゝ"),
array('type' => 'text', 'text' => "(☆ω☆)"),
array('type' => 'text', 'text' => "(╯‵□′)╯︵┴─┴"),
array('type' => 'text', 'text' => " ̄﹃ ̄"),
array('type' => 'text', 'text' => "(/ω\)"),
array('type' => 'text', 'text' => "∠( ᐛ 」∠)_"),
array('type' => 'text', 'text' => "(๑•̀ㅁ•́ฅ)"),
array('type' => 'text', 'text' => "→_→"),
array('type' => 'text', 'text' => "୧(๑•̀⌄•́๑)૭"),
array('type' => 'text', 'text' => "٩(ˊᗜˋ*)و"),
array('type' => 'text', 'text' => "(ノ°ο°)ノ"),
array('type' => 'text', 'text' => "(´இ皿இ`)"),
array('type' => 'text', 'text' => "⌇●﹏●⌇"),
array('type' => 'text', 'text' => "(ฅ´ω`ฅ)"),
array('type' => 'text', 'text' => "(╯°A°)╯︵○○○"),
array('type' => 'text', 'text' => "φ( ̄∇ ̄o)"),
array('type' => 'text', 'text' => "ヾ(´・ ・`。)ノ\""),
array('type' => 'text', 'text' => "( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃"),
array('type' => 'text', 'text' => "(ó﹏ò。)"),
array('type' => 'text', 'text' => "Σ(っ °Д °;)っ"),
array('type' => 'text', 'text' => "( ,,´・ω・)ノ\"(´っω・`。)"),
array('type' => 'text', 'text' => "╮(╯▽╰)╭"),
array('type' => 'text', 'text' => "o(*////▽////*)q"),
array('type' => 'text', 'text' => ">﹏<"),
array('type' => 'text', 'text' => "( ๑´•ω•) \"(ㆆᴗㆆ)")
)
),
array(
'groupname' => 'Emoji',
'list' => array(
array('type' => 'text', 'text' => "😂"),
array('type' => 'text', 'text' => "😀"),
array('type' => 'text', 'text' => "😅"),
array('type' => 'text', 'text' => "😊"),
array('type' => 'text', 'text' => "🙂"),
array('type' => 'text', 'text' => "🙃"),
array('type' => 'text', 'text' => "😌"),
array('type' => 'text', 'text' => "😍"),
array('type' => 'text', 'text' => "😘"),
array('type' => 'text', 'text' => "😜"),
array('type' => 'text', 'text' => "😝"),
array('type' => 'text', 'text' => "😏"),
array('type' => 'text', 'text' => "😒"),
array('type' => 'text', 'text' => "🙄"),
array('type' => 'text', 'text' => "😳"),
array('type' => 'text', 'text' => "😡"),
array('type' => 'text', 'text' => "😔"),
array('type' => 'text', 'text' => "😫"),
array('type' => 'text', 'text' => "😱"),
array('type' => 'text', 'text' => "😭"),
array('type' => 'text', 'text' => "💩"),
array('type' => 'text', 'text' => "👻"),
array('type' => 'text', 'text' => "🙌"),
array('type' => 'text', 'text' => "🖕"),
array('type' => 'text', 'text' => "👍"),
array('type' => 'text', 'text' => "👫"),
array('type' => 'text', 'text' => "👬"),
array('type' => 'text', 'text' => "👭"),
array('type' => 'text', 'text' => "🌚"),
array('type' => 'text', 'text' => "🌝"),
array('type' => 'text', 'text' => "🙈"),
array('type' => 'text', 'text' => "💊"),
array('type' => 'text', 'text' => "😶"),
array('type' => 'text', 'text' => "🙏"),
array('type' => 'text', 'text' => "🍦"),
array('type' => 'text', 'text' => "🍉"),
array('type' => 'text', 'text' => "😣")
)
),
array(
'groupname' => '小恐龙',
'list' => array(
array('type' => 'sticker', 'code' => 'dinosaur-shy', 'src' => $GLOBALS['assets_path'] . '/stickers/dinosaur/1.jpg'),
array('type' => 'sticker', 'code' => 'dinosaur-daze', 'src' => $GLOBALS['assets_path'] . '/stickers/dinosaur/2.jpg'),
array('type' => 'sticker', 'code' => 'dinosaur-sweat', 'src' => $GLOBALS['assets_path'] . '/stickers/dinosaur/3.jpg'),
array('type' => 'sticker', 'code' => 'dinosaur-proud', 'src' => $GLOBALS['assets_path'] . '/stickers/dinosaur/4.jpg'),
array('type' => 'sticker', 'code' => 'dinosaur-powerless', 'src' => $GLOBALS['assets_path'] . '/stickers/dinosaur/5.jpg'),
array('type' => 'sticker', 'code' => 'dinosaur-pouting', 'src' => $GLOBALS['assets_path'] . '/stickers/dinosaur/6.jpg'),
array('type' => 'sticker', 'code' => 'dinosaur-eating', 'src' => $GLOBALS['assets_path'] . '/stickers/dinosaur/7.jpg'),
array('type' => 'sticker', 'code' => 'dinosaur-ok', 'src' => $GLOBALS['assets_path'] . '/stickers/dinosaur/8.jpg'),
array('type' => 'sticker', 'code' => 'dinosaur-doubt', 'src' => $GLOBALS['assets_path'] . '/stickers/dinosaur/9.jpg'),
array('type' => 'sticker', 'code' => 'dinosaur-depressed', 'src' => $GLOBALS['assets_path'] . '/stickers/dinosaur/10.jpg'),
array('type' => 'sticker', 'code' => 'dinosaur-close-eyes', 'src' => $GLOBALS['assets_path'] . '/stickers/dinosaur/11.jpg'),
array('type' => 'sticker', 'code' => 'dinosaur-sleeping', 'src' => $GLOBALS['assets_path'] . '/stickers/dinosaur/12.jpg'),
array('type' => 'sticker', 'code' => 'dinosaur-puzzled', 'src' => $GLOBALS['assets_path'] . '/stickers/dinosaur/13.jpg'),
array('type' => 'sticker', 'code' => 'dinosaur-agree', 'src' => $GLOBALS['assets_path'] . '/stickers/dinosaur/14.jpg'),
array('type' => 'sticker', 'code' => 'dinosaur-crazy', 'src' => $GLOBALS['assets_path'] . '/stickers/dinosaur/15.jpg'),
array('type' => 'sticker', 'code' => 'dinosaur-angry', 'src' => $GLOBALS['assets_path'] . '/stickers/dinosaur/16.jpg')
)
),
array(
'groupname' => '花!',
'list' => array(
array('type' => 'sticker', 'code' => 'flower-flower', 'src' => $GLOBALS['assets_path'] . '/stickers/flower/1.jpg'),
array('type' => 'sticker', 'code' => 'flower-grass', 'src' => $GLOBALS['assets_path'] . '/stickers/flower/2.jpg'),
array('type' => 'sticker', 'code' => 'flower-leaf', 'src' => $GLOBALS['assets_path'] . '/stickers/flower/3.jpg'),
array('type' => 'sticker', 'code' => 'flower-star', 'src' => $GLOBALS['assets_path'] . '/stickers/flower/4.jpg'),
array('type' => 'sticker', 'code' => 'flower-sun', 'src' => $GLOBALS['assets_path'] . '/stickers/flower/5.jpg'),
array('type' => 'sticker', 'code' => 'flower-moon', 'src' => $GLOBALS['assets_path'] . '/stickers/flower/6.jpg'),
array('type' => 'sticker', 'code' => 'flower-water', 'src' => $GLOBALS['assets_path'] . '/stickers/flower/7.jpg'),
array('type' => 'sticker', 'code' => 'flower-heihei', 'src' => $GLOBALS['assets_path'] . '/stickers/flower/8.jpg'),
array('type' => 'sticker', 'code' => 'flower-lemon', 'src' => $GLOBALS['assets_path'] . '/stickers/flower/9.jpg'),
array('type' => 'sticker', 'code' => 'flower-birthday', 'src' => $GLOBALS['assets_path'] . '/stickers/flower/10.jpg'),
array('type' => 'sticker', 'code' => 'flower-sea', 'src' => $GLOBALS['assets_path'] . '/stickers/flower/11.jpg'),
array('type' => 'sticker', 'code' => 'flower-vegetable', 'src' => $GLOBALS['assets_path'] . '/stickers/flower/12.jpg'),
array('type' => 'sticker', 'code' => 'flower-tile', 'src' => $GLOBALS['assets_path'] . '/stickers/flower/13.jpg'),
array('type' => 'sticker', 'code' => 'flower-utf', 'src' => $GLOBALS['assets_path'] . '/stickers/flower/14.jpg'),
),
'description' => 'Source: github.com/k4yt3x/flowerhd'
)
);
?>
6 changes: 6 additions & 0 deletions footer.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,12 @@
wp_enqueue_script("argonjs", $GLOBALS['assets_path'] . "/assets/js/argon.min.js", null, $GLOBALS['theme_version'], true);
?>
<?php wp_footer(); ?>
<noscript>
<style>
article img.lazyload[src^="data:image/svg+xml;base64,PCEtLUFyZ29uTG9hZGluZy0tPg"]{display: none;}
.comment-item-text .comment-sticker.lazyload{display: none;}
</style>
</noscript>
</body>

<?php echo get_option('argon_custom_html_foot'); ?>
Expand Down
Loading

0 comments on commit b8f4848

Please sign in to comment.