artalk 2.1.3 → 2.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/Artalk.es.js CHANGED
@@ -109,7 +109,7 @@ const defaults$3 = {
109
109
  mirror: "https://sdn.geekzu.org/avatar/"
110
110
  },
111
111
  pagination: {
112
- pageSize: 15,
112
+ pageSize: 20,
113
113
  readMore: true,
114
114
  autoLoad: true
115
115
  },
@@ -2584,6 +2584,8 @@ function timeAgo(date) {
2584
2584
  }
2585
2585
  }
2586
2586
  function onImagesLoaded($container, event) {
2587
+ if (!$container)
2588
+ return;
2587
2589
  const images = $container.getElementsByTagName("img");
2588
2590
  if (!images.length)
2589
2591
  return;
@@ -3038,16 +3040,13 @@ class Api {
3038
3040
  this.ctx = ctx;
3039
3041
  this.baseURL = ctx.conf.server;
3040
3042
  }
3041
- get(offset, type, flatMode, paramsEditor) {
3042
- var _a;
3043
+ get(offset, pageSize, flatMode, paramsEditor) {
3043
3044
  const params = {
3044
3045
  page_key: this.ctx.conf.pageKey,
3045
3046
  site_name: this.ctx.conf.site || "",
3046
- limit: ((_a = this.ctx.conf.pagination) == null ? void 0 : _a.pageSize) || 15,
3047
+ limit: pageSize,
3047
3048
  offset
3048
3049
  };
3049
- if (type)
3050
- params.type = type;
3051
3050
  if (flatMode)
3052
3051
  params.flat_mode = flatMode;
3053
3052
  if (this.ctx.user.checkHasBasicUserInfo()) {
@@ -3381,7 +3380,7 @@ class CheckerLauncher {
3381
3380
  }
3382
3381
  }
3383
3382
  var editor = "";
3384
- var EditorHTML = '<div class="atk-main-editor">\n <div class="atk-editor-header">\n <input name="nick" placeholder="\u6635\u79F0" class="atk-nick" type="text" required="required">\n <input name="email" placeholder="\u90AE\u7BB1" class="atk-email" type="email" required="required">\n <input name="link" placeholder="\u7F51\u5740 (https://)" class="atk-link" type="url">\n </div>\n <div class="atk-editor-textarea-wrap">\n <div class="atk-close-comment" style="display: none;"><span>\u4EC5\u7BA1\u7406\u5458\u53EF\u8BC4\u8BBA</span></div>\n <textarea id="atk-editor-textarea" class="atk-editor-textarea" placeholder=""></textarea>\n </div>\n <div class="atk-editor-plug-wrap" style="display: none;"></div>\n <div class="atk-editor-bottom">\n <div class="atk-editor-bottom-part atk-left atk-editor-plug-switcher-wrap"></div>\n <div class="atk-editor-bottom-part atk-right">\n <button type="button" class="atk-send-btn"></button>\n </div>\n </div>\n <div class="atk-editor-notify-wrap"></div>\n</div>\n';
3383
+ var EditorHTML = '<div class="atk-main-editor">\n <div class="atk-header">\n <input name="nick" placeholder="\u6635\u79F0" class="atk-nick" type="text" required="required">\n <input name="email" placeholder="\u90AE\u7BB1" class="atk-email" type="email" required="required">\n <input name="link" placeholder="\u7F51\u5740 (https://)" class="atk-link" type="url">\n </div>\n <div class="atk-textarea-wrap">\n <textarea class="atk-textarea" placeholder=""></textarea>\n </div>\n <div class="atk-plug-wrap" style="display: none;"></div>\n <div class="atk-bottom">\n <div class="atk-item atk-plug-btn-wrap"></div>\n <div class="atk-item">\n <button type="button" class="atk-send-btn"></button>\n </div>\n </div>\n <div class="atk-notify-wrap"></div>\n</div>\n';
3385
3384
  var emoticonsPlug = "";
3386
3385
  class EditorPlug {
3387
3386
  constructor(editor2) {
@@ -3398,8 +3397,8 @@ class EmoticonsPlug extends EditorPlug {
3398
3397
  super(editor2);
3399
3398
  __publicField(this, "$el");
3400
3399
  __publicField(this, "emoticons", []);
3401
- __publicField(this, "$listWrap");
3402
- __publicField(this, "$types");
3400
+ __publicField(this, "$grpWrap");
3401
+ __publicField(this, "$grpSwitcher");
3403
3402
  this.editor = editor2;
3404
3403
  this.$el = createElement(`<div class="atk-editor-plug-emoticons"></div>`);
3405
3404
  this.init();
@@ -3527,17 +3526,17 @@ class EmoticonsPlug extends EditorPlug {
3527
3526
  return dest;
3528
3527
  }
3529
3528
  initEmoticonsList() {
3530
- this.$listWrap = createElement(`<div class="atk-emoticons-list-wrap"></div>`);
3531
- this.$el.append(this.$listWrap);
3529
+ this.$grpWrap = createElement(`<div class="atk-grp-wrap"></div>`);
3530
+ this.$el.append(this.$grpWrap);
3532
3531
  this.emoticons.forEach((grp, index) => {
3533
- const emoticonsEl = createElement(`<div class="atk-emoticons-list" style="display: none;"></div>`);
3534
- this.$listWrap.append(emoticonsEl);
3535
- emoticonsEl.setAttribute("data-index", String(index));
3536
- emoticonsEl.setAttribute("data-grp-name", grp.name);
3537
- emoticonsEl.setAttribute("data-type", grp.type);
3532
+ const $grp = createElement(`<div class="atk-grp" style="display: none;"></div>`);
3533
+ this.$grpWrap.append($grp);
3534
+ $grp.setAttribute("data-index", String(index));
3535
+ $grp.setAttribute("data-grp-name", grp.name);
3536
+ $grp.setAttribute("data-type", grp.type);
3538
3537
  grp.items.forEach((item) => {
3539
- const $item = createElement(`<span class="atk-emoticons-item"></span>`);
3540
- emoticonsEl.append($item);
3538
+ const $item = createElement(`<span class="atk-item"></span>`);
3539
+ $grp.append($item);
3541
3540
  if (!!item.key && !new RegExp(`^(${grp.name})?\\s?[0-9]+$`).test(item.key))
3542
3541
  $item.setAttribute("title", item.key);
3543
3542
  if (grp.type === "image") {
@@ -3557,21 +3556,21 @@ class EmoticonsPlug extends EditorPlug {
3557
3556
  };
3558
3557
  });
3559
3558
  });
3560
- this.$types = createElement(`<div class="atk-emoticons-types"></div>`);
3561
- this.$el.append(this.$types);
3559
+ this.$grpSwitcher = createElement(`<div class="atk-grp-switcher"></div>`);
3560
+ this.$el.append(this.$grpSwitcher);
3562
3561
  this.emoticons.forEach((grp, index) => {
3563
3562
  const $item = createElement("<span />");
3564
3563
  $item.innerText = grp.name;
3565
3564
  $item.setAttribute("data-index", String(index));
3566
3565
  $item.onclick = () => this.openGrp(index);
3567
- this.$types.append($item);
3566
+ this.$grpSwitcher.append($item);
3568
3567
  });
3569
3568
  if (this.emoticons.length > 0)
3570
3569
  this.openGrp(0);
3571
3570
  }
3572
3571
  openGrp(index) {
3573
3572
  var _a;
3574
- Array.from(this.$listWrap.children).forEach((item) => {
3573
+ Array.from(this.$grpWrap.children).forEach((item) => {
3575
3574
  const el = item;
3576
3575
  if (el.getAttribute("data-index") !== String(index)) {
3577
3576
  el.style.display = "none";
@@ -3579,8 +3578,8 @@ class EmoticonsPlug extends EditorPlug {
3579
3578
  el.style.display = "";
3580
3579
  }
3581
3580
  });
3582
- this.$types.querySelectorAll("span.active").forEach((item) => item.classList.remove("active"));
3583
- (_a = this.$types.querySelector(`span[data-index="${index}"]`)) == null ? void 0 : _a.classList.add("active");
3581
+ this.$grpSwitcher.querySelectorAll("span.active").forEach((item) => item.classList.remove("active"));
3582
+ (_a = this.$grpSwitcher.querySelector(`span[data-index="${index}"]`)) == null ? void 0 : _a.classList.add("active");
3584
3583
  this.changeListHeight();
3585
3584
  }
3586
3585
  getEl() {
@@ -3655,12 +3654,9 @@ class Editor extends Component {
3655
3654
  __publicField(this, "$header");
3656
3655
  __publicField(this, "$textareaWrap");
3657
3656
  __publicField(this, "$textarea");
3658
- __publicField(this, "$closeComment");
3659
3657
  __publicField(this, "$plugWrap");
3660
3658
  __publicField(this, "$bottom");
3661
- __publicField(this, "$bottomPartLeft");
3662
- __publicField(this, "$plugSwitcherWrap");
3663
- __publicField(this, "$bottomPartRight");
3659
+ __publicField(this, "$plugBtnWrap");
3664
3660
  __publicField(this, "$submitBtn");
3665
3661
  __publicField(this, "$notifyWrap");
3666
3662
  __publicField(this, "replyComment", null);
@@ -3672,17 +3668,14 @@ class Editor extends Component {
3672
3668
  });
3673
3669
  __publicField(this, "openedPlugName", null);
3674
3670
  this.$el = createElement(EditorHTML);
3675
- this.$header = this.$el.querySelector(".atk-editor-header");
3676
- this.$textareaWrap = this.$el.querySelector(".atk-editor-textarea-wrap");
3677
- this.$textarea = this.$el.querySelector(".atk-editor-textarea");
3678
- this.$closeComment = this.$el.querySelector(".atk-close-comment");
3679
- this.$plugWrap = this.$el.querySelector(".atk-editor-plug-wrap");
3680
- this.$bottom = this.$el.querySelector(".atk-editor-bottom");
3681
- this.$bottomPartLeft = this.$el.querySelector(".atk-editor-bottom-part.atk-left");
3682
- this.$plugSwitcherWrap = this.$el.querySelector(".atk-editor-plug-switcher-wrap");
3683
- this.$bottomPartRight = this.$el.querySelector(".atk-editor-bottom-part.atk-right");
3671
+ this.$header = this.$el.querySelector(".atk-header");
3672
+ this.$textareaWrap = this.$el.querySelector(".atk-textarea-wrap");
3673
+ this.$textarea = this.$el.querySelector(".atk-textarea");
3674
+ this.$plugWrap = this.$el.querySelector(".atk-plug-wrap");
3675
+ this.$bottom = this.$el.querySelector(".atk-bottom");
3676
+ this.$plugBtnWrap = this.$el.querySelector(".atk-plug-btn-wrap");
3684
3677
  this.$submitBtn = this.$el.querySelector(".atk-send-btn");
3685
- this.$notifyWrap = this.$el.querySelector(".atk-editor-notify-wrap");
3678
+ this.$notifyWrap = this.$el.querySelector(".atk-notify-wrap");
3686
3679
  this.initLocalStorage();
3687
3680
  this.initHeader();
3688
3681
  this.initTextarea();
@@ -3793,17 +3786,17 @@ class Editor extends Component {
3793
3786
  this.$plugWrap.innerHTML = "";
3794
3787
  this.$plugWrap.style.display = "none";
3795
3788
  this.openedPlugName = null;
3796
- this.$plugSwitcherWrap.innerHTML = "";
3789
+ this.$plugBtnWrap.innerHTML = "";
3797
3790
  this.LOADABLE_PLUG_LIST.forEach((PlugObj) => {
3798
- const btnElem = createElement(`<span class="atk-editor-action atk-editor-plug-switcher">${PlugObj.BtnHTML}</span>`);
3799
- this.$plugSwitcherWrap.appendChild(btnElem);
3791
+ const btnElem = createElement(`<span class="atk-plug-btn">${PlugObj.BtnHTML}</span>`);
3792
+ this.$plugBtnWrap.appendChild(btnElem);
3800
3793
  btnElem.addEventListener("click", () => {
3801
3794
  let plug = this.plugList[PlugObj.Name];
3802
3795
  if (!plug) {
3803
3796
  plug = new PlugObj(this);
3804
3797
  this.plugList[PlugObj.Name] = plug;
3805
3798
  }
3806
- this.$plugSwitcherWrap.querySelectorAll(".active").forEach((item) => item.classList.remove("active"));
3799
+ this.$plugBtnWrap.querySelectorAll(".active").forEach((item) => item.classList.remove("active"));
3807
3800
  if (PlugObj.Name === this.openedPlugName) {
3808
3801
  plug.onHide();
3809
3802
  this.$plugWrap.style.display = "none";
@@ -3965,7 +3958,8 @@ class Editor extends Component {
3965
3958
  showNotify(this.$notifyWrap, msg, type);
3966
3959
  }
3967
3960
  close() {
3968
- this.$closeComment.style.display = "";
3961
+ if (!this.$textareaWrap.querySelector(".atk-comment-closed"))
3962
+ this.$textareaWrap.prepend(createElement('<div class="atk-comment-closed">\u4EC5\u7BA1\u7406\u5458\u53EF\u8BC4\u8BBA</div>'));
3969
3963
  if (!this.user.data.isAdmin) {
3970
3964
  this.$textarea.style.display = "none";
3971
3965
  this.closePlug();
@@ -3976,7 +3970,8 @@ class Editor extends Component {
3976
3970
  }
3977
3971
  }
3978
3972
  open() {
3979
- this.$closeComment.style.display = "none";
3973
+ var _a;
3974
+ (_a = this.$textareaWrap.querySelector(".atk-comment-closed")) == null ? void 0 : _a.remove();
3980
3975
  this.$textarea.style.display = "";
3981
3976
  this.$bottom.style.display = "";
3982
3977
  }
@@ -4000,7 +3995,7 @@ class Editor extends Component {
4000
3995
  }
4001
3996
  }
4002
3997
  var list = "";
4003
- var ListHTML = '<div class="atk-list">\n <div class="atk-list-header">\n <div class="atk-comment-count">\n <span class="atk-comment-count-num">0</span>\n \u6761\u8BC4\u8BBA\n </div>\n <div class="atk-right-action">\n <span data-action="admin-close-comment" class="atk-hide" atk-only-admin-show>\u5173\u95ED\u8BC4\u8BBA</span>\n <span data-action="open-sidebar" class="atk-hide atk-on">\n <span class="atk-unread-badge" style="display: none;"></span>\n \u901A\u77E5\u4E2D\u5FC3\n </span>\n </div>\n </div>\n <div class="atk-list-body"></div>\n <div class="atk-list-footer">\n <div class="atk-copyright"></div>\n </div>\n</div>\n';
3998
+ var ListHTML = '<div class="atk-list">\n <div class="atk-list-header">\n <div class="atk-comment-count">\n <span class="atk-comment-count-num">0</span>\n \u6761\u8BC4\u8BBA\n </div>\n <div class="atk-right-action">\n <span data-action="admin-close-comment" class="atk-hide" atk-only-admin-show>\u5173\u95ED\u8BC4\u8BBA</span>\n <span data-action="open-sidebar" class="atk-hide atk-on">\n <span class="atk-unread-badge" style="display: none;"></span>\n <div class="atk-text">\u901A\u77E5\u4E2D\u5FC3</div>\n </span>\n </div>\n </div>\n <div class="atk-list-body"></div>\n <div class="atk-list-footer">\n <div class="atk-copyright"></div>\n </div>\n</div>\n';
4004
3999
  var comment = "";
4005
4000
  var win = window || {};
4006
4001
  var nav = navigator || {};
@@ -4243,7 +4238,7 @@ function Detect(userAgent) {
4243
4238
  function detectFactory(u) {
4244
4239
  return new Detect(u);
4245
4240
  }
4246
- var CommentHTML = '<div class="atk-comment-wrap" data-comment-id="">\n <div class="atk-comment">\n\n <div class="atk-avatar"></div>\n\n <div class="atk-comment-main">\n\n <div class="atk-header">\n <span class="atk-nick"></span>\n <span class="atk-badge"></span>\n <span class="atk-date"></span>\n </div>\n\n <div class="atk-body">\n <div class="atk-content"></div>\n </div>\n\n <div class="atk-footer">\n <div class="atk-comment-actions"></div>\n </div>\n\n </div>\n\n </div>\n</div>\n';
4241
+ var CommentHTML = '<div class="atk-comment-wrap">\n <div class="atk-comment">\n <div class="atk-avatar"></div>\n <div class="atk-main">\n <div class="atk-header">\n <span class="atk-item atk-nick"></span>\n <span class="atk-item atk-badge"></span>\n <span class="atk-item atk-date"></span>\n </div>\n <div class="atk-body">\n <div class="atk-content"></div>\n </div>\n <div class="atk-footer">\n <div class="atk-actions"></div>\n </div>\n </div>\n </div>\n</div>\n';
4247
4242
  class ActionBtn {
4248
4243
  constructor(conf) {
4249
4244
  __publicField(this, "conf");
@@ -4306,7 +4301,7 @@ class ActionBtn {
4306
4301
  this.setLoading(false);
4307
4302
  this.$el.innerText = this.getText();
4308
4303
  }
4309
- setLoading(value = true, loadingText) {
4304
+ setLoading(value, loadingText) {
4310
4305
  if (this.isLoading === value)
4311
4306
  return;
4312
4307
  this.isLoading = value;
@@ -4393,11 +4388,11 @@ class Comment extends Component {
4393
4388
  }
4394
4389
  render() {
4395
4390
  this.$el = createElement(CommentHTML);
4396
- this.$main = this.$el.querySelector(".atk-comment-main");
4391
+ this.$main = this.$el.querySelector(".atk-main");
4397
4392
  this.$header = this.$el.querySelector(".atk-header");
4398
4393
  this.$body = this.$el.querySelector(".atk-body");
4399
4394
  this.$content = this.$body.querySelector(".atk-content");
4400
- this.$actions = this.$el.querySelector(".atk-comment-actions");
4395
+ this.$actions = this.$el.querySelector(".atk-actions");
4401
4396
  this.$children = null;
4402
4397
  this.$el.setAttribute("data-comment-id", `${this.data.id}`);
4403
4398
  this.renderCheckUnread();
@@ -4540,7 +4535,7 @@ class Comment extends Component {
4540
4535
  }
4541
4536
  }
4542
4537
  if (this.data.is_allow_reply) {
4543
- const replyBtn = createElement(`<span data-atk-action="comment-reply">\u56DE\u590D</span>`);
4538
+ const replyBtn = createElement(`<span>\u56DE\u590D</span>`);
4544
4539
  this.$actions.append(replyBtn);
4545
4540
  replyBtn.addEventListener("click", (e) => {
4546
4541
  e.stopPropagation();
@@ -4612,6 +4607,7 @@ class Comment extends Component {
4612
4607
  this.children.push(childC);
4613
4608
  this.getChildrenEl().appendChild(childC.getEl());
4614
4609
  childC.playFadeInAnim();
4610
+ childC.checkHeightLimitArea("content");
4615
4611
  }
4616
4612
  getChildrenEl() {
4617
4613
  if (this.$children === null) {
@@ -4727,6 +4723,76 @@ class Comment extends Component {
4727
4723
  this.openURL = url;
4728
4724
  this.$el.classList.add("atk-openable");
4729
4725
  }
4726
+ checkHeightLimit() {
4727
+ this.checkHeightLimitArea("content");
4728
+ this.checkHeightLimitArea("children");
4729
+ }
4730
+ checkHeightLimitArea(area) {
4731
+ var _a, _b;
4732
+ const childrenMaxH = (_a = this.ctx.conf.heightLimit) == null ? void 0 : _a.children;
4733
+ const contentMaxH = (_b = this.ctx.conf.heightLimit) == null ? void 0 : _b.content;
4734
+ if (area === "children" && !childrenMaxH)
4735
+ return;
4736
+ if (area === "content" && !contentMaxH)
4737
+ return;
4738
+ let maxHeight;
4739
+ if (area === "children")
4740
+ maxHeight = childrenMaxH;
4741
+ if (area === "content")
4742
+ maxHeight = contentMaxH;
4743
+ const checkEl = ($el) => {
4744
+ if (!$el)
4745
+ return;
4746
+ if (getHeight($el) > maxHeight) {
4747
+ this.heightLimitAdd($el, maxHeight);
4748
+ }
4749
+ };
4750
+ if (area === "children") {
4751
+ checkEl(this.$children);
4752
+ } else if (area === "content") {
4753
+ checkEl(this.$content);
4754
+ checkEl(this.$replyTo);
4755
+ onImagesLoaded(this.$content, () => {
4756
+ checkEl(this.$content);
4757
+ });
4758
+ if (this.$replyTo) {
4759
+ onImagesLoaded(this.$replyTo, () => {
4760
+ checkEl(this.$replyTo);
4761
+ });
4762
+ }
4763
+ }
4764
+ }
4765
+ heightLimitRemove($el) {
4766
+ if (!$el)
4767
+ return;
4768
+ if (!$el.classList.contains("atk-height-limit"))
4769
+ return;
4770
+ $el.classList.remove("atk-height-limit");
4771
+ Array.from($el.children).forEach((e) => {
4772
+ if (e.classList.contains("atk-height-limit-btn"))
4773
+ e.remove();
4774
+ });
4775
+ $el.style.height = "";
4776
+ $el.style.overflow = "";
4777
+ }
4778
+ heightLimitAdd($el, maxHeight) {
4779
+ if (!$el)
4780
+ return;
4781
+ if ($el.classList.contains("atk-height-limit"))
4782
+ return;
4783
+ $el.classList.add("atk-height-limit");
4784
+ $el.style.height = `${maxHeight}px`;
4785
+ $el.style.overflow = "hidden";
4786
+ const $hideMoreOpenBtn = createElement(`<div class="atk-height-limit-btn">\u9605\u8BFB\u66F4\u591A</span>`);
4787
+ $hideMoreOpenBtn.onclick = (e) => {
4788
+ e.stopPropagation();
4789
+ this.heightLimitRemove($el);
4790
+ const children = this.getChildren();
4791
+ if (children.length === 1)
4792
+ children[0].heightLimitRemove(children[0].$content);
4793
+ };
4794
+ $el.append($hideMoreOpenBtn);
4795
+ }
4730
4796
  }
4731
4797
  var pagination = "";
4732
4798
  class Pagination {
@@ -4759,7 +4825,7 @@ class Pagination {
4759
4825
  this.checkDisabled();
4760
4826
  }
4761
4827
  get pageSize() {
4762
- return this.conf.pageSize || 15;
4828
+ return this.conf.pageSize;
4763
4829
  }
4764
4830
  get offset() {
4765
4831
  return this.pageSize * (this.page - 1);
@@ -4869,19 +4935,28 @@ class ReadMoreBtn {
4869
4935
  __publicField(this, "$el");
4870
4936
  __publicField(this, "$loading");
4871
4937
  __publicField(this, "$text");
4938
+ __publicField(this, "offset", 0);
4939
+ __publicField(this, "total", 0);
4872
4940
  this.conf = conf;
4873
4941
  this.$el = createElement(`<div class="atk-list-read-more" style="display: none;">
4874
4942
  <div class="atk-list-read-more-inner">
4875
4943
  <div class="atk-loading-icon" style="display: none;"></div>
4876
- <span class="atk-text">\u67E5\u770B\u66F4\u591A</span>
4944
+ <span class="atk-text">\u52A0\u8F7D\u66F4\u591A</span>
4877
4945
  </div>
4878
4946
  </div>`);
4879
4947
  this.$loading = this.$el.querySelector(".atk-loading-icon");
4880
4948
  this.$text = this.$el.querySelector(".atk-text");
4881
- this.$el.onclick = () => this.click();
4949
+ this.$el.onclick = () => {
4950
+ this.click();
4951
+ };
4952
+ }
4953
+ get hasMore() {
4954
+ return this.total > this.offset + this.conf.pageSize;
4882
4955
  }
4883
4956
  click() {
4884
- this.conf.onClick();
4957
+ if (this.hasMore)
4958
+ this.conf.onClick(this.offset + this.conf.pageSize);
4959
+ this.checkDisabled();
4885
4960
  }
4886
4961
  show() {
4887
4962
  this.$el.style.display = "";
@@ -4902,38 +4977,43 @@ class ReadMoreBtn {
4902
4977
  this.$el.classList.remove("atk-err");
4903
4978
  }, 2e3);
4904
4979
  }
4980
+ update(offset, total) {
4981
+ this.offset = offset;
4982
+ this.total = total;
4983
+ this.checkDisabled();
4984
+ }
4985
+ checkDisabled() {
4986
+ if (this.hasMore)
4987
+ this.show();
4988
+ else
4989
+ this.hide();
4990
+ }
4905
4991
  }
4906
4992
  class ListLite extends Component {
4907
- constructor(ctx, $parent) {
4993
+ constructor(ctx) {
4908
4994
  super(ctx);
4909
- __publicField(this, "$parent");
4910
4995
  __publicField(this, "$commentsWrap");
4911
4996
  __publicField(this, "comments", []);
4912
4997
  __publicField(this, "data");
4913
- __publicField(this, "pageSize", 15);
4914
- __publicField(this, "offset", 0);
4915
- __publicField(this, "type");
4916
- __publicField(this, "noCommentText");
4917
- __publicField(this, "renderComment");
4918
- __publicField(this, "paramsEditor");
4919
- __publicField(this, "onAfterLoad");
4920
4998
  __publicField(this, "isLoading", false);
4921
- __publicField(this, "isFirstLoad", true);
4922
- __publicField(this, "flatMode");
4999
+ __publicField(this, "noCommentText", "\u65E0\u5185\u5BB9");
5000
+ __publicField(this, "flatMode", false);
4923
5001
  __publicField(this, "pageMode", "pagination");
5002
+ __publicField(this, "pageSize", 20);
5003
+ __publicField(this, "scrollListenerAt");
5004
+ __publicField(this, "repositionAt");
4924
5005
  __publicField(this, "pagination");
4925
5006
  __publicField(this, "readMoreBtn");
4926
5007
  __publicField(this, "autoLoadScrollEvent");
4927
- __publicField(this, "autoLoadListenerAt");
5008
+ __publicField(this, "renderComment");
5009
+ __publicField(this, "paramsEditor");
5010
+ __publicField(this, "onAfterLoad");
4928
5011
  __publicField(this, "unread", []);
4929
- __publicField(this, "unreadHighlight", false);
4930
- this.$parent = $parent;
5012
+ __publicField(this, "unreadHighlight");
4931
5013
  this.$el = createElement(`<div class="atk-list-lite">
4932
5014
  <div class="atk-list-comments-wrap"></div>
4933
5015
  </div>`);
4934
5016
  this.$commentsWrap = this.$el.querySelector(".atk-list-comments-wrap");
4935
- this.pageSize = this.conf.pagination ? this.conf.pagination.pageSize || this.pageSize : this.pageSize;
4936
- this.noCommentText = this.conf.noComment || "\u65E0\u8BC4\u8BBA";
4937
5017
  window.setInterval(() => {
4938
5018
  this.$el.querySelectorAll("[data-atk-comment-date]").forEach((el) => {
4939
5019
  const date = el.getAttribute("data-atk-comment-date");
@@ -4942,11 +5022,10 @@ class ListLite extends Component {
4942
5022
  }, 30 * 1e3);
4943
5023
  this.ctx.on("unread-update", (data) => this.updateUnread(data.notifies));
4944
5024
  }
4945
- reqComments(offset = 0) {
5025
+ fetchComments(offset) {
4946
5026
  return __async(this, null, function* () {
4947
- if (offset === 0 && this.pageMode !== "pagination") {
4948
- this.clearAllComments();
4949
- }
5027
+ if (this.isLoading)
5028
+ return;
4950
5029
  const showLoading$1 = () => {
4951
5030
  this.isLoading = true;
4952
5031
  if (offset === 0)
@@ -4967,28 +5046,23 @@ class ListLite extends Component {
4967
5046
  };
4968
5047
  showLoading$1();
4969
5048
  this.ctx.trigger("comments-load");
5049
+ if (this.pageMode === "read-more" && offset === 0) {
5050
+ this.clearAllComments();
5051
+ }
4970
5052
  let listData;
4971
5053
  try {
4972
- listData = yield new Api(this.ctx).get(offset, this.type, this.flatMode, this.paramsEditor);
5054
+ listData = yield new Api(this.ctx).get(offset, this.pageSize, this.flatMode, this.paramsEditor);
4973
5055
  } catch (e) {
4974
- this.onError(e.msg || String(e));
5056
+ this.onError(e.msg || String(e), offset);
4975
5057
  throw e;
4976
5058
  } finally {
4977
5059
  hideLoading$1();
4978
5060
  }
4979
- if (this.ctx.conf.versionCheck) {
4980
- const needUpdate = this.apiVersionCheck(listData.api_version || {});
4981
- if (needUpdate)
4982
- return;
4983
- }
4984
- this.offset = offset;
5061
+ setError(this.$el, null);
4985
5062
  try {
4986
5063
  this.onLoad(listData, offset);
4987
- if (this.onAfterLoad) {
4988
- this.onAfterLoad(listData);
4989
- }
4990
5064
  } catch (e) {
4991
- this.onError(String(e));
5065
+ this.onError(String(e), offset);
4992
5066
  throw e;
4993
5067
  } finally {
4994
5068
  hideLoading$1();
@@ -4996,128 +5070,116 @@ class ListLite extends Component {
4996
5070
  });
4997
5071
  }
4998
5072
  onLoad(data, offset) {
4999
- var _a;
5000
- setError(this.$el, null);
5001
5073
  if (this.pageMode === "pagination") {
5002
5074
  this.clearAllComments();
5003
5075
  }
5004
5076
  this.data = data;
5077
+ if (this.ctx.conf.versionCheck && this.versionCheck(data.api_version))
5078
+ return;
5005
5079
  this.importComments(data.comments);
5006
- if (this.isFirstLoad) {
5007
- this.onLoadInit();
5008
- }
5009
- if (this.pageMode === "pagination") {
5010
- this.pagination.update(offset, ((_a = this.data) == null ? void 0 : _a.total_parents) || 0);
5011
- }
5012
- if (this.pageMode === "read-more") {
5013
- if (this.hasMoreComments)
5014
- this.readMoreBtn.show();
5015
- else
5016
- this.readMoreBtn.hide();
5017
- }
5080
+ this.refreshPagination(offset, this.flatMode ? data.total : data.total_roots);
5081
+ this.refreshUI();
5018
5082
  this.ctx.trigger("unread-update", { notifies: data.unread || [] });
5019
- this.isFirstLoad = false;
5020
- }
5021
- onLoadInit() {
5083
+ this.ctx.trigger("comments-loaded");
5084
+ if (this.onAfterLoad)
5085
+ this.onAfterLoad(data);
5086
+ }
5087
+ refreshPagination(offset, total) {
5088
+ const modePagination = this.pageMode === "pagination";
5089
+ const modeReadMoreBtn = this.pageMode === "read-more";
5090
+ const initialized = modePagination ? !!this.pagination : !!this.readMoreBtn;
5091
+ if (!initialized) {
5092
+ this.initPagination();
5093
+ }
5094
+ if (modePagination)
5095
+ this.pagination.update(offset, total);
5096
+ if (modeReadMoreBtn)
5097
+ this.readMoreBtn.update(offset, total);
5098
+ }
5099
+ initPagination() {
5022
5100
  var _a;
5023
- if (this.autoLoadScrollEvent) {
5024
- const at = this.autoLoadListenerAt || document;
5025
- at.removeEventListener("scroll", this.autoLoadScrollEvent);
5026
- }
5027
5101
  if (this.pageMode === "read-more") {
5028
- const readMoreBtn = new ReadMoreBtn({
5029
- onClick: () => __async(this, null, function* () {
5030
- const offset = this.offset + this.pageSize;
5031
- yield this.reqComments(offset);
5102
+ this.readMoreBtn = new ReadMoreBtn({
5103
+ pageSize: this.pageSize,
5104
+ onClick: (o) => __async(this, null, function* () {
5105
+ yield this.fetchComments(o);
5032
5106
  })
5033
5107
  });
5034
- if (this.readMoreBtn)
5035
- this.readMoreBtn.$el.replaceWith(readMoreBtn.$el);
5036
- else
5037
- this.$el.append(readMoreBtn.$el);
5038
- this.readMoreBtn = readMoreBtn;
5108
+ this.$el.append(this.readMoreBtn.$el);
5039
5109
  if ((_a = this.conf.pagination) == null ? void 0 : _a.autoLoad) {
5110
+ const at = this.scrollListenerAt || document;
5111
+ if (this.autoLoadScrollEvent)
5112
+ at.removeEventListener("scroll", this.autoLoadScrollEvent);
5040
5113
  this.autoLoadScrollEvent = () => {
5041
5114
  if (this.pageMode !== "read-more")
5042
5115
  return;
5043
- if (!this.hasMoreComments)
5116
+ if (!this.readMoreBtn)
5117
+ return;
5118
+ if (!this.readMoreBtn.hasMore)
5044
5119
  return;
5045
5120
  if (this.isLoading)
5046
5121
  return;
5047
5122
  const $target = this.$el.querySelector(".atk-list-comments-wrap > .atk-comment-wrap:nth-last-child(3)");
5048
5123
  if (!$target)
5049
5124
  return;
5050
- if (isVisible($target, this.autoLoadListenerAt)) {
5125
+ if (isVisible($target, this.scrollListenerAt)) {
5051
5126
  this.readMoreBtn.click();
5052
5127
  }
5053
5128
  };
5054
- const at = this.autoLoadListenerAt || document;
5055
5129
  at.addEventListener("scroll", this.autoLoadScrollEvent);
5056
5130
  }
5057
- } else if (this.pageMode === "pagination") {
5058
- const pagination2 = new Pagination(this.parentCommentsCount, {
5131
+ }
5132
+ if (this.pageMode === "pagination") {
5133
+ this.pagination = new Pagination(!this.flatMode ? this.data.total_roots : this.data.total, {
5059
5134
  pageSize: this.pageSize,
5060
- onChange: (offset) => __async(this, null, function* () {
5135
+ onChange: (o) => __async(this, null, function* () {
5061
5136
  if (this.ctx.conf.editorTravel === true) {
5062
5137
  this.ctx.trigger("editor-travel-back");
5063
5138
  }
5064
- yield this.reqComments(offset);
5065
- if (this.$parent) {
5066
- let topPos = 0;
5067
- if (!this.autoLoadListenerAt && this.$parent) {
5068
- topPos = getOffset(this.$parent).top;
5069
- }
5070
- const at = this.autoLoadListenerAt || window;
5139
+ yield this.fetchComments(o);
5140
+ if (this.repositionAt) {
5141
+ const at = this.scrollListenerAt || window;
5071
5142
  at.scroll({
5072
- top: topPos,
5143
+ top: this.repositionAt ? getOffset(this.repositionAt).top : 0,
5073
5144
  left: 0
5074
5145
  });
5075
5146
  }
5076
5147
  })
5077
5148
  });
5078
- if (this.pagination)
5079
- this.pagination.$el.replaceWith(pagination2.$el);
5080
- else
5081
- this.$el.append(pagination2.$el);
5082
- this.pagination = pagination2;
5149
+ this.$el.append(this.pagination.$el);
5083
5150
  }
5084
5151
  }
5085
- onError(msg) {
5152
+ onError(msg, offset) {
5086
5153
  var _a;
5087
5154
  msg = String(msg);
5088
5155
  console.error(msg);
5089
- if (this.isFirstLoad || this.pageMode === "pagination") {
5090
- const errEl = createElement(`<span>${msg}\uFF0C\u65E0\u6CD5\u83B7\u53D6\u8BC4\u8BBA\u5217\u8868\u6570\u636E<br/></span>`);
5091
- const retryBtn = createElement('<span style="cursor:pointer;">\u70B9\u51FB\u91CD\u65B0\u83B7\u53D6</span>');
5092
- retryBtn.onclick = () => {
5093
- this.reqComments(this.offset);
5094
- };
5095
- errEl.appendChild(retryBtn);
5096
- const adminBtn = createElement('<span atk-only-admin-show> | <span style="cursor:pointer;">\u6253\u5F00\u63A7\u5236\u53F0</span></span>');
5097
- adminBtn.onclick = () => {
5098
- this.ctx.trigger("sidebar-show");
5099
- };
5100
- if (!this.ctx.user.data.isAdmin) {
5101
- adminBtn.classList.add("atk-hide");
5102
- }
5103
- errEl.appendChild(adminBtn);
5104
- setError(this.$el, errEl);
5105
- } else {
5156
+ if (offset !== 0 && this.pageMode === "read-more") {
5106
5157
  (_a = this.readMoreBtn) == null ? void 0 : _a.showErr(`\u83B7\u53D6\u5931\u8D25`);
5158
+ return;
5107
5159
  }
5160
+ const $err = createElement(`<span>${msg}\uFF0C\u65E0\u6CD5\u83B7\u53D6\u8BC4\u8BBA\u5217\u8868\u6570\u636E<br/></span>`);
5161
+ const $retryBtn = createElement('<span style="cursor:pointer;">\u70B9\u51FB\u91CD\u65B0\u83B7\u53D6</span>');
5162
+ $retryBtn.onclick = () => this.fetchComments(0);
5163
+ $err.appendChild($retryBtn);
5164
+ const adminBtn = createElement('<span atk-only-admin-show> | <span style="cursor:pointer;">\u6253\u5F00\u63A7\u5236\u53F0</span></span>');
5165
+ adminBtn.onclick = () => this.ctx.trigger("sidebar-show");
5166
+ if (!this.ctx.user.data.isAdmin)
5167
+ adminBtn.classList.add("atk-hide");
5168
+ $err.appendChild(adminBtn);
5169
+ setError(this.$el, $err);
5108
5170
  }
5109
5171
  refreshUI() {
5110
- const noComment = this.comments.length <= 0;
5111
- let noCommentEl = this.$commentsWrap.querySelector(".atk-list-no-comment");
5112
- if (noComment) {
5113
- if (!noCommentEl) {
5114
- noCommentEl = createElement('<div class="atk-list-no-comment"></div>');
5115
- this.$commentsWrap.appendChild(noCommentEl);
5116
- noCommentEl.innerHTML = this.noCommentText;
5172
+ const isNoComment = this.comments.length <= 0;
5173
+ let $noComment = this.$commentsWrap.querySelector(".atk-list-no-comment");
5174
+ if (isNoComment) {
5175
+ if (!$noComment) {
5176
+ $noComment = createElement('<div class="atk-list-no-comment"></div>');
5177
+ $noComment.innerHTML = this.noCommentText;
5178
+ this.$commentsWrap.appendChild($noComment);
5117
5179
  }
5180
+ } else {
5181
+ $noComment == null ? void 0 : $noComment.remove();
5118
5182
  }
5119
- if (!noComment && noCommentEl)
5120
- noCommentEl.remove();
5121
5183
  this.ctx.trigger("check-admin-show-el");
5122
5184
  }
5123
5185
  createComment(data) {
@@ -5132,66 +5194,58 @@ class ListLite extends Component {
5132
5194
  };
5133
5195
  return comment2;
5134
5196
  }
5135
- importComments(rawData) {
5136
- const queryImportChildren = (parentC) => {
5137
- const children = rawData.filter((o) => o.rid === parentC.data.id);
5138
- if (children.length === 0)
5139
- return;
5140
- children.forEach((itemData) => {
5141
- itemData.is_allow_reply = parentC.data.is_allow_reply;
5142
- const childC = this.createComment(itemData);
5197
+ importComments(srcData) {
5198
+ if (this.flatMode) {
5199
+ srcData.forEach((commentData) => {
5200
+ this.putCommentFlatMode(commentData, srcData, "append");
5201
+ });
5202
+ } else {
5203
+ this.importCommentsNesting(srcData);
5204
+ }
5205
+ }
5206
+ importCommentsNesting(srcData) {
5207
+ const loadChildren = (parentC) => {
5208
+ const children = srcData.filter((o) => o.rid === parentC.data.id);
5209
+ children.forEach((childData) => {
5210
+ const childC = this.createComment(childData);
5143
5211
  childC.render();
5144
5212
  parentC.putChild(childC);
5145
- queryImportChildren(childC);
5213
+ loadChildren(childC);
5146
5214
  });
5147
5215
  };
5148
- if (!this.flatMode) {
5149
- rawData.filter((o) => o.rid === 0).forEach((rootCommentData) => {
5150
- if (rootCommentData.is_collapsed)
5151
- rootCommentData.is_allow_reply = false;
5152
- const rootComment = this.createComment(rootCommentData);
5153
- rootComment.render();
5154
- this.comments.push(rootComment);
5155
- this.$commentsWrap.appendChild(rootComment.getEl());
5156
- rootComment.playFadeInAnim();
5157
- queryImportChildren(rootComment);
5158
- });
5159
- } else {
5160
- rawData.forEach((commentData) => {
5161
- this.putCommentFlatMode(commentData, rawData, "append");
5162
- });
5163
- }
5164
- this.eachComment(this.comments, (c) => {
5165
- if (c.getIsRoot())
5166
- this.checkMoreHide(c);
5216
+ const rootComments = srcData.filter((o) => o.rid === 0);
5217
+ rootComments.forEach((rootData) => {
5218
+ const rootC = this.createComment(rootData);
5219
+ rootC.render();
5220
+ this.$commentsWrap.appendChild(rootC.getEl());
5221
+ rootC.playFadeInAnim();
5222
+ this.comments.push(rootC);
5223
+ loadChildren(rootC);
5224
+ rootC.checkHeightLimit();
5167
5225
  });
5168
- this.refreshUI();
5169
- this.ctx.trigger("comments-loaded");
5170
5226
  }
5171
- putCommentFlatMode(commentItem, comments, insertMode) {
5172
- if (commentItem.is_collapsed)
5173
- commentItem.is_allow_reply = false;
5174
- const comment2 = this.createComment(commentItem);
5175
- if (commentItem.rid !== 0) {
5176
- const rComment = comments.find((o) => o.id === commentItem.rid);
5227
+ putCommentFlatMode(cData, srcData, insertMode) {
5228
+ if (cData.is_collapsed)
5229
+ cData.is_allow_reply = false;
5230
+ const comment2 = this.createComment(cData);
5231
+ if (cData.rid !== 0) {
5232
+ const rComment = srcData.find((o) => o.id === cData.rid);
5177
5233
  if (rComment)
5178
5234
  comment2.replyTo = rComment;
5179
5235
  }
5180
5236
  comment2.render();
5181
- if (insertMode === "append") {
5237
+ if (insertMode === "append")
5182
5238
  this.comments.push(comment2);
5183
- } else {
5239
+ if (insertMode === "prepend")
5184
5240
  this.comments.unshift(comment2);
5185
- }
5186
- if (commentItem.visible) {
5187
- if (insertMode === "append") {
5188
- this.$commentsWrap.appendChild(comment2.getEl());
5189
- } else {
5241
+ if (cData.visible) {
5242
+ if (insertMode === "append")
5243
+ this.$commentsWrap.append(comment2.getEl());
5244
+ if (insertMode === "prepend")
5190
5245
  this.$commentsWrap.prepend(comment2.getEl());
5191
- }
5192
5246
  comment2.playFadeInAnim();
5193
5247
  }
5194
- this.checkMoreHide(comment2);
5248
+ comment2.checkHeightLimit();
5195
5249
  return comment2;
5196
5250
  }
5197
5251
  insertComment(commentData) {
@@ -5201,18 +5255,17 @@ class ListLite extends Component {
5201
5255
  if (commentData.rid === 0) {
5202
5256
  this.$commentsWrap.prepend(comment2.getEl());
5203
5257
  this.comments.unshift(comment2);
5204
- this.checkMoreHide(comment2);
5205
5258
  } else {
5206
5259
  const parent = this.findComment(commentData.rid);
5207
5260
  if (parent) {
5208
5261
  parent.putChild(comment2);
5209
- if (parent.$children)
5210
- this.removeHideMore(parent.$children);
5211
- this.eachComment(parent.children, (c) => {
5212
- this.checkMoreHide(c);
5262
+ comment2.getParents().forEach((p) => {
5263
+ if (p.$children)
5264
+ p.heightLimitRemove(p.$children);
5213
5265
  });
5214
5266
  }
5215
5267
  }
5268
+ comment2.checkHeightLimit();
5216
5269
  scrollIntoView(comment2.getEl());
5217
5270
  comment2.playFadeInAnim();
5218
5271
  } else {
@@ -5224,92 +5277,6 @@ class ListLite extends Component {
5224
5277
  this.refreshUI();
5225
5278
  this.ctx.trigger("comments-loaded");
5226
5279
  }
5227
- checkMoreHide(c) {
5228
- const check = () => {
5229
- this.checkMoreHideEl(c, "children");
5230
- this.checkMoreHideEl(c, "content");
5231
- if (c.$replyTo)
5232
- this.checkMoreHideEl(c, "replyTo");
5233
- };
5234
- check();
5235
- if (c.$content.querySelectorAll("img").length) {
5236
- onImagesLoaded(c.$content, () => {
5237
- check();
5238
- });
5239
- }
5240
- }
5241
- checkMoreHideEl(comment2, area, allowHeight = 300) {
5242
- var _a, _b;
5243
- const childrenH = (_a = this.ctx.conf.heightLimit) == null ? void 0 : _a.children;
5244
- const contentH = (_b = this.ctx.conf.heightLimit) == null ? void 0 : _b.content;
5245
- if (area === "children" && !childrenH)
5246
- return;
5247
- if ((area === "content" || area === "replyTo") && !contentH)
5248
- return;
5249
- if (area === "children")
5250
- allowHeight = childrenH || 300;
5251
- else
5252
- allowHeight = contentH || 200;
5253
- let $target;
5254
- if (area === "children")
5255
- $target = comment2.$children;
5256
- else if (area === "content")
5257
- $target = comment2.$content;
5258
- else if (area === "replyTo")
5259
- $target = comment2.$replyTo;
5260
- if (!$target)
5261
- return;
5262
- let $hideMoreOpenBtn = $target.querySelector(".atk-more-hide-open-btn");
5263
- const removeHideMore = () => {
5264
- $target.classList.remove("atk-comment-more-hide");
5265
- if ($hideMoreOpenBtn)
5266
- $hideMoreOpenBtn.remove();
5267
- $target.style.height = "";
5268
- $target.style.overflow = "";
5269
- };
5270
- if (getHeight($target) > allowHeight) {
5271
- $target.classList.add("atk-comment-more-hide");
5272
- $target.style.height = `${allowHeight}px`;
5273
- $target.style.overflow = "hidden";
5274
- if (!$hideMoreOpenBtn) {
5275
- $hideMoreOpenBtn = createElement(`<div class="atk-more-hide-open-btn">\u9605\u8BFB\u66F4\u591A</span>`);
5276
- $hideMoreOpenBtn.onclick = (e) => {
5277
- e.stopPropagation();
5278
- removeHideMore();
5279
- if (comment2.getIsRoot()) {
5280
- const children = comment2.getChildren();
5281
- if (children.length > 1) {
5282
- this.eachComment(children, (c) => {
5283
- this.checkMoreHideEl(c, "content", contentH || 200);
5284
- });
5285
- }
5286
- }
5287
- };
5288
- $target.append($hideMoreOpenBtn);
5289
- }
5290
- }
5291
- }
5292
- removeHideMore($target) {
5293
- const $hideMoreOpenBtn = $target.querySelector(".atk-more-hide-open-btn");
5294
- $target.classList.remove("atk-comment-more-hide");
5295
- if ($hideMoreOpenBtn)
5296
- $hideMoreOpenBtn.remove();
5297
- $target.style.height = "";
5298
- $target.style.overflow = "";
5299
- }
5300
- get commentsCount() {
5301
- var _a;
5302
- return Number((_a = this.data) == null ? void 0 : _a.total) || 0;
5303
- }
5304
- get parentCommentsCount() {
5305
- var _a;
5306
- return Number((_a = this.data) == null ? void 0 : _a.total_parents) || 0;
5307
- }
5308
- get hasMoreComments() {
5309
- if (!this.data)
5310
- return false;
5311
- return (!this.flatMode ? this.data.total_parents : this.data.total) > this.offset + this.pageSize;
5312
- }
5313
5280
  eachComment(commentList, action) {
5314
5281
  if (commentList.length === 0)
5315
5282
  return;
@@ -5333,13 +5300,6 @@ class ListLite extends Component {
5333
5300
  });
5334
5301
  return comment2;
5335
5302
  }
5336
- getCommentCount() {
5337
- let count = 0;
5338
- this.eachComment(this.comments, () => {
5339
- count++;
5340
- });
5341
- return count;
5342
- }
5343
5303
  deleteComment(comment2) {
5344
5304
  let findComment;
5345
5305
  if (typeof comment2 === "number") {
@@ -5367,7 +5327,7 @@ class ListLite extends Component {
5367
5327
  }
5368
5328
  updateUnread(notifies) {
5369
5329
  this.unread = notifies;
5370
- if (this.unreadHighlight) {
5330
+ if (this.unreadHighlight === true) {
5371
5331
  this.eachComment(this.comments, (comment2) => {
5372
5332
  const notify = this.unread.find((o) => o.comment_id === comment2.data.id);
5373
5333
  if (notify) {
@@ -5385,16 +5345,16 @@ class ListLite extends Component {
5385
5345
  });
5386
5346
  }
5387
5347
  }
5388
- apiVersionCheck(versionData) {
5348
+ versionCheck(versionData) {
5389
5349
  const needVersion = (versionData == null ? void 0 : versionData.fe_min_version) || "0.0.0";
5390
- const needUpdate = versionCompare(needVersion, "2.1.3") === 1;
5350
+ const needUpdate = versionCompare(needVersion, "2.1.4") === 1;
5391
5351
  if (needUpdate) {
5392
- const errEl = createElement(`<div>\u524D\u7AEF Artalk \u7248\u672C\u5DF2\u8FC7\u65F6\uFF0C\u8BF7\u66F4\u65B0\u4EE5\u83B7\u5F97\u5B8C\u6574\u4F53\u9A8C<br/>\u82E5\u60A8\u662F\u7AD9\u70B9\u7BA1\u7406\u5458\uFF0C\u8BF7\u524D\u5F80 \u201C<a href="https://artalk.js.org/" target="_blank">\u5B98\u65B9\u6587\u6863</a>\u201D \u83B7\u53D6\u5E2E\u52A9<br/><br/><span style="color: var(--at-color-meta);">\u524D\u7AEF\u7248\u672C ${"2.1.3"}\uFF0C\u9700\u6C42\u7248\u672C >= ${needVersion}</span><br/><br/></div>`);
5352
+ const errEl = createElement(`<div>\u524D\u7AEF Artalk \u7248\u672C\u5DF2\u8FC7\u65F6\uFF0C\u8BF7\u66F4\u65B0\u4EE5\u83B7\u5F97\u5B8C\u6574\u4F53\u9A8C<br/>\u82E5\u60A8\u662F\u7AD9\u70B9\u7BA1\u7406\u5458\uFF0C\u8BF7\u524D\u5F80 \u201C<a href="https://artalk.js.org/" target="_blank">\u5B98\u65B9\u6587\u6863</a>\u201D \u83B7\u53D6\u5E2E\u52A9<br/><br/><span style="color: var(--at-color-meta);">\u524D\u7AEF\u7248\u672C ${"2.1.4"}\uFF0C\u9700\u6C42\u7248\u672C >= ${needVersion}</span><br/><br/></div>`);
5393
5353
  const ignoreBtn = createElement('<span style="cursor:pointer;">\u5FFD\u7565</span>');
5394
5354
  ignoreBtn.onclick = () => {
5395
5355
  setError(this.ctx, null);
5396
5356
  this.ctx.conf.versionCheck = false;
5397
- this.reqComments(0);
5357
+ this.fetchComments(0);
5398
5358
  };
5399
5359
  errEl.append(ignoreBtn);
5400
5360
  setError(this.ctx, errEl, '<span class="atk-warn-title">Artalk Warn</span>');
@@ -5404,9 +5364,9 @@ class ListLite extends Component {
5404
5364
  }
5405
5365
  class List extends ListLite {
5406
5366
  constructor(ctx) {
5407
- var _a;
5367
+ var _a, _b;
5408
5368
  const el = createElement(ListHTML);
5409
- super(ctx, el);
5369
+ super(ctx);
5410
5370
  __publicField(this, "$closeCommentBtn");
5411
5371
  __publicField(this, "$openSidebarBtn");
5412
5372
  __publicField(this, "$unreadBadge");
@@ -5421,9 +5381,11 @@ class List extends ListLite {
5421
5381
  }
5422
5382
  this.flatMode = flatMode;
5423
5383
  this.pageMode = ((_a = this.conf.pagination) == null ? void 0 : _a.readMore) ? "read-more" : "pagination";
5384
+ this.pageSize = ((_b = this.conf.pagination) == null ? void 0 : _b.pageSize) || 20;
5385
+ this.repositionAt = this.$el;
5424
5386
  this.initListActionBtn();
5425
- this.$el.querySelector(".atk-copyright").innerHTML = `Powered By <a href="https://artalk.js.org" target="_blank" title="Artalk v${"2.1.3"}">Artalk</a>`;
5426
- this.ctx.on("list-reload", () => this.reqComments(0));
5387
+ this.$el.querySelector(".atk-copyright").innerHTML = `Powered By <a href="https://artalk.js.org" target="_blank" title="Artalk v${"2.1.4"}">Artalk</a>`;
5388
+ this.ctx.on("list-reload", () => this.fetchComments(0));
5427
5389
  this.ctx.on("list-refresh-ui", () => this.refreshUI());
5428
5390
  this.ctx.on("list-import", (data) => this.importComments(data));
5429
5391
  this.ctx.on("list-insert", (data) => this.insertComment(data));
@@ -5452,15 +5414,16 @@ class List extends ListLite {
5452
5414
  });
5453
5415
  }
5454
5416
  refreshUI() {
5417
+ var _a;
5455
5418
  super.refreshUI();
5456
- this.$el.querySelector(".atk-comment-count-num").innerText = String(this.commentsCount);
5419
+ this.$el.querySelector(".atk-comment-count-num").innerText = String(Number((_a = this.data) == null ? void 0 : _a.total) || 0);
5457
5420
  if (!!this.ctx.user.data.nick && !!this.ctx.user.data.email) {
5458
5421
  this.$openSidebarBtn.classList.remove("atk-hide");
5459
5422
  } else {
5460
5423
  this.$openSidebarBtn.classList.add("atk-hide");
5461
5424
  }
5462
5425
  this.ctx.trigger("check-admin-show-el");
5463
- this.$openSidebarBtn.innerText = !this.ctx.user.data.isAdmin ? "\u901A\u77E5\u4E2D\u5FC3" : "\u63A7\u5236\u4E2D\u5FC3";
5426
+ this.$openSidebarBtn.querySelector(".atk-text").innerText = !this.ctx.user.data.isAdmin ? "\u901A\u77E5\u4E2D\u5FC3" : "\u63A7\u5236\u4E2D\u5FC3";
5464
5427
  if (!!this.data && !!this.data.page && this.data.page.admin_only === true) {
5465
5428
  this.ctx.trigger("editor-close");
5466
5429
  this.$closeCommentBtn.innerHTML = "\u6253\u5F00\u8BC4\u8BBA";
@@ -5619,10 +5582,10 @@ class MessageView extends SidebarView {
5619
5582
  };
5620
5583
  this.viewActiveTab = "mentions";
5621
5584
  }
5622
- this.list = new ListLite(this.ctx, this.$el);
5585
+ this.list = new ListLite(this.ctx);
5623
5586
  this.list.flatMode = true;
5624
5587
  this.list.unreadHighlight = true;
5625
- this.list.autoLoadListenerAt = this.$parent;
5588
+ this.list.scrollListenerAt = this.$parent;
5626
5589
  this.list.pageMode = "pagination";
5627
5590
  this.list.noCommentText = '<div class="atk-sidebar-no-content">\u65E0\u5185\u5BB9</div>';
5628
5591
  this.list.renderComment = (comment2) => {
@@ -5645,12 +5608,11 @@ class MessageView extends SidebarView {
5645
5608
  }
5646
5609
  switchTab(tab, siteName) {
5647
5610
  this.viewActiveTab = tab;
5648
- this.list.type = tab;
5649
- this.list.isFirstLoad = true;
5650
5611
  this.list.paramsEditor = (params) => {
5612
+ params.type = tab;
5651
5613
  params.site_name = siteName;
5652
5614
  };
5653
- this.list.reqComments();
5615
+ this.list.fetchComments(0);
5654
5616
  return true;
5655
5617
  }
5656
5618
  }
@@ -6764,7 +6726,7 @@ const _Artalk = class {
6764
6726
  this.$root.appendChild(this.list.$el);
6765
6727
  this.sidebar = new Sidebar(this.ctx);
6766
6728
  this.$root.appendChild(this.sidebar.$el);
6767
- this.list.reqComments();
6729
+ this.list.fetchComments(0);
6768
6730
  this.initEventBind();
6769
6731
  }
6770
6732
  initEventBind() {
@@ -6790,7 +6752,7 @@ const _Artalk = class {
6790
6752
  });
6791
6753
  }
6792
6754
  reload() {
6793
- this.list.reqComments();
6755
+ this.list.fetchComments(0);
6794
6756
  }
6795
6757
  initDarkMode() {
6796
6758
  const darkModeClassName = "atk-dark-mode";