mirror of
https://github.com/jerryc127/hexo-theme-butterfly.git
synced 2026-04-10 21:17:07 +08:00
feat: 去除 jQuery (fancybox和圖庫 仍需要加載jQuery)
feat: 點擊文字特效增加隨機配置 feat: 可配置是否添加css前綴 fix: 修復子目錄下,配置justifiedGallery CDN(相對鏈接)後,連接會無法訪問的bugs fix: 修復 pangu 配置post 後,仍在全站生效的bugs improvement: 夜間模式下,廣告降低亮度 improvement: 手機端toc邊距微調 improvement: html格式優化 improvement: 搜索優化 improvement: 刪除不必要的語言文件
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
$(function () {
|
||||
window.addEventListener('load', () => {
|
||||
const openSearch = () => {
|
||||
$('body').css({ width: '100%', overflow: 'hidden' })
|
||||
$('#algolia-search .search-dialog').css('display', 'block')
|
||||
$('.ais-search-box--input').focus()
|
||||
$('#search-mask').fadeIn()
|
||||
document.body.style.cssText = 'width: 100%;overflow: hidden'
|
||||
document.querySelector('#algolia-search .search-dialog').style.display = 'block'
|
||||
document.querySelector('#algolia-search .ais-search-box--input').focus()
|
||||
btf.fadeIn(document.getElementById('search-mask'), 0.5)
|
||||
// shortcut: ESC
|
||||
document.addEventListener('keydown', function f (event) {
|
||||
if (event.code === 'Escape') {
|
||||
@@ -14,30 +14,23 @@ $(function () {
|
||||
}
|
||||
|
||||
const closeSearch = () => {
|
||||
$('body').css({ width: '', overflow: '' })
|
||||
$('#algolia-search .search-dialog').css({
|
||||
animation: 'search_close .5s'
|
||||
})
|
||||
|
||||
setTimeout(function () {
|
||||
$('#algolia-search .search-dialog').css({
|
||||
animation: '',
|
||||
display: 'none'
|
||||
})
|
||||
}, 500)
|
||||
|
||||
$('#search-mask').fadeOut()
|
||||
document.body.style.cssText = "width: '';overflow: ''"
|
||||
const $searchDialog = document.querySelector('#algolia-search .search-dialog')
|
||||
$searchDialog.style.animation = 'search_close .5s'
|
||||
setTimeout(() => { $searchDialog.style.cssText = "display: none; animation: ''" }, 500)
|
||||
btf.fadeOut(document.getElementById('search-mask'), 0.5)
|
||||
}
|
||||
|
||||
const searchClickFn = () => {
|
||||
$('a.social-icon.search').on('click', openSearch)
|
||||
$('#search-mask, .search-close-button').on('click touchstart', closeSearch)
|
||||
document.querySelector('#search-button > .search').addEventListener('click', openSearch)
|
||||
document.getElementById('search-mask').addEventListener('click', closeSearch)
|
||||
document.querySelector('#algolia-search .search-close-button').addEventListener('click', closeSearch)
|
||||
}
|
||||
|
||||
searchClickFn()
|
||||
|
||||
window.addEventListener('pjax:complete', function () {
|
||||
closeSearch()
|
||||
getComputedStyle(document.querySelector('#algolia-search .search-dialog')).display === 'block' && closeSearch()
|
||||
searchClickFn()
|
||||
})
|
||||
|
||||
@@ -55,9 +48,9 @@ $(function () {
|
||||
hitsPerPage: algolia.hits.per_page || 10
|
||||
},
|
||||
searchFunction: function (helper) {
|
||||
const searchInput = $('#algolia-search-input').find('input')
|
||||
const searchInput = document.querySelector('#algolia-search-input input')
|
||||
|
||||
if (searchInput.val()) {
|
||||
if (searchInput.value) {
|
||||
helper.search()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user