diff options
| author | 阔落 <45323514+BigCoke233@users.noreply.github.com> | 2019-03-30 15:30:52 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-03-30 15:30:52 +0800 |
| commit | 9ae13dfa011baab12843b6855c2e9a4d6ca92075 (patch) | |
| tree | 07399ca9dfed868bc74a4ace8bc14e11d31e364d /includes/comments.php | |
| parent | d5ff633699d665803d400551dc66c14ec480bb5f (diff) | |
Add files via upload
Diffstat (limited to 'includes/comments.php')
| -rw-r--r-- | includes/comments.php | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/includes/comments.php b/includes/comments.php index 3facb2a..ee6e771 100644 --- a/includes/comments.php +++ b/includes/comments.php @@ -1,4 +1,67 @@ <br />
+
+<!-- 重新获取respondId -->
+<script>
+(function () {
+ window.TypechoComment = {
+ dom : function (id) {
+ return document.getElementById(id);
+ },
+
+ create : function (tag, attr) {
+ var el = document.createElement(tag);
+
+ for (var key in attr) {
+ el.setAttribute(key, attr[key]);
+ }
+
+ return el;
+ },
+ reply : function (cid, coid) {
+ var comment = this.dom(cid), parent = comment.parentNode,
+ response = this.dom('" . $this->respondId . "'), input = this.dom('comment-parent'),
+ form = 'form' == response.tagName ? response : response.getElementsByTagName('form')[0],
+ textarea = response.getElementsByTagName('textarea')[0];
+ if (null == input) {
+ input = this.create('input', {
+ 'type' : 'hidden',
+ 'name' : 'parent',
+ 'id' : 'comment-parent'
+ });
+ form.appendChild(input);
+ }
+ input.setAttribute('value', coid);
+ if (null == this.dom('comment-form-place-holder')) {
+ var holder = this.create('div', {
+ 'id' : 'comment-form-place-holder'
+ });
+ response.parentNode.insertBefore(holder, response);
+ }
+ comment.appendChild(response);
+ this.dom('cancel-comment-reply-link').style.display = '';
+ if (null != textarea && 'text' == textarea.name) {
+ textarea.focus();
+ }
+ return false;
+ },
+ cancelReply : function () {
+ var response = this.dom('{$this->respondId}'),
+ holder = this.dom('comment-form-place-holder'), input = this.dom('comment-parent');
+ if (null != input) {
+ input.parentNode.removeChild(input);
+ }
+ if (null == holder) {
+ return true;
+ }
+ this.dom('cancel-comment-reply-link').style.display = 'none';
+ holder.parentNode.insertBefore(response, holder);
+ return false;
+ }
+ };
+})();
+</script>
+
+<!-- 评论开始 -->
<?php if (!defined('__TYPECHO_ROOT_DIR__')) exit; ?>
<div id="comments" class="responsesWrapper">
|
