mirror of
https://github.com/jerryc127/hexo-theme-butterfly.git
synced 2026-10-04 22:32:00 +08:00
✨ disqus/disqusjs/facebook comments 可隨夜間模式按鈕切換而轉換主題
🐛 修復pjax下valine評論顯示不正常的bugs 🐛 修復facebook comments 在手機下寬度不是100%的bugs
This commit is contained in:
1 parent
f7d57ac883
commit
4f64768011
17 files changed
+120
-98
No files matched your search
@@ -6,11 +6,15 @@ script.
|
||||
this.page.title = '!{ page.title }'
|
||||
};
|
||||
|
||||
if (window.DISQUS) {
|
||||
window.disqusReset = () => {
|
||||
DISQUS.reset({
|
||||
reload: true,
|
||||
config: disqus_config
|
||||
})
|
||||
}
|
||||
|
||||
if (window.DISQUS) {
|
||||
disqusReset()
|
||||
} else {
|
||||
(function() {
|
||||
var d = document, s = d.createElement('script')
|
||||
@@ -34,11 +38,11 @@ script.
|
||||
|
||||
if is_post() && theme.comments.count && defaultComment === 'Disqus'
|
||||
script.
|
||||
function getDisqusCount() {
|
||||
if (window.DISQUSWIDGETS === undefined) {
|
||||
var d = document, s = d.createElement('script');
|
||||
s.src = 'https://!{theme.disqus.shortname}.disqus.com/count.js';
|
||||
s.id = 'dsq-count-scr';
|
||||
(d.head || d.body).appendChild(s);
|
||||
} else {
|
||||
DISQUSWIDGETS.getCount({reset: true});
|
||||
}
|
||||
|
||||
getDisqusCount()
|
||||
@@ -7,7 +7,7 @@ script.
|
||||
document.getElementsByTagName('head')[0].appendChild(ele)
|
||||
}
|
||||
|
||||
function initDiqusjs () {
|
||||
function initDisqusjs () {
|
||||
window.DISQUS = null
|
||||
new DisqusJS({
|
||||
shortname: '!{theme.disqusjs.shortname}',
|
||||
@@ -23,11 +23,13 @@ script.
|
||||
});
|
||||
}
|
||||
|
||||
if (window.disqusjsload) initDiqusjs()
|
||||
window.disqusReset = initDisqusjs
|
||||
|
||||
if (window.disqusJsLoad) initDisqusjs()
|
||||
else {
|
||||
addDisqusjsCSS()
|
||||
$.getScript('!{url_for(theme.CDN.disqusjs)}', initDiqusjs)
|
||||
window.disqusjsload = true
|
||||
$.getScript('!{url_for(theme.CDN.disqusjs)}', initDisqusjs)
|
||||
window.disqusJsLoad = true
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,10 +45,12 @@ script.
|
||||
|
||||
if is_post() && theme.comments.count && defaultComment === 'Disqusjs'
|
||||
script.
|
||||
function getDisqusCount() {
|
||||
if (window.DISQUSWIDGETS === undefined) {
|
||||
var d = document, s = d.createElement('script');
|
||||
s.src = 'https://!{theme.disqusjs.shortname}.disqus.com/count.js';
|
||||
s.src = 'https://!{theme.disqus.shortname}.disqus.com/count.js';
|
||||
s.id = 'dsq-count-scr';
|
||||
(d.head || d.body).appendChild(s);
|
||||
} else {
|
||||
DISQUSWIDGETS.getCount({reset: true});
|
||||
}
|
||||
getDisqusCount()
|
||||
|
||||
@@ -1,25 +1,29 @@
|
||||
#fb-root
|
||||
script.
|
||||
function loadFBComent () {
|
||||
let ele = document.createElement('script')
|
||||
ele.setAttribute('src','https://connect.facebook.net/!{theme.facebook_comments.lang}/sdk.js#xfbml=1&version=v7.0')
|
||||
ele.setAttribute('async', 'true')
|
||||
ele.setAttribute('defer', 'true')
|
||||
ele.setAttribute('crossorigin', 'anonymous')
|
||||
document.getElementById('fb-root').insertAdjacentElement('afterbegin',ele)
|
||||
|
||||
function loadFBComment () {
|
||||
var themeNow = document.documentElement.getAttribute('data-theme') === 'dark' ? 'dark' : 'light'
|
||||
document.getElementsByClassName('fb-comments')[0].setAttribute('data-colorscheme',themeNow)
|
||||
|
||||
if (typeof FB === 'object') FB.XFBML.parse()
|
||||
else {
|
||||
let ele = document.createElement('script')
|
||||
ele.setAttribute('src','https://connect.facebook.net/!{theme.facebook_comments.lang}/sdk.js#xfbml=1&version=v7.0')
|
||||
ele.setAttribute('async', 'true')
|
||||
ele.setAttribute('defer', 'true')
|
||||
ele.setAttribute('crossorigin', 'anonymous')
|
||||
document.getElementById('fb-root').insertAdjacentElement('afterbegin',ele)
|
||||
}
|
||||
}
|
||||
|
||||
if ('!{defaultComment}' === 'Facebook Comments' || !{theme.comments.load_begin}) {
|
||||
loadFBComent()
|
||||
document.getElementsByClassName('fb-comments').length && loadFBComment()
|
||||
!{theme.pjax} && document.addEventListener('pjax:complete', () =>
|
||||
document.getElementsByClassName('fb-comments').length && loadFBComment()
|
||||
)
|
||||
}
|
||||
else {
|
||||
function loadOtherComment () {
|
||||
loadFBComent()
|
||||
loadFBComment()
|
||||
}
|
||||
}
|
||||
|
||||
Loaded 3 of 17 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user