mirror of
https://github.com/jerryc127/hexo-theme-butterfly.git
synced 2026-04-12 22:17:06 +08:00
Compare commits
37 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4a69c623fc | ||
|
|
eb823b0a2d | ||
|
|
83299dfd2f | ||
|
|
8f412c90da | ||
|
|
6a1330de84 | ||
|
|
eb5a356a4e | ||
|
|
f4b07340f7 | ||
|
|
17d8062968 | ||
|
|
d4b69051aa | ||
|
|
59f6ce63e3 | ||
|
|
cd78f639dd | ||
|
|
8e4c20f6d4 | ||
|
|
e984efa35c | ||
|
|
863cf1e780 | ||
|
|
85b8a83371 | ||
|
|
d73960f2a2 | ||
|
|
fcd430902d | ||
|
|
ee45f6517f | ||
|
|
67201ac58d | ||
|
|
315d3b50df | ||
|
|
727a2d97d9 | ||
|
|
54b67987c1 | ||
|
|
26df41c772 | ||
|
|
4e7051ad77 | ||
|
|
955b4bae6a | ||
|
|
95ddf28f3b | ||
|
|
e901f9ad35 | ||
|
|
462422e279 | ||
|
|
bad24849bd | ||
|
|
eb242f0809 | ||
|
|
b1795e3def | ||
|
|
54b212ead3 | ||
|
|
4bbc035f54 | ||
|
|
40ba3bb92f | ||
|
|
e2cb0242bb | ||
|
|
559afab632 | ||
|
|
c134d4fc86 |
@@ -77,7 +77,7 @@
|
|||||||
else if whichCount === 'Gitalk'
|
else if whichCount === 'Gitalk'
|
||||||
+countBlock
|
+countBlock
|
||||||
a(href=url_for(page.path) + '#post-comment')
|
a(href=url_for(page.path) + '#post-comment')
|
||||||
span.gitalk-#card-toc
|
span.gitalk-comment-count
|
||||||
else if whichCount === 'Twikoo'
|
else if whichCount === 'Twikoo'
|
||||||
+countBlock
|
+countBlock
|
||||||
a(href=url_for(page.path) + '#post-comment')
|
a(href=url_for(page.path) + '#post-comment')
|
||||||
|
|||||||
@@ -23,11 +23,11 @@ script.
|
|||||||
const loadTwikoo = (bool = false) => {
|
const loadTwikoo = (bool = false) => {
|
||||||
if (typeof twikoo === 'object') {
|
if (typeof twikoo === 'object') {
|
||||||
init()
|
init()
|
||||||
bool && $countDom && setTimeout(()=>{getCount()},0)
|
bool && $countDom && setTimeout(getCount,0)
|
||||||
} else {
|
} else {
|
||||||
getScript('!{theme.CDN.twikoo}').then(()=> {
|
getScript('!{theme.CDN.twikoo}').then(()=> {
|
||||||
init()
|
init()
|
||||||
bool && $countDom && setTimeout(()=>{getCount()},0)
|
bool && $countDom && setTimeout(getCount,0)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ script.
|
|||||||
|
|
||||||
if ('!{theme.comments.use[0]}' === 'Valine' || !!{theme.comments.lazyload}) {
|
if ('!{theme.comments.use[0]}' === 'Valine' || !!{theme.comments.lazyload}) {
|
||||||
if (!{theme.comments.lazyload}) btf.loadComment(document.querySelector('#vcomment'),loadValine)
|
if (!{theme.comments.lazyload}) btf.loadComment(document.querySelector('#vcomment'),loadValine)
|
||||||
else setTimeout(() => loadValine(), 0)
|
else setTimeout(loadValine, 0)
|
||||||
} else {
|
} else {
|
||||||
function loadOtherComment () {
|
function loadOtherComment () {
|
||||||
loadValine()
|
loadValine()
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "hexo-theme-butterfly",
|
"name": "hexo-theme-butterfly",
|
||||||
"version": "3.4.0",
|
"version": "3.4.2",
|
||||||
"description": "A Simple and Card UI Design theme for Hexo",
|
"description": "A Simple and Card UI Design theme for Hexo",
|
||||||
"main": "package.json",
|
"main": "package.json",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
@@ -247,40 +247,38 @@ document.addEventListener('DOMContentLoaded', function () {
|
|||||||
* fancybox和 mediumZoom
|
* fancybox和 mediumZoom
|
||||||
*/
|
*/
|
||||||
const addFancybox = function (ele) {
|
const addFancybox = function (ele) {
|
||||||
if (ele.length) {
|
const runFancybox = (ele) => {
|
||||||
const runFancybox = (ele) => {
|
ele.each(function (i, o) {
|
||||||
ele.each(function (i, o) {
|
const $this = $(o)
|
||||||
const $this = $(o)
|
const lazyloadSrc = $this.attr('data-lazy-src') || $this.attr('src')
|
||||||
const lazyloadSrc = $this.attr('data-lazy-src') || $this.attr('src')
|
const dataCaption = $this.attr('alt') || ''
|
||||||
const dataCaption = $this.attr('alt') || ''
|
$this.wrap(`<a href="${lazyloadSrc}" data-fancybox="group" data-caption="${dataCaption}" class="fancybox"></a>`)
|
||||||
$this.wrap(`<a href="${lazyloadSrc}" data-fancybox="group" data-caption="${dataCaption}" class="fancybox"></a>`)
|
})
|
||||||
})
|
|
||||||
|
|
||||||
$().fancybox({
|
$().fancybox({
|
||||||
selector: '[data-fancybox]',
|
selector: '[data-fancybox]',
|
||||||
loop: true,
|
loop: true,
|
||||||
transitionEffect: 'slide',
|
transitionEffect: 'slide',
|
||||||
protect: true,
|
protect: true,
|
||||||
buttons: ['slideShow', 'fullScreen', 'thumbs', 'close'],
|
buttons: ['slideShow', 'fullScreen', 'thumbs', 'close'],
|
||||||
hash: false
|
hash: false
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof $.fancybox === 'undefined') {
|
if (typeof $.fancybox === 'undefined') {
|
||||||
$('head').append(`<link rel="stylesheet" type="text/css" href="${GLOBAL_CONFIG.source.fancybox.css}">`)
|
$('head').append(`<link rel="stylesheet" type="text/css" href="${GLOBAL_CONFIG.source.fancybox.css}">`)
|
||||||
$.getScript(`${GLOBAL_CONFIG.source.fancybox.js}`, function () {
|
$.getScript(`${GLOBAL_CONFIG.source.fancybox.js}`, function () {
|
||||||
runFancybox($(ele))
|
|
||||||
})
|
|
||||||
} else {
|
|
||||||
runFancybox($(ele))
|
runFancybox($(ele))
|
||||||
}
|
})
|
||||||
|
} else {
|
||||||
|
runFancybox($(ele))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const addMediumZoom = () => {
|
const addMediumZoom = () => {
|
||||||
const zoom = mediumZoom(document.querySelectorAll('#article-container :not(a)>img'))
|
const zoom = mediumZoom(document.querySelectorAll('#article-container :not(a)>img'))
|
||||||
zoom.on('open', e => {
|
zoom.on('open', e => {
|
||||||
const photoBg = $(document.documentElement).attr('data-theme') === 'dark' ? '#121212' : '#fff'
|
const photoBg = document.documentElement.getAttribute('data-theme') === 'dark' ? '#121212' : '#fff'
|
||||||
zoom.update({
|
zoom.update({
|
||||||
background: photoBg
|
background: photoBg
|
||||||
})
|
})
|
||||||
@@ -288,15 +286,17 @@ document.addEventListener('DOMContentLoaded', function () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const jqLoadAndRun = () => {
|
const jqLoadAndRun = () => {
|
||||||
const isFancybox = GLOBAL_CONFIG.lightbox === 'fancybox'
|
const $fancyboxEle = GLOBAL_CONFIG.lightbox === 'fancybox'
|
||||||
const $fancyboxEle = isFancybox ? document.querySelectorAll('#article-container :not(a):not(.gallery-group) > img, #article-container > img') : null
|
? document.querySelectorAll('#article-container :not(a):not(.gallery-group) > img, #article-container > img')
|
||||||
|
: []
|
||||||
|
const fbLengthNoZero = $fancyboxEle.length > 0
|
||||||
const $jgEle = document.querySelectorAll('#article-container .justified-gallery')
|
const $jgEle = document.querySelectorAll('#article-container .justified-gallery')
|
||||||
const jgEleLength = $jgEle.length
|
const jgLengthNoZero = $jgEle.length > 0
|
||||||
|
|
||||||
if (jgEleLength || $fancyboxEle !== null) {
|
if (jgLengthNoZero || fbLengthNoZero) {
|
||||||
btf.isJqueryLoad(() => {
|
btf.isJqueryLoad(() => {
|
||||||
jgEleLength && runJustifiedGallery($jgEle)
|
jgLengthNoZero && runJustifiedGallery($jgEle)
|
||||||
isFancybox && addFancybox($fancyboxEle)
|
fbLengthNoZero && addFancybox($fancyboxEle)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -471,7 +471,7 @@ document.addEventListener('DOMContentLoaded', function () {
|
|||||||
const currentActive = $tocLink[currentIndex]
|
const currentActive = $tocLink[currentIndex]
|
||||||
currentActive.classList.add('active')
|
currentActive.classList.add('active')
|
||||||
|
|
||||||
setTimeout(function () {
|
setTimeout(() => {
|
||||||
autoScrollToc(currentActive)
|
autoScrollToc(currentActive)
|
||||||
}, 0)
|
}, 0)
|
||||||
|
|
||||||
@@ -626,7 +626,7 @@ document.addEventListener('DOMContentLoaded', function () {
|
|||||||
*/
|
*/
|
||||||
const addRuntime = () => {
|
const addRuntime = () => {
|
||||||
const $runtimeCount = document.getElementById('runtimeshow')
|
const $runtimeCount = document.getElementById('runtimeshow')
|
||||||
if ($runtimeCount !== null) {
|
if ($runtimeCount) {
|
||||||
const publishDate = $runtimeCount.getAttribute('data-publishDate')
|
const publishDate = $runtimeCount.getAttribute('data-publishDate')
|
||||||
$runtimeCount.innerText = btf.diffDate(publishDate) + ' ' + GLOBAL_CONFIG.runtime
|
$runtimeCount.innerText = btf.diffDate(publishDate) + ' ' + GLOBAL_CONFIG.runtime
|
||||||
}
|
}
|
||||||
@@ -637,7 +637,7 @@ document.addEventListener('DOMContentLoaded', function () {
|
|||||||
*/
|
*/
|
||||||
const addLastPushDate = () => {
|
const addLastPushDate = () => {
|
||||||
const $lastPushDateItem = document.getElementById('last-push-date')
|
const $lastPushDateItem = document.getElementById('last-push-date')
|
||||||
if ($lastPushDateItem !== null) {
|
if ($lastPushDateItem) {
|
||||||
const lastPushDate = $lastPushDateItem.getAttribute('data-lastPushDate')
|
const lastPushDate = $lastPushDateItem.getAttribute('data-lastPushDate')
|
||||||
$lastPushDateItem.innerText = btf.diffDate(lastPushDate, true)
|
$lastPushDateItem.innerText = btf.diffDate(lastPushDate, true)
|
||||||
}
|
}
|
||||||
@@ -685,7 +685,8 @@ document.addEventListener('DOMContentLoaded', function () {
|
|||||||
|
|
||||||
if (!$tabItem.classList.contains('active')) {
|
if (!$tabItem.classList.contains('active')) {
|
||||||
const $tabContent = $tabItem.parentNode.nextElementSibling
|
const $tabContent = $tabItem.parentNode.nextElementSibling
|
||||||
btf.siblings($tabItem, '.active')[0].classList.remove('active')
|
const $siblings = btf.siblings($tabItem, '.active')[0]
|
||||||
|
$siblings && $siblings.classList.remove('active')
|
||||||
$tabItem.classList.add('active')
|
$tabItem.classList.add('active')
|
||||||
const tabId = $this.getAttribute('data-href').replace('#', '')
|
const tabId = $this.getAttribute('data-href').replace('#', '')
|
||||||
const childList = [...$tabContent.children]
|
const childList = [...$tabContent.children]
|
||||||
@@ -712,7 +713,7 @@ document.addEventListener('DOMContentLoaded', function () {
|
|||||||
|
|
||||||
const toggleCardCategory = function () {
|
const toggleCardCategory = function () {
|
||||||
const $cardCategory = document.querySelectorAll('#aside-cat-list .card-category-list-item.parent i')
|
const $cardCategory = document.querySelectorAll('#aside-cat-list .card-category-list-item.parent i')
|
||||||
if ($cardCategory.length > 0) {
|
if ($cardCategory.length) {
|
||||||
$cardCategory.forEach(function (item) {
|
$cardCategory.forEach(function (item) {
|
||||||
item.addEventListener('click', function (e) {
|
item.addEventListener('click', function (e) {
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
|
|||||||
@@ -88,8 +88,9 @@ document.addEventListener('DOMContentLoaded', function () {
|
|||||||
translateButtonObject = document.getElementById('translateLink')
|
translateButtonObject = document.getElementById('translateLink')
|
||||||
if (translateButtonObject) {
|
if (translateButtonObject) {
|
||||||
if (currentEncoding !== targetEncoding) {
|
if (currentEncoding !== targetEncoding) {
|
||||||
setTimeout(function () { translateBody() }, translateDelay)
|
setTimeout(translateBody, translateDelay)
|
||||||
if (targetEncoding === 1) { translateButtonObject.innerHTML = msgToSimplifiedChinese } else translateButtonObject.innerHTML = msgToTraditionalChinese
|
if (targetEncoding === 1) translateButtonObject.innerHTML = msgToSimplifiedChinese
|
||||||
|
else translateButtonObject.innerHTML = msgToTraditionalChinese
|
||||||
}
|
}
|
||||||
translateButtonObject.addEventListener('click', translatePage, false)
|
translateButtonObject.addEventListener('click', translatePage, false)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user