artalk 2.1.0 → 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.
Files changed (45) hide show
  1. package/dist/Artalk.css +1 -1
  2. package/dist/Artalk.es.js +3895 -3106
  3. package/dist/Artalk.iife.js +1 -266
  4. package/dist/Artalk.js +1 -266
  5. package/package.json +19 -21
  6. package/src/api/index.ts +6 -7
  7. package/src/artalk.ts +11 -4
  8. package/src/components/action-btn.ts +1 -1
  9. package/src/components/comment.ts +102 -27
  10. package/src/components/editor-plugs/_example-plug.ts.txt +2 -7
  11. package/src/components/editor-plugs/editor-plug.ts +3 -3
  12. package/src/components/editor-plugs/emoticons-plug.less +21 -11
  13. package/src/components/editor-plugs/emoticons-plug.ts +199 -79
  14. package/src/components/editor-plugs/preview-plug.less +1 -1
  15. package/src/components/editor-plugs/preview-plug.ts +2 -7
  16. package/src/components/editor.ts +75 -34
  17. package/src/components/html/comment.html +6 -13
  18. package/src/components/html/editor.html +9 -10
  19. package/src/components/html/list.html +1 -1
  20. package/src/components/layer.ts +33 -14
  21. package/src/components/list-lite.ts +218 -235
  22. package/src/components/list.ts +11 -9
  23. package/src/components/pagination.ts +2 -2
  24. package/src/components/read-more-btn.ts +27 -10
  25. package/src/components/sidebar-views/comments-view.ts +12 -5
  26. package/src/components/sidebar-views/sites-view.ts +0 -6
  27. package/src/components/sidebar.ts +7 -2
  28. package/src/{default-conf.ts → defaults.ts} +7 -7
  29. package/src/lib/utils.ts +41 -12
  30. package/src/style/_color.less +19 -23
  31. package/src/style/_extend.less +3 -3
  32. package/src/style/_variables.less +0 -24
  33. package/src/style/comment.less +191 -197
  34. package/src/style/editor.less +78 -103
  35. package/src/style/item-text-editor.less +2 -2
  36. package/src/style/list.less +14 -13
  37. package/src/style/main.less +35 -31
  38. package/src/style/page-list.less +4 -4
  39. package/src/style/pagination.less +6 -6
  40. package/src/style/sidebar.less +35 -35
  41. package/src/style/site-list.less +13 -13
  42. package/types/artalk-config.d.ts +13 -10
  43. package/types/artalk-data.d.ts +10 -5
  44. package/types/event.d.ts +10 -1
  45. package/src/assets/emoticons.json +0 -100
@@ -8,7 +8,7 @@
8
8
  <span data-action="admin-close-comment" class="atk-hide" atk-only-admin-show>关闭评论</span>
9
9
  <span data-action="open-sidebar" class="atk-hide atk-on">
10
10
  <span class="atk-unread-badge" style="display: none;"></span>
11
- 通知中心
11
+ <div class="atk-text">通知中心</div>
12
12
  </span>
13
13
  </div>
14
14
  </div>
@@ -13,6 +13,8 @@ export default class Layer extends Component {
13
13
  private bodyStyleOrgOverflow = ''
14
14
  private bodyStyleOrgPaddingRight = ''
15
15
 
16
+ public afterHide?: Function
17
+
16
18
  constructor (ctx: Context, name: string, el?: HTMLElement) {
17
19
  super(ctx)
18
20
 
@@ -50,13 +52,8 @@ export default class Layer extends Component {
50
52
  return this.$el
51
53
  }
52
54
 
53
- private static hideTimeoutList: number[] = []
54
-
55
55
  show () {
56
- Layer.hideTimeoutList.forEach(item => {
57
- clearTimeout(item)
58
- })
59
- Layer.hideTimeoutList = []
56
+ this.fireAllActionTimer()
60
57
 
61
58
  this.$wrap.style.display = 'block'
62
59
  this.$mask.style.display = 'block'
@@ -77,26 +74,48 @@ export default class Layer extends Component {
77
74
  }
78
75
 
79
76
  hide () {
80
- Layer.hideTimeoutList.push(window.setTimeout(() => {
77
+ if (this.afterHide) this.afterHide()
78
+ this.$wrap.classList.add('atk-fade-out')
79
+ this.$el.style.display = 'none'
80
+
81
+ this.newActionTimer(() => {
81
82
  this.$wrap.style.display = 'none'
82
83
  // body style 禁止滚动解除
83
84
  document.body.style.overflow = this.bodyStyleOrgOverflow
84
85
  document.body.style.paddingRight = this.bodyStyleOrgPaddingRight
85
- }, 450))
86
-
87
- this.$wrap.classList.add('atk-fade-out')
88
- Layer.hideTimeoutList.push(window.setTimeout(() => {
86
+ this.checkCleanLayer()
87
+ }, 450)
88
+ this.newActionTimer(() => {
89
89
  this.$wrap.style.display = 'none'
90
90
  this.$wrap.classList.remove('atk-fade-out')
91
- }, 200))
92
-
93
- this.$el.style.display = 'none'
91
+ }, 200)
94
92
  }
95
93
 
96
94
  setMaskClickHide (enable: boolean) {
97
95
  this.maskClickHideEnable = enable
98
96
  }
99
97
 
98
+ // Timers
99
+ private static actionTimers: {act: Function, tid: number}[] = []
100
+
101
+ private newActionTimer(func: Function, delay: number) {
102
+ const act = () => {
103
+ func() // 执行
104
+ Layer.actionTimers = Layer.actionTimers.filter(o => o.act !== act) // 删除
105
+ }
106
+
107
+ const tid = window.setTimeout(() => act(), delay)
108
+
109
+ Layer.actionTimers.push({ act, tid })
110
+ }
111
+
112
+ private fireAllActionTimer() {
113
+ Layer.actionTimers.forEach(item => {
114
+ clearTimeout(item.tid)
115
+ item.act() // 立即执行
116
+ })
117
+ }
118
+
100
119
  /** 销毁 - 无动画 */
101
120
  disposeNow () {
102
121
  document.body.style.overflow = ''