-
-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
35a5154
commit 1718bd7
Showing
12 changed files
with
295 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?php if (!defined('__TYPECHO_ROOT_DIR__')) exit; | ||
/** | ||
* 关于页面 | ||
* | ||
* @package custom | ||
*/ | ||
$this->need('includes/head.php'); | ||
$this->need('includes/header.php'); | ||
?> | ||
<main class="main-container container"> | ||
<div class="post-body"> | ||
<br><br><br> | ||
<div class="about"> | ||
<div class="about-avatar"> | ||
<?php echo $this->author->gravatar(300); ?> | ||
<?php if($this->fields->name==!''): ?> | ||
<h2 class="about-name"><?php echo $this->fields->name(); ?></h2> | ||
<?php endif; ?> | ||
</div> | ||
<div class="about-social"> | ||
<?php if($this->fields->github==!''): ?> | ||
<a href="https://github.com/<?php echo $this->fields->github(); ?>" target="_blank" title="GayHub"><i class="iconfont icon-github"></i></a> | ||
<?php endif; ?> | ||
<?php if($this->fields->qq==!''): ?> | ||
<a href="tencent://Message/?Uin=<?php echo $this->fields->qq(); ?>&websiteName=q-zone.qq.com&Menu=yes" target="_blank" title="QQ"><i class="iconfont icon-qq1"></i></a> | ||
<?php endif; ?> | ||
<?php if($this->fields->bilibili==!''): ?> | ||
<a href="https://space.bilibili.com/<?php echo $this->fields->bilibili(); ?>" target="_blank" title="Bilibili"><i class="iconfont icon-bilibili-"></i></a> | ||
<?php endif; ?> | ||
<?php if($this->fields->email==!''): ?> | ||
<a href="mail:<?php echo $this->fields->email(); ?>"><i class="iconfont icon-mail_fill" target="_blank" title="email"></i></a> | ||
<?php endif; ?> | ||
</div> | ||
</div> | ||
<div class="post-content page-content"> | ||
<?php $this->content(); ?> | ||
</div> | ||
</div> | ||
<?php $this->need('includes/comments.php'); ?> | ||
</main> | ||
<?php $this->need('includes/footer.php'); ?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
/** | ||
* Ajax Comment | ||
* 半成品,还有报错,所以没有引用 | ||
*/ | ||
var replyTo = ''; | ||
var bindButton = function() { | ||
//绑定“评论回复”和“取消回复”的事件 | ||
$(".comment-reply a").click( | ||
function () { | ||
replyTo = $(this).parent().parent().parent().parent().parent().parent().attr("id"); | ||
} | ||
); | ||
$(".cancel-comment-reply a").click(function () { replyTo = ''; }); | ||
} | ||
function commentCounts() { | ||
//显示在评论区的评论数加一 | ||
var counts = parseInt($(".comment-title").text()); | ||
$(".comment-title").html($(".comment-title").html().replace(/\d+/, counts + 1)); | ||
}; | ||
function beforeSendComment() { | ||
//发送前的一些处理 | ||
$(".comment-submit button").text("提交中"); | ||
} | ||
function afterSendComment(ok) { | ||
//发送后的处理 | ||
//清空replyTo变量,以及结束过渡动画、重新绑定回复按钮等等 | ||
//ok作为一个评论或失败的标志 | ||
|
||
if (ok) { | ||
$(".comment-textarea").val(''); | ||
replyTo = ''; | ||
} | ||
bindButton(); | ||
} | ||
//主体部分 | ||
beforeSendComment(); | ||
$("#comment-form").submit(function() { | ||
//监听评论表单submit事件 | ||
var commentData = $(this).serializeArray(); //获取表单POST的数据 | ||
beforeSendComment(); | ||
$.ajax({ | ||
type: $(this).attr('method'), | ||
url: $(this).attr('action'), | ||
data: commentData, | ||
error: function(e) { | ||
//失败的处理 | ||
//这里比较随意,比如可以直接刷新页面 | ||
console.log('Ajax Comment Error'); | ||
window.location.realod(); | ||
}, | ||
success: function(data) { | ||
if (!$('.comments', data).length) { | ||
var msg = $('title').eq(0).text().trim().toLowerCase() === 'error' ? $('.container', data).eq(0).text() : '评论提交失败!'; | ||
alertSend(msg); | ||
afterSendComment(false); | ||
return false; | ||
} | ||
} | ||
}) | ||
return false; | ||
}); | ||
var newComment; | ||
/** 获取新评论的id */ | ||
newCommentId = $(".comment-list", data).html().match(/id=\"?comment-\d+/g).join().match(/\d+/g).sort(function (a, b) { return a - b }).pop(); | ||
if(replyTo === '') { | ||
if(!$('.comment-list').length) { | ||
//检查是否已有评论 | ||
newComment = $("#li-comment-" + newCommentId, data); | ||
//没有的话需要先嵌入评论列表的结构 | ||
//具体结构需要参照评论的模板而定,参照下图 | ||
$('.comment-title').after('<div class="comment-container"><ol class="comment-list"></ol></div>'); | ||
//插入评论 | ||
$('.comment-list').first().prepend((newComment).addClass('animated fadeInUp')); | ||
} | ||
else if($('.prev').length) { | ||
//这里是当前评论不在第一页的情况 | ||
//所以这里可以进行比如跳转到第一页的操作,当然也可以进行别的操作 | ||
$('.comment-pagenav ul li a').eq(1).click(); | ||
} | ||
else { | ||
//当前页面直接在最前面插入评论 | ||
newComment = $("#li-comment-" + newCommentId, data); | ||
$('.comment-list').first().prepend((newComment).addClass('animated fadeInUp')); | ||
} | ||
//页面滑动到评论列表头部 | ||
$('html,body').animate({scrollTop:$('.comment-title').offset().top - 100},1000); | ||
} | ||
else { | ||
//取数据 | ||
newComment = $("#li-comment-" + newCommentId, data); | ||
//处理子级评论 | ||
if ($('#' + replyTo).find('.comment-children').length) { | ||
//当前父评论已经有嵌套的结构 | ||
//直接插入新的评论 | ||
$('#' + replyTo + ' .comment-children .comment-list').first().prepend((newComment).addClass('animated fadeInUp')); | ||
TypechoComment.cancelReply(); | ||
} | ||
else { | ||
//当前父评论没有嵌套的结构 | ||
//先构建嵌套的结构再进插入子评论 | ||
//插入的结构视模板具体情况而定 | ||
$('#' + replyTo).append('<div class="comment-children"><ol class="comment-list"></ol></div>'); | ||
$('#' + replyTo + ' .comment-children .comment-list').first().prepend((newComment).addClass('animated fadeInUp')); | ||
TypechoComment.cancelReply(); | ||
} | ||
} | ||
commentCounts(); | ||
afterSendComment(true); | ||
alertSend("评论提交成功!"); |
Oops, something went wrong.