<?php
/**
 * 微语
 * @author 即刻学术 www.ijkxs.com
 * @package custom
 */
?>
<!DOCTYPE html>
<html lang="zh-CN">

<head>
  <?php $this->need('public/include.php'); ?>
  <link rel="stylesheet" href="<?php $this->options->themeUrl('assets/css/joe.index.min.css'); ?>">
  <script src="<?php $this->options->themeUrl('assets/js/joe.index.min.js'); ?>"></script>
  <link rel="stylesheet" href="<?php $this->options->themeUrl('times/assets/dycomment.min.css'); ?>" media="all" onload="this.media='all'; this.onload=null;">
</head>

<body>
  <div id="Joe">
    <?php $this->need('public/header.php'); ?>
      <div class="joe_container">
        <div class="joe_main">
          <?php $this->need('times/dycomment.php'); ?>
        </div>
        <?php $this->need('public/aside.php'); ?>
      </div>
    <?php $this->need('public/footer.php'); ?>
  </div>

  <script>
    let DyComment = {
      /* 初始化微语发布 */
      init_dynamic_verify() {
        let _this = this;
        $('#j-dynamic-form').off('submit').on('submit', function (e) {
          let btn = $("#j-dynamic-form .form-foot button")
          if ($('#j-dynamic-form-text').val().trim() === '') {
            return alert('请输入发表内容');
          }
          if ($(this).attr('data-disabled')) return;
          $(this).attr('data-disabled', true);
          btn.text("发表中...")
        });
      },
      /* 初始化图片灯箱 */
      init_img_group() {
         const images = $(".comment-parent .content img");
         images.each(index => {
           const img = $(images[index]);
           const src = img.attr("src");
           img.replaceWith(`<span class="img-group" data-fancybox="Joe" href="${src}"><img src="${src}" alt="图片加载失败" title="点击查看大图"></span>`);
         })
      }
    }
    $(document).ready(function () {
      /* 点击评论按钮显示隐藏评论区域 */
      $('.j-comment-reply').unbind('click').bind('click', function (e) {
        e.stopPropagation();
        $(this).parents('li').find('.j-dynamic-reply').toggle();
      });
      // DyComment初始化代码
      DyComment.init_dynamic_verify()
      // 移除当前页面的目录
      $(".joe_aside__item.catalogue").remove()
      // 初始化图片灯箱
      DyComment.init_img_group();
    })
  </script>

</body>
</html>