hexo-theme-fluid 1.8.13 → 1.9.1

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 (155) hide show
  1. package/LICENSE +674 -21
  2. package/README.md +17 -21
  3. package/_config.yml +164 -79
  4. package/languages/de.yml +58 -33
  5. package/languages/en.yml +58 -33
  6. package/languages/eo.yml +58 -33
  7. package/languages/es.yml +69 -0
  8. package/languages/ja.yml +58 -33
  9. package/languages/zh-CN.yml +58 -33
  10. package/languages/zh-HK.yml +69 -0
  11. package/languages/zh-TW.yml +58 -33
  12. package/layout/.DS_Store +0 -0
  13. package/layout/404.ejs +3 -1
  14. package/layout/{_partial → _partials}/archive-list.ejs +4 -4
  15. package/layout/_partials/category-chains.ejs +19 -0
  16. package/layout/_partials/category-list.ejs +62 -0
  17. package/layout/{_partial → _partials}/comments/changyan.ejs +0 -0
  18. package/layout/{_partial → _partials}/comments/cusdis.ejs +0 -0
  19. package/layout/{_partial → _partials}/comments/disqus.ejs +0 -0
  20. package/layout/_partials/comments/giscus.ejs +36 -0
  21. package/layout/{_partial → _partials}/comments/gitalk.ejs +0 -0
  22. package/layout/{_partial → _partials}/comments/livere.ejs +0 -0
  23. package/layout/{_partial → _partials}/comments/remark42.ejs +0 -0
  24. package/layout/{_partial → _partials}/comments/twikoo.ejs +3 -1
  25. package/layout/{_partial → _partials}/comments/utterances.ejs +1 -1
  26. package/layout/{_partial → _partials}/comments/valine.ejs +3 -1
  27. package/layout/{_partial → _partials}/comments/waline.ejs +6 -3
  28. package/layout/_partials/comments.ejs +5 -0
  29. package/layout/_partials/css.ejs +26 -0
  30. package/layout/_partials/footer/beian.ejs +33 -0
  31. package/layout/_partials/footer/statistics.ejs +39 -0
  32. package/layout/_partials/footer.ejs +18 -0
  33. package/layout/{_partial → _partials}/head.ejs +7 -1
  34. package/layout/_partials/header/banner.ejs +33 -0
  35. package/layout/{_partial/nav.ejs → _partials/header/navigation.ejs} +3 -2
  36. package/layout/_partials/header.ejs +8 -0
  37. package/layout/{_partial → _partials}/paginator.ejs +0 -0
  38. package/layout/_partials/plugins/analytics.ejs +87 -0
  39. package/layout/_partials/plugins/anchorjs.ejs +24 -0
  40. package/layout/_partials/plugins/code-widget.ejs +71 -0
  41. package/layout/_partials/plugins/fancybox.ejs +11 -0
  42. package/layout/_partials/plugins/highlight.ejs +13 -0
  43. package/layout/_partials/plugins/math.ejs +46 -0
  44. package/layout/_partials/plugins/mermaid.ejs +5 -0
  45. package/layout/{_partial → _partials}/plugins/nprogress.ejs +0 -0
  46. package/layout/_partials/plugins/typed.ejs +48 -0
  47. package/layout/_partials/post/category-bar.ejs +18 -0
  48. package/layout/_partials/post/copyright.ejs +56 -0
  49. package/layout/_partials/post/meta-bottom.ejs +16 -0
  50. package/layout/_partials/post/meta-top.ejs +63 -0
  51. package/layout/_partials/post/sidebar-left.ejs +10 -0
  52. package/layout/_partials/post/sidebar-right.ejs +10 -0
  53. package/layout/_partials/post/toc.ejs +34 -0
  54. package/layout/_partials/scripts.ejs +32 -0
  55. package/layout/{_partial → _partials}/search.ejs +2 -3
  56. package/layout/about.ejs +5 -3
  57. package/layout/archive.ejs +1 -1
  58. package/layout/categories.ejs +10 -59
  59. package/layout/category.ejs +1 -1
  60. package/layout/index.ejs +13 -15
  61. package/layout/layout.ejs +19 -39
  62. package/layout/links.ejs +2 -8
  63. package/layout/page.ejs +28 -12
  64. package/layout/post.ejs +65 -59
  65. package/layout/tag.ejs +1 -1
  66. package/package.json +11 -3
  67. package/scripts/.DS_Store +0 -0
  68. package/scripts/events/.DS_Store +0 -0
  69. package/scripts/events/index.js +1 -0
  70. package/scripts/events/lib/compatible-configs.js +7 -8
  71. package/scripts/events/lib/footnote.js +1 -1
  72. package/scripts/events/lib/hello.js +6 -2
  73. package/scripts/events/lib/highlight.js +93 -24
  74. package/scripts/events/lib/injects.js +118 -0
  75. package/scripts/events/lib/merge-configs.js +37 -7
  76. package/scripts/filters/default-injects.js +27 -0
  77. package/scripts/filters/post-filter.js +7 -0
  78. package/scripts/helpers/date.js +25 -0
  79. package/scripts/helpers/engine.js +9 -0
  80. package/scripts/helpers/export-config.js +8 -0
  81. package/scripts/helpers/import.js +24 -0
  82. package/scripts/helpers/injects.js +7 -0
  83. package/scripts/helpers/scope.js +44 -0
  84. package/scripts/helpers/utils.js +17 -2
  85. package/scripts/tags/checkbox.js +4 -2
  86. package/scripts/utils/.DS_Store +0 -0
  87. package/scripts/utils/object.js +5 -0
  88. package/scripts/utils/resolve.js +15 -0
  89. package/source/.DS_Store +0 -0
  90. package/source/css/_pages/_archive/archive.styl +28 -0
  91. package/source/css/_pages/_base/_widget/anchorjs.styl +8 -0
  92. package/source/css/_pages/_base/_widget/banner.styl +2 -11
  93. package/source/css/_pages/_base/_widget/board.styl +1 -4
  94. package/source/css/_pages/_base/_widget/code-widget.styl +36 -0
  95. package/source/css/_pages/_base/_widget/copyright.styl +90 -0
  96. package/source/css/_pages/_base/_widget/footer.styl +4 -1
  97. package/source/css/_pages/_base/_widget/header.styl +161 -2
  98. package/source/css/_pages/_base/_widget/modal.styl +100 -0
  99. package/source/css/_pages/_base/_widget/ngrogress.styl +12 -0
  100. package/source/css/_pages/_base/_widget/noscript.styl +12 -0
  101. package/source/css/_pages/_base/_widget/pagination.styl +23 -0
  102. package/source/css/_pages/_base/_widget/scroll-btn.styl +2 -15
  103. package/source/css/_pages/_base/_widget/toc.styl +75 -0
  104. package/source/css/_pages/_base/base.styl +23 -3
  105. package/source/css/_pages/_base/color-schema.styl +30 -58
  106. package/source/css/_pages/_base/inline.styl +2 -2
  107. package/source/css/_pages/_category/category-bar.styl +59 -0
  108. package/source/css/_pages/_category/category-chain.styl +6 -0
  109. package/source/css/_pages/_category/{categories.styl → category-list.styl} +17 -11
  110. package/source/css/_pages/_index/index.styl +7 -5
  111. package/source/css/_pages/_links/links.styl +2 -1
  112. package/source/css/_pages/_post/comment.styl +27 -0
  113. package/source/css/_pages/_post/highlight.styl +65 -0
  114. package/source/css/_pages/_post/markdown.styl +91 -0
  115. package/source/css/_pages/_post/{post.styl → post-page.styl} +44 -75
  116. package/source/css/_pages/_post/{tag_plugin.styl → post-tag.styl} +29 -27
  117. package/source/css/_variables/base.styl +30 -9
  118. package/source/css/highlight-dark.styl +6 -0
  119. package/source/css/highlight.styl +6 -0
  120. package/source/css/main.styl +7 -0
  121. package/source/img/.DS_Store +0 -0
  122. package/source/img/default.png +0 -0
  123. package/source/img/{favicon.png → fluid.png} +0 -0
  124. package/source/js/boot.js +1 -9
  125. package/source/js/color-schema.js +52 -7
  126. package/source/js/events.js +15 -15
  127. package/source/js/leancloud.js +9 -2
  128. package/source/js/local-search.js +2 -2
  129. package/source/js/plugins.js +26 -94
  130. package/source/js/utils.js +28 -12
  131. package/.editorconfig +0 -13
  132. package/.eslintrc +0 -224
  133. package/.gitattributes +0 -1
  134. package/.github/ISSUE_TEMPLATE/bug_report.md +0 -28
  135. package/.github/ISSUE_TEMPLATE/bug_report_zh.md +0 -33
  136. package/.github/ISSUE_TEMPLATE/feature_request.md +0 -20
  137. package/.github/ISSUE_TEMPLATE/feature_request_zh.md +0 -20
  138. package/.github/ISSUE_TEMPLATE/question.md +0 -11
  139. package/.github/ISSUE_TEMPLATE/question_zh.md +0 -14
  140. package/.github/workflows/limit.yaml +0 -18
  141. package/README_en.md +0 -125
  142. package/layout/_partial/beian.ejs +0 -36
  143. package/layout/_partial/css.ejs +0 -47
  144. package/layout/_partial/footer.ejs +0 -11
  145. package/layout/_partial/plugins/analytics.ejs +0 -66
  146. package/layout/_partial/plugins/math.ejs +0 -69
  147. package/layout/_partial/plugins/mermaid.ejs +0 -24
  148. package/layout/_partial/plugins/typed.ejs +0 -41
  149. package/layout/_partial/post-meta.ejs +0 -51
  150. package/layout/_partial/scripts.ejs +0 -72
  151. package/layout/_partial/statistics.ejs +0 -43
  152. package/layout/_partial/toc.ejs +0 -4
  153. package/source/css/_pages/_base/_widget/copy-btn.styl +0 -42
  154. package/source/css/_pages/_base/rewrite.styl +0 -556
  155. package/source/css/_pages/_category/category.styl +0 -0
@@ -1,7 +1,7 @@
1
1
  /* global Fluid */
2
2
 
3
3
  /**
4
- * Modify by https://blog.skk.moe/post/hello-darkmode-my-old-friend/
4
+ * Modified from https://blog.skk.moe/post/hello-darkmode-my-old-friend/
5
5
  */
6
6
  (function(window, document) {
7
7
  var rootElement = document.documentElement;
@@ -101,6 +101,9 @@
101
101
  // 根据当前模式设置图标
102
102
  setButtonIcon(current);
103
103
 
104
+ // 设置代码高亮
105
+ setHighlightCSS(current);
106
+
104
107
  // 设置其他应用
105
108
  setApplications(current);
106
109
  }
@@ -176,6 +179,39 @@
176
179
  }
177
180
  }
178
181
 
182
+ function setHighlightCSS(schema) {
183
+ // 启用对应的代码高亮的样式
184
+ var lightCss = document.getElementById('highlight-css');
185
+ var darkCss = document.getElementById('highlight-css-dark');
186
+ if (schema === 'dark') {
187
+ if (darkCss) {
188
+ darkCss.removeAttribute('disabled');
189
+ }
190
+ if (lightCss) {
191
+ lightCss.setAttribute('disabled', '');
192
+ }
193
+ } else {
194
+ if (lightCss) {
195
+ lightCss.removeAttribute('disabled');
196
+ }
197
+ if (darkCss) {
198
+ darkCss.setAttribute('disabled', '');
199
+ }
200
+ }
201
+
202
+ setTimeout(function() {
203
+ // 设置代码块组件样式
204
+ document.querySelectorAll('.markdown-body pre').forEach((pre) => {
205
+ var cls = Fluid.utils.getBackgroundLightness(pre) >= 0 ? 'code-widget-light' : 'code-widget-dark';
206
+ var widget = pre.querySelector('.code-widget-light, .code-widget-dark');
207
+ if (widget) {
208
+ widget.classList.remove('code-widget-light', 'code-widget-dark');
209
+ widget.classList.add(cls);
210
+ }
211
+ });
212
+ }, 200);
213
+ }
214
+
179
215
  function setApplications(schema) {
180
216
  // 设置 remark42 评论主题
181
217
  if (window.REMARK42) {
@@ -188,18 +224,27 @@
188
224
  }
189
225
 
190
226
  // 设置 utterances 评论主题
191
- var utterances = document.querySelector('iframe');
227
+ var utterances = document.querySelector('.utterances-frame');
192
228
  if (utterances) {
193
- var theme = window.UtterancesThemeLight;
194
- if (schema === 'dark') {
195
- theme = window.UtterancesThemeDark;
196
- }
229
+ var utterancesTheme = schema === 'dark' ? window.UtterancesThemeDark : window.UtterancesThemeLight;
197
230
  const message = {
198
231
  type : 'set-theme',
199
- theme: theme
232
+ theme: utterancesTheme
200
233
  };
201
234
  utterances.contentWindow.postMessage(message, 'https://utteranc.es');
202
235
  }
236
+
237
+ // 设置 giscus 评论主题
238
+ var giscus = document.querySelector('iframe.giscus-frame');
239
+ if (giscus) {
240
+ var giscusTheme = schema === 'dark' ? window.GiscusThemeDark : window.GiscusThemeLight;
241
+ const message = {
242
+ setConfig: {
243
+ theme: giscusTheme,
244
+ }
245
+ };
246
+ giscus.contentWindow.postMessage({ 'giscus': message }, 'https://giscus.app');
247
+ }
203
248
  }
204
249
 
205
250
  // 当页面加载时,将显示模式设置为 localStorage 中自定义的值(如果有的话)
@@ -10,6 +10,9 @@ Fluid.events = {
10
10
 
11
11
  registerNavbarEvent: function() {
12
12
  var navbar = jQuery('#navbar');
13
+ if (navbar.length === 0) {
14
+ return;
15
+ }
13
16
  var submenu = jQuery('#navbar .dropdown-menu');
14
17
  if (navbar.offset().top > 0) {
15
18
  navbar.removeClass('navbar-dark');
@@ -33,8 +36,8 @@ Fluid.events = {
33
36
  },
34
37
 
35
38
  registerParallaxEvent: function() {
36
- var bg = jQuery('#banner[parallax="true"]');
37
- if (bg.length === 0) {
39
+ var ph = jQuery('#banner[parallax="true"]');
40
+ if (ph.length === 0) {
38
41
  return;
39
42
  }
40
43
  var board = jQuery('#board');
@@ -42,22 +45,19 @@ Fluid.events = {
42
45
  return;
43
46
  }
44
47
  var parallax = function() {
45
- var oVal = jQuery(window).scrollTop() / 5;
46
- var offset = parseInt(board.css('margin-top'), 0);
48
+ var pxv = jQuery(window).scrollTop() / 5;
49
+ var offset = parseInt(board.css('margin-top'), 10);
47
50
  var max = 96 + offset;
48
- if (oVal > max) {
49
- oVal = max;
51
+ if (pxv > max) {
52
+ pxv = max;
50
53
  }
51
- bg.css({
52
- transform : 'translate3d(0,' + oVal + 'px,0)',
53
- '-webkit-transform': 'translate3d(0,' + oVal + 'px,0)',
54
- '-ms-transform' : 'translate3d(0,' + oVal + 'px,0)',
55
- '-o-transform' : 'translate3d(0,' + oVal + 'px,0)'
54
+ ph.css({
55
+ transform: 'translate3d(0,' + pxv + 'px,0)'
56
56
  });
57
- var toc = jQuery('#toc');
58
- if (toc) {
59
- jQuery('#toc-ctn').css({
60
- 'padding-top': oVal + 'px'
57
+ var sideCol = jQuery('.side-col');
58
+ if (sideCol) {
59
+ sideCol.css({
60
+ 'padding-top': pxv + 'px'
61
61
  });
62
62
  }
63
63
  };
@@ -94,7 +94,7 @@
94
94
  }
95
95
 
96
96
  function addCount(Counter) {
97
- var enableIncr = CONFIG.web_analytics.enable && validHost();
97
+ var enableIncr = CONFIG.web_analytics.enable && !Fluid.ctx.dnt && validHost();
98
98
  var getterArr = [];
99
99
  var incrArr = [];
100
100
 
@@ -155,6 +155,13 @@
155
155
  var appKey = CONFIG.web_analytics.leancloud.app_key;
156
156
  var serverUrl = CONFIG.web_analytics.leancloud.server_url;
157
157
 
158
+ if (!appId) {
159
+ throw new Error('LeanCloud appId is empty');
160
+ }
161
+ if (!appKey) {
162
+ throw new Error('LeanCloud appKey is empty');
163
+ }
164
+
158
165
  function fetchData(api_server) {
159
166
  var Counter = (method, url, data) => {
160
167
  return fetch(`${api_server}/1.1${url}`, {
@@ -171,7 +178,7 @@
171
178
  addCount(Counter);
172
179
  }
173
180
 
174
- var apiServer = appId.slice(-9) !== '-MdYXbMMI' ? serverUrl : `https://${appId.slice(0, 8).toLowerCase()}.api.lncldglobal.com`;
181
+ var apiServer = serverUrl || `https://${appId.slice(0, 8).toLowerCase()}.api.lncldglobal.com`;
175
182
 
176
183
  if (apiServer) {
177
184
  fetchData(apiServer);
@@ -1,7 +1,7 @@
1
- /* global CONFIG, jQuery */
1
+ /* global CONFIG */
2
2
 
3
3
  (function() {
4
- // Modify by [hexo-generator-search](https://github.com/wzpan/hexo-generator-search)
4
+ // Modified from [hexo-generator-search](https://github.com/wzpan/hexo-generator-search)
5
5
  function localSearchFunc(path, searchSelector, resultSelector) {
6
6
  'use strict';
7
7
  // 0x00. environment initialization
@@ -1,4 +1,4 @@
1
- /* global Fluid, CONFIG, jQuery */
1
+ /* global Fluid, CONFIG */
2
2
 
3
3
  HTMLElement.prototype.wrap = function(wrapper) {
4
4
  this.parentNode.insertBefore(wrapper, this);
@@ -26,37 +26,12 @@ Fluid.plugins = {
26
26
  subtitle.innerText = '';
27
27
  }
28
28
  jQuery(document).ready(function() {
29
- jQuery('.typed-cursor').addClass('h2');
30
29
  typed.start();
31
30
  });
32
31
  },
33
32
 
34
- initTocBot: function() {
35
- var toc = jQuery('#toc');
36
- if (toc.length === 0 || !window.tocbot) { return; }
37
- var boardCtn = jQuery('#board-ctn');
38
- var boardTop = boardCtn.offset().top;
39
-
40
- window.tocbot.init({
41
- tocSelector : '#toc-body',
42
- contentSelector : '.markdown-body',
43
- headingSelector : CONFIG.toc.headingSelector || 'h1,h2,h3,h4,h5,h6',
44
- linkClass : 'tocbot-link',
45
- activeLinkClass : 'tocbot-active-link',
46
- listClass : 'tocbot-list',
47
- isCollapsedClass: 'tocbot-is-collapsed',
48
- collapsibleClass: 'tocbot-is-collapsible',
49
- collapseDepth : CONFIG.toc.collapseDepth || 0,
50
- scrollSmooth : true,
51
- headingsOffset : -boardTop
52
- });
53
- if (jQuery('.toc-list-item').length > 0) {
54
- toc.css('visibility', 'visible');
55
- }
56
- },
57
-
58
- initFancyBox: function(selector) {
59
- if (!('fancybox' in jQuery)) { return; }
33
+ fancyBox: function(selector) {
34
+ if (!CONFIG.image_zoom.enable || !('fancybox' in jQuery)) { return; }
60
35
 
61
36
  jQuery(selector || '.markdown-body :not(a) > img, .markdown-body > img').each(function() {
62
37
  var $image = jQuery(this);
@@ -79,16 +54,17 @@ Fluid.plugins = {
79
54
  <a class="fancybox fancybox.image" href="${imageUrl}"
80
55
  itemscope itemtype="http://schema.org/ImageObject" itemprop="url"></a>`
81
56
  ).parent('a');
82
- if ($image.is('.group-image-container img')) {
83
- $imageWrap.attr('data-fancybox', 'group').attr('rel', 'group');
84
- } else {
85
- $imageWrap.attr('data-fancybox', 'default').attr('rel', 'default');
86
- }
57
+ if ($imageWrap.length !== 0) {
58
+ if ($image.is('.group-image-container img')) {
59
+ $imageWrap.attr('data-fancybox', 'group').attr('rel', 'group');
60
+ } else {
61
+ $imageWrap.attr('data-fancybox', 'default').attr('rel', 'default');
62
+ }
87
63
 
88
- var imageTitle = $image.attr('title') || $image.attr('alt');
89
- if (imageTitle) {
90
- $imageWrap.append(`<p class="image-caption">${imageTitle}</p>`);
91
- $imageWrap.attr('title', imageTitle).attr('data-caption', imageTitle);
64
+ var imageTitle = $image.attr('title') || $image.attr('alt');
65
+ if (imageTitle) {
66
+ $imageWrap.attr('title', imageTitle).attr('data-caption', imageTitle);
67
+ }
92
68
  }
93
69
  });
94
70
 
@@ -103,65 +79,21 @@ Fluid.plugins = {
103
79
  });
104
80
  },
105
81
 
106
- initAnchor: function() {
107
- if (!('anchors' in window)) { return; }
108
-
109
- window.anchors.options = {
110
- placement: CONFIG.anchorjs.placement,
111
- visible : CONFIG.anchorjs.visible
112
- };
113
- if (CONFIG.anchorjs.icon) {
114
- window.anchors.options.icon = CONFIG.anchorjs.icon;
115
- }
116
- var el = (CONFIG.anchorjs.element || 'h1,h2,h3,h4,h5,h6').split(',');
117
- var res = [];
118
- for (const item of el) {
119
- res.push('.markdown-body > ' + item);
120
- }
121
- window.anchors.add(res.join(', '));
122
- },
123
-
124
- initCopyCode: function() {
125
- if (!('ClipboardJS' in window)) { return; }
126
-
127
- function getBgClass(ele) {
128
- if (ele.length === 0) {
129
- return 'copy-btn-dark';
130
- }
131
- var rgbArr = ele.css('background-color').replace(/rgba*\(/, '').replace(')', '').split(',');
132
- var color = (0.213 * rgbArr[0]) + (0.715 * rgbArr[1]) + (0.072 * rgbArr[2]) > 255 / 2;
133
- return color ? 'copy-btn-dark' : 'copy-btn-light';
134
- }
82
+ imageCaption: function(selector) {
83
+ if (!CONFIG.image_caption.enable) { return; }
135
84
 
136
- var copyHtml = '';
137
- copyHtml += '<button class="copy-btn" data-clipboard-snippet="">';
138
- copyHtml += '<i class="iconfont icon-copy"></i><span>Copy</span>';
139
- copyHtml += '</button>';
140
- var blockElement = jQuery('.markdown-body pre');
141
- blockElement.each(function() {
142
- const pre = jQuery(this);
143
- if (pre.find('code.mermaid').length > 0) {
144
- return;
145
- }
146
- if (pre.find('span.line').length > 0) {
147
- return;
148
- }
149
- pre.append(copyHtml);
150
- });
151
- var clipboard = new window.ClipboardJS('.copy-btn', {
152
- target: function(trigger) {
153
- return trigger.previousElementSibling;
85
+ jQuery(selector || `.markdown-body > p > img, .markdown-body > figure > img,
86
+ .markdown-body > p > a.fancybox, .markdown-body > figure > a.fancybox`).each(function() {
87
+ var $target = jQuery(this);
88
+ var $figcaption = $target.next('figcaption');
89
+ if ($figcaption.length !== 0) {
90
+ $figcaption.addClass('image-caption');
91
+ } else {
92
+ var imageTitle = $target.attr('title') || $target.attr('alt');
93
+ if (imageTitle) {
94
+ $target.after(`<figcaption aria-hidden="true" class="image-caption">${imageTitle}</figcaption>`);
95
+ }
154
96
  }
155
97
  });
156
- jQuery('.copy-btn').addClass(getBgClass(blockElement));
157
- clipboard.on('success', function(e) {
158
- e.clearSelection();
159
- var tmp = e.trigger.outerHTML;
160
- e.trigger.innerHTML = 'Success';
161
- setTimeout(function() {
162
- e.trigger.outerHTML = tmp;
163
- }, 2000);
164
- });
165
98
  }
166
-
167
99
  };
@@ -26,7 +26,7 @@ Fluid.utils = {
26
26
  },
27
27
 
28
28
  elementVisible: function(element, offsetFactor) {
29
- offsetFactor = (offsetFactor && offsetFactor >= 0) ? offsetFactor : 0;
29
+ offsetFactor = offsetFactor && offsetFactor >= 0 ? offsetFactor : 0;
30
30
  var rect = element.getBoundingClientRect();
31
31
  var height = window.innerHeight || document.documentElement.clientHeight;
32
32
  var top = rect.top;
@@ -36,13 +36,13 @@ Fluid.utils = {
36
36
 
37
37
  waitElementVisible: function(selectorOrElement, callback, offsetFactor) {
38
38
  var runningOnBrowser = typeof window !== 'undefined';
39
- var isBot = (runningOnBrowser && !('onscroll' in window)) ||
40
- (typeof navigator !== 'undefined' && /(gle|ing|ro|msn)bot|crawl|spider|yand|duckgo/i.test(navigator.userAgent));
39
+ var isBot = (runningOnBrowser && !('onscroll' in window))
40
+ || (typeof navigator !== 'undefined' && /(gle|ing|ro|msn)bot|crawl|spider|yand|duckgo/i.test(navigator.userAgent));
41
41
  if (!runningOnBrowser || isBot) {
42
42
  return;
43
43
  }
44
44
 
45
- offsetFactor = (offsetFactor && offsetFactor >= 0) ? offsetFactor : 0;
45
+ offsetFactor = offsetFactor && offsetFactor >= 0 ? offsetFactor : 0;
46
46
 
47
47
  function waitInViewport(element) {
48
48
  if (Fluid.utils.elementVisible(element, offsetFactor)) {
@@ -81,8 +81,8 @@ Fluid.utils = {
81
81
 
82
82
  waitElementLoaded: function(selector, callback) {
83
83
  var runningOnBrowser = typeof window !== 'undefined';
84
- var isBot = (runningOnBrowser && !('onscroll' in window)) ||
85
- (typeof navigator !== 'undefined' && /(gle|ing|ro|msn)bot|crawl|spider|yand|duckgo/i.test(navigator.userAgent));
84
+ var isBot = (runningOnBrowser && !('onscroll' in window))
85
+ || (typeof navigator !== 'undefined' && /(gle|ing|ro|msn)bot|crawl|spider|yand|duckgo/i.test(navigator.userAgent));
86
86
  if (!runningOnBrowser || isBot) {
87
87
  return;
88
88
  }
@@ -130,10 +130,9 @@ Fluid.utils = {
130
130
  s.onload = onload;
131
131
  }
132
132
  }
133
- var e = document.getElementsByTagName('script')[0]
134
- || document.getElementsByTagName('head')[0]
135
- || document.head || document.documentElement;
136
- e.parentNode.insertBefore(s, e);
133
+ var ss = document.getElementsByTagName('script');
134
+ var e = ss.length > 0 ? ss[ss.length - 1] : document.head || document.documentElement;
135
+ e.parentNode.insertBefore(s, e.nextSibling);
137
136
  },
138
137
 
139
138
  createCssLink: function(url) {
@@ -147,17 +146,34 @@ Fluid.utils = {
147
146
  e.parentNode.insertBefore(l, e);
148
147
  },
149
148
 
150
- loadComments: function(selectors, loadFunc) {
149
+ loadComments: function(selector, loadFunc) {
151
150
  var ele = document.querySelector('#comments[lazyload]');
152
151
  if (ele) {
153
152
  var callback = function() {
154
153
  loadFunc();
155
154
  ele.removeAttribute('lazyload');
156
155
  };
157
- Fluid.utils.waitElementVisible(selectors, callback, CONFIG.lazyload.offset_factor);
156
+ Fluid.utils.waitElementVisible(selector, callback, CONFIG.lazyload.offset_factor);
158
157
  } else {
159
158
  loadFunc();
160
159
  }
160
+ },
161
+
162
+ getBackgroundLightness(selectorOrElement) {
163
+ var ele = selectorOrElement;
164
+ if (typeof selectorOrElement === 'string') {
165
+ ele = document.querySelector(selectorOrElement);
166
+ }
167
+ var view = ele.ownerDocument.defaultView;
168
+ if (!view) {
169
+ view = window;
170
+ }
171
+ var rgbArr = view.getComputedStyle(ele).backgroundColor.replace(/rgba*\(/, '').replace(')', '').split(/,\s*/);
172
+ if (rgbArr.length < 3) {
173
+ return 0;
174
+ }
175
+ var colorCast = (0.213 * rgbArr[0]) + (0.715 * rgbArr[1]) + (0.072 * rgbArr[2]);
176
+ return colorCast === 0 || colorCast > 255 / 2 ? 1 : -1;
161
177
  }
162
178
 
163
179
  };
package/.editorconfig DELETED
@@ -1,13 +0,0 @@
1
- # editorconfig.org
2
- root = true
3
-
4
- [*]
5
- indent_style = space
6
- indent_size = 2
7
- end_of_line = lf
8
- charset = utf-8
9
- trim_trailing_whitespace = true
10
- insert_final_newline = true
11
-
12
- [*.md]
13
- trim_trailing_whitespace = false
package/.eslintrc DELETED
@@ -1,224 +0,0 @@
1
- {
2
- "extends": [
3
- "eslint:recommended"
4
- ],
5
- "parserOptions": {
6
- "ecmaVersion": 2018
7
- },
8
- "rules": {
9
- // Override recomennded
10
- "no-console": [
11
- 2,
12
- {
13
- "allow": [
14
- "warn"
15
- ]
16
- }
17
- ],
18
- "no-empty": [
19
- 2,
20
- {
21
- "allowEmptyCatch": true
22
- }
23
- ],
24
- "no-unused-vars": [
25
- 2,
26
- {
27
- "args": "none"
28
- }
29
- ],
30
- // Possible Errors
31
- "no-extra-parens": [
32
- 2,
33
- "all",
34
- {
35
- "conditionalAssign": false,
36
- "returnAssign": false,
37
- "nestedBinaryExpressions": false,
38
- "enforceForArrowConditionals": false
39
- }
40
- ],
41
- // Best Practices
42
- "array-callback-return": 2,
43
- "block-scoped-var": 2,
44
- "curly": [
45
- 2,
46
- "multi-line"
47
- ],
48
- "dot-location": [
49
- 2,
50
- "property"
51
- ],
52
- "dot-notation": 2,
53
- "eqeqeq": [
54
- 2,
55
- "smart"
56
- ],
57
- "no-else-return": 2,
58
- "no-eval": 2,
59
- "no-extend-native": 2,
60
- "no-extra-bind": 2,
61
- "no-extra-label": 2,
62
- "no-implicit-globals": 2,
63
- "no-implied-eval": 2,
64
- "no-lone-blocks": 2,
65
- "no-loop-func": 2,
66
- "no-multi-spaces": [
67
- 2,
68
- {
69
- "exceptions": {
70
- "ImportDeclaration": true,
71
- "VariableDeclarator": true,
72
- "FunctionDeclarator": true,
73
- "AssignmentExpression": true,
74
- "CallExpression": true
75
- }
76
- }
77
- ],
78
- "no-multi-str": 2,
79
- "no-new": 2,
80
- "no-new-func": 2,
81
- "no-new-wrappers": 2,
82
- "no-proto": 2,
83
- "no-return-assign": 2,
84
- "no-self-compare": 2,
85
- "no-sequences": 2,
86
- "no-throw-literal": 2,
87
- "no-unused-expressions": [
88
- 2,
89
- {
90
- "allowShortCircuit": true,
91
- "allowTernary": true
92
- }
93
- ],
94
- "no-useless-call": 2,
95
- "no-useless-concat": 2,
96
- "no-useless-return": 2,
97
- "no-void": 2,
98
- "no-with": 2,
99
- "prefer-promise-reject-errors": 2,
100
- "radix": 2,
101
- "wrap-iife": [
102
- 2,
103
- "inside"
104
- ],
105
- "yoda": 2,
106
- // Variables
107
- "no-label-var": 2,
108
- "no-shadow-restricted-names": 2,
109
- "no-undef-init": 2,
110
- // Node.js and CommonJS
111
- "handle-callback-err": 2,
112
- "no-path-concat": 2,
113
- // Stylistic Issues
114
- "array-bracket-spacing": 2,
115
- "block-spacing": 2,
116
- "brace-style": [
117
- 2,
118
- "1tbs",
119
- {
120
- "allowSingleLine": true
121
- }
122
- ],
123
- "comma-dangle": 2,
124
- "comma-spacing": 2,
125
- "comma-style": 2,
126
- "computed-property-spacing": 2,
127
- "eol-last": 2,
128
- "func-call-spacing": 2,
129
- "indent": [
130
- 2,
131
- 2,
132
- {
133
- "SwitchCase": 1,
134
- "VariableDeclarator": {
135
- "var": 2,
136
- "let": 2,
137
- "const": 3
138
- }
139
- }
140
- ],
141
- "key-spacing": [
142
- 2,
143
- {
144
- "align": "colon",
145
- "beforeColon": false
146
- }
147
- ],
148
- "keyword-spacing": 2,
149
- "linebreak-style": ["off", "window"],
150
- "lines-around-comment": 2,
151
- "new-cap": [
152
- 2,
153
- {
154
- "capIsNew": false
155
- }
156
- ],
157
- "new-parens": 2,
158
- "no-array-constructor": 2,
159
- "no-mixed-operators": 2,
160
- "no-multiple-empty-lines": 2,
161
- "no-nested-ternary": 2,
162
- "no-new-object": 2,
163
- "no-trailing-spaces": 2,
164
- "no-unneeded-ternary": 2,
165
- "no-whitespace-before-property": 2,
166
- "object-curly-spacing": [
167
- 2,
168
- "always"
169
- ],
170
- "one-var": [
171
- 2,
172
- {
173
- "uninitialized": "always",
174
- "initialized": "never"
175
- }
176
- ],
177
- "operator-linebreak": [
178
- 2,
179
- "before"
180
- ],
181
- "quotes": [
182
- 2,
183
- "single"
184
- ],
185
- "semi": 2,
186
- "semi-spacing": 2,
187
- "space-before-blocks": 2,
188
- "space-before-function-paren": [
189
- 2,
190
- "never"
191
- ],
192
- "space-in-parens": 2,
193
- "space-infix-ops": 2,
194
- "space-unary-ops": 2,
195
- "template-tag-spacing": 2,
196
- "unicode-bom": 2,
197
- // ECMAScript 6
198
- "arrow-spacing": 2,
199
- "generator-star-spacing": [
200
- 2,
201
- "after"
202
- ],
203
- "no-confusing-arrow": [
204
- 2,
205
- {
206
- "allowParens": true
207
- }
208
- ],
209
- "no-duplicate-imports": 2,
210
- "no-useless-computed-key": 2,
211
- "no-useless-constructor": 2,
212
- "no-useless-rename": 2,
213
- "rest-spread-spacing": 2,
214
- "template-curly-spacing": 2,
215
- "yield-star-spacing": 2
216
- },
217
- "env": {
218
- "browser": true,
219
- "jquery": true,
220
- "mocha": true,
221
- "node": true,
222
- "es6": true
223
- }
224
- }
package/.gitattributes DELETED
@@ -1 +0,0 @@
1
- source/lib/* linguist-vendored