評論增加lazyload

 頭像/打賞圖片 增加lazyload
 調整移動端 ol ul 的邊距 #267
🐛 修復Valine 的requiredFields設置為空 無效的bugs
This commit is contained in:
Jerry
2020-07-26 15:33:47 +08:00
parent d5cf43a6b4
commit d2943bbbb1
26 changed files with 176 additions and 161 deletions

View File

@@ -101,11 +101,11 @@ default_top_img: https://i.loli.net/2020/05/01/IuWi8QbHvzjlOPw.jpg
archive_img: archive_img:
# the banner image of tag page # the banner image of tag page
# tag page, look like https://xxxxxxxxx.com/tags/butterfly # note: tag page, not tags page (子標籤頁面的 top_img)
tag_img: tag_img:
# the banner image of category page # the banner image of category page
# category page, look like https://xxxxxxxxx.com/categories/butterfly # note: category page, not categories page (子分類頁面的 top_img)
category_img: category_img:
# If you are using hexo-douban, you can configure it (如果你有使用 hexo-douban,可配置這個) # If you are using hexo-douban, you can configure it (如果你有使用 hexo-douban,可配置這個)
@@ -251,7 +251,9 @@ comments:
# - Valine # - Valine
# - Disqus # - Disqus
text: true # Display the comment name next to the button text: true # Display the comment name next to the button
load_begin: false # The second comment system will auto load when visiting the website # lazyload: The comment system will be load when comment element enters the browser's viewport.
# If you set it to false, the comment count will be invalid
lazyload: false
count: false # Display comment count in top_img count: false # Display comment count in top_img
# disqus # disqus
@@ -368,14 +370,13 @@ crisp:
# Footer Settings # Footer Settings
# -------------------------------------- # --------------------------------------
footer: footer:
owner: # 顯示站長信息 owner:
enable: true enable: true
since: 2020 since: 2020
custom_text: Hi, welcome to my blog! # 頁腳自定義文本 custom_text:
copyright: true # 顯示框架及主題作者信息 copyright: true # Copyright of theme and framework
ICP: # 備案信息 ICP: # Chinese ICP License
enable: false enable: false
url: url:
text: text:
@@ -456,7 +457,7 @@ yandex_site_verification:
# The top_img settings of home page # The top_img settings of home page
# default: top img - full screen, site info - middle (默認top_img全屏site_info在中間) # default: top img - full screen, site info - middle (默認top_img全屏site_info在中間)
# The positon of site info, eg: 300px/300em/300rem/10% (主頁標題距離頂部距離) # The position of site info, eg: 300px/300em/300rem/10% (主頁標題距離頂部距離)
index_site_info_top: index_site_info_top:
# The height of top_img, eg: 300px/300em/300rem (主頁top_img高度) # The height of top_img, eg: 300px/300em/300rem (主頁top_img高度)
index_top_img_height: index_top_img_height:
@@ -553,12 +554,12 @@ font:
# 左上角網站名字 主頁居中網站名字 # 左上角網站名字 主頁居中網站名字
blog_title_font: blog_title_font:
font_link: https://fonts.googleapis.com/css?family=Titillium+Web&display=swap font_link: https://fonts.googleapis.com/css?family=Titillium+Web&display=swap
font-family: Titillium Web, 'PingFang SC', 'Hiragino Sans GB', Microsoft YaHei', sans-serif font-family: Titillium Web, 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif
# The setting of divider icon (水平分隔線圖標設置) # The setting of divider icon (水平分隔線圖標設置)
hr_icon: hr_icon:
enable: true enable: true
icon: # the unicode value of Font Awesome icon icon: # the unicode value of Font Awesome icon, such as '\3423'
icon-top: icon-top:
# the subtitle on homepage (主頁subtitle) # the subtitle on homepage (主頁subtitle)
@@ -707,6 +708,8 @@ note:
# other # other
# -------------------------------------- # --------------------------------------
# Pjax [Beta]
# It may contain bugs and unstable, give feedback when you find the bugs.
# https://github.com/MoOx/pjax # https://github.com/MoOx/pjax
pjax: false pjax: false

View File

@@ -43,10 +43,10 @@ div
//- 鼠標特效 //- 鼠標特效
if theme.click_heart if theme.click_heart
script(src=url_for(theme.CDN.click_heart)) script(src=url_for(theme.CDN.click_heart) async)
if theme.ClickShowText && theme.ClickShowText.enable if theme.ClickShowText && theme.ClickShowText.enable
script(src=url_for(theme.CDN.ClickShowText)) script(src=url_for(theme.CDN.ClickShowText) async)
if theme.pangu && theme.pangu.enable if theme.pangu && theme.pangu.enable
include ./third-party/pangu.pug include ./third-party/pangu.pug
@@ -76,11 +76,6 @@ div
if theme.busuanzi.site_uv || theme.busuanzi.site_pv || theme.busuanzi.page_pv if theme.busuanzi.site_uv || theme.busuanzi.site_pv || theme.busuanzi.page_pv
script(async src=url_for(theme.CDN.busuanzi)) script(async src=url_for(theme.CDN.busuanzi))
if theme.pjax && theme.comments && theme.comments.use
!=partial('includes/comments/js-load-all', {}, {cache:theme.fragment_cache})
else if commentsJsLoad
!=partial('includes/comments/js-load-all', {}, {cache:theme.fragment_cache})
if theme.aplayerInject && !config.aplayer.asset_inject if theme.aplayerInject && !config.aplayer.asset_inject
if theme.pjax if theme.pjax
include ./head/aplayer.pug include ./head/aplayer.pug

View File

@@ -13,30 +13,27 @@ script.
}) })
} }
if (window.DISQUS) { if (window.DISQUS) disqusReset()
disqusReset() else {
} else {
(function() { (function() {
var d = document, s = d.createElement('script') var d = document, s = d.createElement('script');
s.src = 'https://!{theme.disqus.shortname}.disqus.com/embed.js' s.src = 'https://!{theme.disqus.shortname}.disqus.com/embed.js';
s.setAttribute('data-timestamp', +new Date())
s.setAttribute('data-timestamp', +new Date()); s.setAttribute('data-timestamp', +new Date());
(d.head || d.body).appendChild(s); (d.head || d.body).appendChild(s);
})(); })();
} }
} }
if ('!{defaultComment}' === 'Disqus' || !{theme.comments.load_begin}) { if ('!{theme.comments.use[0]}' === 'Disqus' || !!{theme.comments.lazyload}) {
loadDisqus() if (!{theme.comments.lazyload}) loadComment(document.getElementById('disqus_thread'), loadDisqus)
} else loadDisqus()
else { } else {
function loadOtherComment () { function loadOtherComment () {
loadDisqus() loadDisqus()
} }
} }
if is_post() && !theme.comments.lazyload && theme.comments.count && theme.comments.use[0] === 'Disqus'
if is_post() && theme.comments.count && defaultComment === 'Disqus'
script. script.
if (window.DISQUSWIDGETS === undefined) { if (window.DISQUSWIDGETS === undefined) {
var d = document, s = d.createElement('script'); var d = document, s = d.createElement('script');

View File

@@ -33,8 +33,9 @@ script.
} }
} }
if ('!{defaultComment}' === 'Disqusjs' || !{theme.comments.load_begin}) { if ('!{theme.comments.use[0]}' === 'Disqusjs' || !!{theme.comments.lazyload}) {
loadDisqusjs() if (!{theme.comments.lazyload}) loadComment(document.getElementById('disqus_thread'), loadDisqusjs)
else loadDisqusjs()
} }
else { else {
function loadOtherComment () { function loadOtherComment () {
@@ -43,7 +44,7 @@ script.
} }
if is_post() && theme.comments.count && defaultComment === 'Disqusjs' if is_post() && !theme.comments.lazyload && theme.comments.count && theme.comments.use[0] === 'Disqusjs'
script. script.
if (window.DISQUSWIDGETS === undefined) { if (window.DISQUSWIDGETS === undefined) {
var d = document, s = d.createElement('script'); var d = document, s = d.createElement('script');

View File

@@ -15,13 +15,10 @@ script.
} }
} }
if ('!{defaultComment}' === 'Facebook Comments' || !{theme.comments.load_begin}) { if ('!{theme.comments.use[0]}' === 'Facebook Comments' || !!{theme.comments.lazyload}) {
document.getElementsByClassName('fb-comments').length && loadFBComment() if (!{theme.comments.lazyload}) loadComment(document.querySelector('#post-comment .fb-comments'), loadFBComment)
!{theme.pjax} && document.addEventListener('pjax:complete', () => else loadFBComment()
document.getElementsByClassName('fb-comments').length && loadFBComment() } else {
)
}
else {
function loadOtherComment () { function loadOtherComment () {
loadFBComment() loadFBComment()
} }

View File

@@ -33,15 +33,16 @@ script.
} }
function commentCount(n){ function commentCount(n){
if (document.querySelector('#post-meta .gitalk-comment-count')) { let isCommentCount = document.querySelector('#post-meta .gitalk-comment-count')
document.querySelector('#post-meta .gitalk-comment-count').innerHTML= n if (isCommentCount) {
isCommentCount.innerHTML= n
} }
} }
if ('!{defaultComment}' === 'Gitalk' || !{theme.comments.load_begin}) { if ('!{theme.comments.use[0]}' === 'Gitalk' || !!{theme.comments.lazyload}) {
loadGitalk() if (!{theme.comments.lazyload}) loadComment(document.getElementById('gitalk-container'), loadGitalk)
} else loadGitalk()
else { } else {
function loadOtherComment () { function loadOtherComment () {
loadGitalk() loadGitalk()
} }

View File

@@ -1,7 +0,0 @@
- let defaultComment = theme.comments.use[0]
each name in theme.comments.use
case name
when 'Valine'
include ./valine.pug
when 'Facebook Comments'
include ./facebook_comments.pug

View File

@@ -1,13 +1,16 @@
- let defaultComment = theme.comments.use[0]
each name in theme.comments.use each name in theme.comments.use
case name case name
when 'Valine'
!=partial('includes/comments/valine', {}, {cache:theme.fragment_cache})
when 'Disqus' when 'Disqus'
include ./disqus.pug include ./disqus.pug
when 'Disqusjs' when 'Disqusjs'
include ./disqusjs.pug include ./disqusjs.pug
when 'Livere' when 'Livere'
include ./livere.pug !=partial('includes/comments/livere', {}, {cache:theme.fragment_cache})
when 'Gitalk' when 'Gitalk'
include ./gitalk.pug include ./gitalk.pug
when 'Utterances' when 'Utterances'
include ./utterances.pug !=partial('includes/comments/utterances', {}, {cache:theme.fragment_cache})
when 'Facebook Comments'
!=partial('includes/comments/facebook_comments', {}, {cache:theme.fragment_cache})

View File

@@ -10,8 +10,9 @@ script.
})(document, 'script'); })(document, 'script');
} }
if ('!{defaultComment}' === 'Livere' || !{theme.comments.load_begin}) { if ('!{theme.comments.use[0]}' === 'Livere' || !!{theme.comments.lazyload}) {
loadLivere() if (!{theme.comments.lazyload}) loadComment(document.getElementById('lv-container'), loadLivere)
else loadLivere()
} }
else { else {
function loadOtherComment () { function loadOtherComment () {

View File

@@ -1,36 +1,34 @@
script. script.
if (document.getElementById('utterances-wrap')) { function loadUtterances () {
function loadUtterances () { let ele = document.createElement('script')
let ele = document.createElement('script') ele.setAttribute('id', 'utterances_comment')
ele.setAttribute('id', 'utterances_comment') ele.setAttribute('src', '!{url_for(theme.CDN.utterances)}')
ele.setAttribute('src', '!{url_for(theme.CDN.utterances)}') ele.setAttribute('repo', '!{theme.utterances.repo}')
ele.setAttribute('repo', '!{theme.utterances.repo}') ele.setAttribute('issue-term', '!{theme.utterances.issue_term}')
ele.setAttribute('issue-term', '!{theme.utterances.issue_term}') let nowTheme = document.documentElement.getAttribute('data-theme') === 'dark' ? '#{theme.utterances.dark_theme}' : '#{theme.utterances.light_theme}'
let nowTheme = document.documentElement.getAttribute('data-theme') === 'dark' ? '#{theme.utterances.dark_theme}' : '#{theme.utterances.light_theme}' ele.setAttribute('theme', nowTheme)
ele.setAttribute('theme', nowTheme) ele.setAttribute('crossorigin', 'anonymous')
ele.setAttribute('crossorigin', 'anonymous') ele.setAttribute('async', 'true')
ele.setAttribute('async', 'true') document.getElementById('utterances-wrap').insertAdjacentElement('afterbegin',ele)
document.getElementById('utterances-wrap').insertAdjacentElement('afterbegin',ele) }
}
function utterancesTheme () { function utterancesTheme () {
if (document.querySelector('.utterances-frame')) { if (document.querySelector('.utterances-frame')) {
const theme = document.documentElement.getAttribute('data-theme') === 'dark' ? '#{theme.utterances.dark_theme}' : '#{theme.utterances.light_theme}' const theme = document.documentElement.getAttribute('data-theme') === 'dark' ? '#{theme.utterances.dark_theme}' : '#{theme.utterances.light_theme}'
const message = { const message = {
type: 'set-theme', type: 'set-theme',
theme: theme theme: theme
}; };
const iframe = document.querySelector('.utterances-frame'); const iframe = document.querySelector('.utterances-frame');
iframe.contentWindow.postMessage(message, 'https://utteranc.es'); iframe.contentWindow.postMessage(message, 'https://utteranc.es');
} }
} }
if ('!{defaultComment}' === 'Utterances' || !{theme.comments.load_begin}) { if ('!{theme.comments.use[0]}' === 'Utterances' || !!{theme.comments.lazyload}) {
loadUtterances() if (!{theme.comments.lazyload}) loadComment(document.getElementById('utterances-wrap'), loadUtterances)
} else loadUtterances()
else { } else {
function loadOtherComment () { function loadOtherComment () {
loadUtterances() loadUtterances()
}
} }
} }

View File

@@ -4,18 +4,6 @@ if site.data.valine
script. script.
function loadValine () { function loadValine () {
function requestSetting (from, set) {
var from = from
var setting = set.split(',').filter(function(item){
return from.indexOf(item) > -1
});
setting = setting.length == 0 ? from :setting;
return setting
}
var guestInfo = requestSetting(['nick','mail','link'],'#{ theme.valine.guest_info }')
var requiredFields = requestSetting(['nick','mail'],'#{ theme.valine.requiredFields }')
function initValine () { function initValine () {
window.valine = new Valine({ window.valine = new Valine({
el: '#vcomment', el: '#vcomment',
@@ -23,7 +11,7 @@ script.
appKey: '#{theme.valine.appKey}', appKey: '#{theme.valine.appKey}',
placeholder: '#{theme.valine.placeholder}', placeholder: '#{theme.valine.placeholder}',
avatar: '#{theme.valine.avatar}', avatar: '#{theme.valine.avatar}',
meta: guestInfo, meta: '#{theme.valine.guest_info }'.split(','),
pageSize: '#{theme.valine.pageSize}', pageSize: '#{theme.valine.pageSize}',
lang: '#{theme.valine.lang}', lang: '#{theme.valine.lang}',
recordIP: #{theme.valine.recordIP}, recordIP: #{theme.valine.recordIP},
@@ -31,22 +19,22 @@ script.
emojiCDN: '#{theme.valine.emojiCDN}', emojiCDN: '#{theme.valine.emojiCDN}',
emojiMaps: !{emojiMaps}, emojiMaps: !{emojiMaps},
enableQQ: #{theme.valine.enableQQ}, enableQQ: #{theme.valine.enableQQ},
requiredFields: requiredFields,
path: window.location.pathname, path: window.location.pathname,
}); });
if ('#{theme.valine.requiredFields}') { valine.config.requiredFields= '#{theme.valine.requiredFields}'.split(',') }
} }
if (typeof Valine === 'function') initValine() if (typeof Valine === 'function') initValine()
else $.getScript('!{url_for(theme.CDN.valine)}', initValine) else $.getScript('!{url_for(theme.CDN.valine)}', initValine)
} }
if ('!{defaultComment}' === 'Valine' || !{theme.comments.load_begin}) { if ('!{theme.comments.use[0]}' === 'Valine' || !!{theme.comments.lazyload}) {
document.querySelector('#vcomment') && loadValine() if (!{theme.comments.lazyload}) loadComment(document.querySelector('#vcomment'),loadValine)
!{theme.pjax} && document.addEventListener('pjax:complete', () => document.querySelector('#vcomment') && loadValine()) else setTimeout(() => loadValine(), 0)
} } else {
else {
function loadOtherComment () { function loadOtherComment () {
loadValine() loadValine()
} }
} }

View File

@@ -1,5 +1,5 @@
if (theme.google_adsense && theme.google_adsense.enable) if (theme.google_adsense && theme.google_adsense.enable)
script(async src=theme.google_adsense.js data-pjax) script(async src=theme.google_adsense.js)
if theme.google_adsense.auto_ads if theme.google_adsense.auto_ads
script. script.

View File

@@ -56,7 +56,7 @@
span.post-meta-label=_p('post.page_pv') + ':' span.post-meta-label=_p('post.page_pv') + ':'
span#busuanzi_value_page_pv span#busuanzi_value_page_pv
if page.comments !== false && theme.comments.use && theme.comments.count if !theme.comments.lazyload && page.comments !== false && theme.comments.use && theme.comments.count
- var whichCount = theme.comments.use[0] - var whichCount = theme.comments.use[0]
if whichCount !== 'Livere' && whichCount !== 'Utterances' if whichCount !== 'Livere' && whichCount !== 'Utterances'
span.post-meta-separator | span.post-meta-separator |

View File

@@ -1,6 +1,9 @@
#mobile-sidebar-menus #mobile-sidebar-menus
.mobile_author_icon .mobile_author_icon
img.avatar-img(src=url_for(theme.avatar.img) onerror=`onerror=null;src='${theme.error_img.flink}'` alt="avatar") if theme.lazyload.enable
img.avatar-img(data-lazy-src=url_for(theme.avatar.img) onerror=`onerror=null;src='${theme.error_img.flink}'` alt="avatar")
else
img.avatar-img(src=url_for(theme.avatar.img) onerror=`onerror=null;src='${theme.error_img.flink}'` alt="avatar")
.mobile_post_data .mobile_post_data
if site.posts.length if site.posts.length
.mobile_data_item.is-center .mobile_data_item.is-center

View File

@@ -7,6 +7,9 @@
each item in theme.reward.QR_code each item in theme.reward.QR_code
- var clickTo = (item.itemlist||item).link ? (item.itemlist||item).link : (item.itemlist||item).img - var clickTo = (item.itemlist||item).link ? (item.itemlist||item).link : (item.itemlist||item).img
li.reward-item li.reward-item
img.post-qr-code__img(src=url_for((item.itemlist||item).img) alt=(item.itemlist||item).text onclick=`window.open('${url_for(clickTo)}')`) if theme.lazyload.enable
.post-qr-code__desc=(item.itemlist||item).text img.post-qr-code-img(data-lazy-src=url_for((item.itemlist||item).img) alt=(item.itemlist||item).text onclick=`window.open('${url_for(clickTo)}')`)
else
img.post-qr-code-img(src=url_for((item.itemlist||item).img) alt=(item.itemlist||item).text onclick=`window.open('${url_for(clickTo)}')`)
.post-qr-code-desc=(item.itemlist||item).text

View File

@@ -1,4 +1,4 @@
if (theme.sharejs && theme.sharejs.enable) if (theme.sharejs && theme.sharejs.enable)
.social-share(data-image=url_for(page.cover|| theme.avatar.img) data-sites= theme.sharejs.sites) .social-share(data-image=url_for(page.cover|| theme.avatar.img) data-sites= theme.sharejs.sites)
link(rel="stylesheet" href=url_for(theme.CDN.sharejs_css)) link(rel="stylesheet" href=url_for(theme.CDN.sharejs_css))
script(src=url_for(theme.CDN.sharejs)) script(src=url_for(theme.CDN.sharejs) defer)

View File

@@ -1 +1 @@
script#canvas_nest(color=theme.canvas_nest.color opacity=theme.canvas_nest.opacity zIndex=theme.canvas_nest.zIndex count=theme.canvas_nest.count mobile=`${theme.canvas_nest.mobile}` src=url_for(theme.CDN.canvas_nest)) script#canvas_nest(defer color=theme.canvas_nest.color opacity=theme.canvas_nest.opacity zIndex=theme.canvas_nest.zIndex count=theme.canvas_nest.count mobile=`${theme.canvas_nest.mobile}` src=url_for(theme.CDN.canvas_nest))

View File

@@ -1 +1 @@
script(id="ribbon_piao" mobile=`${theme.canvas_ribbon_piao.mobile}` src=url_for(theme.CDN.canvas_ribbon_piao)) script(defer id="ribbon_piao" mobile=`${theme.canvas_ribbon_piao.mobile}` src=url_for(theme.CDN.canvas_ribbon_piao))

View File

@@ -1,7 +1,10 @@
.card-widget.card-info .card-widget.card-info
.card-content .card-content
.card-info-avatar.is-center .card-info-avatar.is-center
img.avatar-img(src=url_for(theme.avatar.img) onerror=`this.onerror=null;this.src='` + url_for(theme.error_img.flink) + `'` alt="avatar") if theme.lazyload.enable
img.avatar-img(data-lazy-src=url_for(theme.avatar.img) onerror=`this.onerror=null;this.src='` + url_for(theme.error_img.flink) + `'` alt="avatar")
else
img.avatar-img(src=url_for(theme.avatar.img) onerror=`this.onerror=null;this.src='` + url_for(theme.error_img.flink) + `'` alt="avatar")
.author-info__name= config.author .author-info__name= config.author
.author-info__description!= theme.aside.card_author.description || config.description .author-info__description!= theme.aside.card_author.description || config.description

View File

@@ -244,6 +244,14 @@ if hexo-config('avatar.effect') == true
.sidebar-toc__content .sidebar-toc__content
animation: tocsidebarRtoL .7s animation: tocsidebarRtoL .7s
#mobile-sidebar-menus
&.open
transform: translate3d(-100%, 0px, 0px)
for i in 1 2 3 4
> :nth-child({i})
animation: sidebarItem (i / 5)s
@keyframes scroll-down-effect @keyframes scroll-down-effect
0% 0%
top: 0 top: 0

View File

@@ -184,7 +184,7 @@
.card-categories .card-categories
.card-category-list .card-category-list
&.child &.child
padding: 0 0 0 1rem padding: 0 0 0 .8rem
> .parent > .parent
.card-category-list .card-category-list

View File

@@ -1,17 +1,17 @@
.category-content .category-content
ul ul
margin-top: .4rem margin-top: .4rem
padding: 0 0 0 .8rem padding: 0 0 0 1rem
list-style: none list-style: none
counter-reset: li counter-reset: li
ul ul
padding-left: .5rem padding-left: .2rem
li li
position: relative position: relative
margin: .3rem 0 margin: .3rem 0
padding: .1rem .5rem .1rem 1.5rem !important padding: .1rem .2rem .1rem 1rem
&:before &:before
position: absolute position: absolute
@@ -20,7 +20,6 @@
transition: all .3s ease-out transition: all .3s ease-out
$w = .3rem $w = .3rem
top: 10px top: 10px
margin-left: .45rem
width: w = $w width: w = $w
height: h = w height: h = w
border: .5 * w solid $light-blue border: .5 * w solid $light-blue
@@ -28,3 +27,7 @@
background: transparent background: transparent
content: '' content: ''
line-height: h line-height: h
&:hover
&:before
border-color: $pseudo-hover

View File

@@ -58,18 +58,24 @@ beautify()
list-style: none list-style: none
counter-reset: li counter-reset: li
@media screen and (max-width: $sm)
padding: 0 0 0 .4rem
p p
margin: 0 0 .5rem margin: 0 0 .5rem
ol, ol,
ul ul
padding-left: .5rem padding-left: .6rem
@media screen and (max-width: $sm)
padding-left: 0.2rem
li li
&:not(.tab) &:not(.tab)
position: relative position: relative
margin: .2rem 0 margin: .2rem 0
padding: .1rem .5rem .1rem 1.5rem
&:hover &:hover
&:before &:before
@@ -86,9 +92,12 @@ beautify()
ol ol
> li > li
&:not(.tab)
padding: .1rem .2rem .1rem 1.4rem
&:before &:before
margin-top: .2rem margin-top: .3rem
width: w = 1.2rem width: w = 1rem
height: h = w height: h = w
border-radius: .5 * w border-radius: .5 * w
content: counter(li) content: counter(li)
@@ -99,6 +108,8 @@ beautify()
ul ul
> li:not(.tab) > li:not(.tab)
padding: .1rem .2rem .1rem 1rem
&:hover &:hover
&:before &:before
border-color: $pseudo-hover border-color: $pseudo-hover
@@ -106,7 +117,6 @@ beautify()
&:before &:before
$w = .3rem $w = .3rem
top: 10px top: 10px
margin-left: .45rem
width: w = $w width: w = $w
height: h = w height: h = w
border: .5 * w solid $light-blue border: .5 * w solid $light-blue

View File

@@ -65,7 +65,7 @@
width: 130px width: 130px
height: 130px height: 130px
.post-qr-code__desc .post-qr-code-desc
padding-top: .4rem padding-top: .4rem
width: 130px width: 130px
color: $reward-pop-up-color color: $reward-pop-up-color

View File

@@ -37,7 +37,7 @@ const initAdjust = () => {
/** /**
* 進入post頁sidebar處理 * 進入post頁sidebar處理
*/ */
const sidebarAutoOpen = () => { const OpenSidebarAuto = () => {
if (window.innerWidth > 1024 && $('#toggle-sidebar').hasClass('on')) { if (window.innerWidth > 1024 && $('#toggle-sidebar').hasClass('on')) {
setTimeout(function () { setTimeout(function () {
openSidebar() openSidebar()
@@ -87,7 +87,7 @@ const openSidebar = () => {
}) })
} }
const toggleSidebarFn = function () { const toggleSidebar = function () {
$('#toggle-sidebar').on('click', function () { $('#toggle-sidebar').on('click', function () {
const isOpen = $(this).hasClass('on') const isOpen = $(this).hasClass('on')
isOpen ? $(this).removeClass('on') : $(this).addClass('on') isOpen ? $(this).removeClass('on') : $(this).addClass('on')
@@ -119,12 +119,7 @@ const sidebarFn = () => {
if (name === 'menu') { if (name === 'menu') {
$toggleMenu.removeClass('close').addClass('open') $toggleMenu.removeClass('close').addClass('open')
$mobileSidebarMenus.css('transform', 'translate3d(-100%,0,0)') $mobileSidebarMenus.addClass('open')
const $mobileSidebarMenusChild = $mobileSidebarMenus.children()
for (let i = 0; i <= $mobileSidebarMenusChild.length; i++) {
const duration = i / 5 + 0.2
$mobileSidebarMenusChild.eq(i).css('animation', 'sidebarItem ' + duration + 's')
}
} }
if (name === 'toc') { if (name === 'toc') {
@@ -139,8 +134,7 @@ const sidebarFn = () => {
if (name === 'menu') { if (name === 'menu') {
$toggleMenu.removeClass('open').addClass('close') $toggleMenu.removeClass('open').addClass('close')
$mobileSidebarMenus.css('transform', '') $mobileSidebarMenus.removeClass('open')
$('#mobile-sidebar-menus > div,#mobile-sidebar-menus > hr').css('animation', '')
} }
if (name === 'toc') { if (name === 'toc') {
@@ -196,7 +190,7 @@ const sidebarFn = () => {
/** /**
* 首頁top_img底下的箭頭 * 首頁top_img底下的箭頭
*/ */
const indexScrollDown = () => { const scrollDownInIndex = () => {
$('#scroll_down').on('click', function () { $('#scroll_down').on('click', function () {
scrollToDest('#content-inner') scrollToDest('#content-inner')
}) })
@@ -319,7 +313,7 @@ function addPhotoFigcaption () {
*/ */
let detectJgJsLoad = false let detectJgJsLoad = false
const justifiedGalleryRun = function () { const runJustifiedGallery = function () {
const $justifiedGallery = $('.justified-gallery') const $justifiedGallery = $('.justified-gallery')
if ($justifiedGallery.length) { if ($justifiedGallery.length) {
const $imgList = $justifiedGallery.find('img') const $imgList = $justifiedGallery.find('img')
@@ -345,7 +339,7 @@ const justifiedGalleryRun = function () {
/** /**
* fancybox和 mediumZoom * fancybox和 mediumZoom
*/ */
const lightBox = function () { const addLightBox = function () {
const isMediumZoom = GLOBAL_CONFIG.medium_zoom const isMediumZoom = GLOBAL_CONFIG.medium_zoom
const isFancybox = GLOBAL_CONFIG.fancybox const isFancybox = GLOBAL_CONFIG.fancybox
if (isFancybox) { if (isFancybox) {
@@ -534,7 +528,7 @@ const tocFn = function () {
* Rightside * Rightside
*/ */
let $rightsideEle = $('#rightside') const $rightsideEle = $('#rightside')
// read-mode // read-mode
$rightsideEle.on('click', '#readmode', function () { $rightsideEle.on('click', '#readmode', function () {
@@ -591,7 +585,7 @@ $rightsideEle.on('click', '#go-up', () => scrollToDest('body'))
* 側邊欄sub-menu 展開/收縮 * 側邊欄sub-menu 展開/收縮
* 解決menus在觸摸屏下滑動屏幕menus_item_child不消失的問題手機hover的bug) * 解決menus在觸摸屏下滑動屏幕menus_item_child不消失的問題手機hover的bug)
*/ */
const subMenuFn = function () { const clickFnOfSubMenu = function () {
$('#mobile-sidebar-menus .expand').on('click', function () { $('#mobile-sidebar-menus .expand').on('click', function () {
$(this).parents('.menus_item').find('> .menus_item_child').slideToggle() $(this).parents('.menus_item').find('> .menus_item_child').slideToggle()
$(this).toggleClass('closed') $(this).toggleClass('closed')
@@ -634,7 +628,7 @@ const addCopyright = function () {
/** /**
* 網頁運行時間 * 網頁運行時間
*/ */
const runtimeShow = function () { const addRuntime = function () {
const $runtimeCount = $('#webinfo-runtime-count') const $runtimeCount = $('#webinfo-runtime-count')
if ($runtimeCount.length) { if ($runtimeCount.length) {
const publishDate = $runtimeCount.attr('publish_date') const publishDate = $runtimeCount.attr('publish_date')
@@ -656,7 +650,7 @@ const addTableWrap = function () {
* 百度推送 * 百度推送
*/ */
const baiduPush = () => { const pushToBaidu = () => {
const bp = document.createElement('script') const bp = document.createElement('script')
const curProtocol = window.location.protocol.split(':')[0] const curProtocol = window.location.protocol.split(':')[0]
if (curProtocol === 'https') { if (curProtocol === 'https') {
@@ -673,7 +667,7 @@ const baiduPush = () => {
* tag-hide * tag-hide
*/ */
const tagHideClick = function () { const clickFnOfTagHide = function () {
const $hideInline = $('.hide-button') const $hideInline = $('.hide-button')
if ($hideInline.length) { if ($hideInline.length) {
$hideInline.on('click', function (e) { $hideInline.on('click', function (e) {
@@ -690,7 +684,7 @@ const tagHideClick = function () {
} }
} }
const tabsClick = function () { const clickFnOfTabs = function () {
const $tab = $('#article-container .tabs') const $tab = $('#article-container .tabs')
$tab.find('.tab > button').on('click', function (e) { $tab.find('.tab > button').on('click', function (e) {
const $this = $(this) const $this = $(this)
@@ -711,7 +705,7 @@ const tabsClick = function () {
}) })
} }
const cardCategoryToggle = function () { const toggleCardCategory = function () {
const $cardCategory = $('.card-category-list-item.parent i') const $cardCategory = $('.card-category-list-item.parent i')
$cardCategory.on('click', function (e) { $cardCategory.on('click', function (e) {
e.preventDefault() e.preventDefault()
@@ -741,7 +735,7 @@ const switchComments = function () {
}) })
} }
const postNoticeUpdate = function () { const addPostOutdateNotice = function () {
const data = GLOBAL_CONFIG.noticeOutdate const data = GLOBAL_CONFIG.noticeOutdate
var diffDay = diffDate(GLOBAL_CONFIG_SITE.postUpdate) var diffDay = diffDate(GLOBAL_CONFIG_SITE.postUpdate)
if (diffDay >= data.limitDay) { if (diffDay >= data.limitDay) {
@@ -780,33 +774,33 @@ const unRefreshFn = function () {
else adjustMenu(2) else adjustMenu(2)
}) })
subMenuFn() clickFnOfSubMenu()
GLOBAL_CONFIG.copyright !== undefined && addCopyright() GLOBAL_CONFIG.copyright !== undefined && addCopyright()
GLOBAL_CONFIG.baiduPush && baiduPush() GLOBAL_CONFIG.baiduPush && pushToBaidu()
} }
const refreshFn = function () { const refreshFn = function () {
initAdjust() initAdjust()
if (GLOBAL_CONFIG_SITE.isPost) { if (GLOBAL_CONFIG_SITE.isPost) {
sidebarAutoOpen() OpenSidebarAuto()
toggleSidebarFn() toggleSidebar()
GLOBAL_CONFIG_SITE.isSidebar && tocFn() GLOBAL_CONFIG_SITE.isSidebar && tocFn()
GLOBAL_CONFIG.noticeOutdate !== undefined && postNoticeUpdate() GLOBAL_CONFIG.noticeOutdate !== undefined && addPostOutdateNotice()
} }
sidebarFn() sidebarFn()
GLOBAL_CONFIG_SITE.isHome && indexScrollDown() GLOBAL_CONFIG_SITE.isHome && scrollDownInIndex()
addHighlightTool() addHighlightTool()
GLOBAL_CONFIG.isPhotoFigcaption && addPhotoFigcaption() GLOBAL_CONFIG.isPhotoFigcaption && addPhotoFigcaption()
justifiedGalleryRun() runJustifiedGallery()
lightBox() addLightBox()
scrollFn() scrollFn()
GLOBAL_CONFIG.runtime && runtimeShow() GLOBAL_CONFIG.runtime && addRuntime()
addTableWrap() addTableWrap()
tagHideClick() clickFnOfTagHide()
tabsClick() clickFnOfTabs()
cardCategoryToggle() toggleCardCategory()
switchComments() switchComments()
} }

View File

@@ -108,10 +108,24 @@ const initJustifiedGallery = function (selector) {
}) })
} }
const diffDate = function (d) { const diffDate = d => {
const dateNow = new Date() const dateNow = new Date()
const datePost = new Date(d.replace(/-/g, '/')) const datePost = new Date(d.replace(/-/g, '/'))
const dateDiff = dateNow.getTime() - datePost.getTime() const dateDiff = dateNow.getTime() - datePost.getTime()
const dayDiff = Math.floor(dateDiff / (24 * 3600 * 1000)) const dayDiff = Math.floor(dateDiff / (24 * 3600 * 1000))
return dayDiff return dayDiff
} }
const loadComment = (dom, callback) => {
if ('IntersectionObserver' in window) {
const observerItem = new IntersectionObserver((entries) => {
if (entries[0].isIntersecting) {
callback()
observerItem.disconnect()
}
}, { threshold: [0] })
observerItem.observe(dom)
} else {
callback()
}
}