mirror of
https://github.com/jerryc127/hexo-theme-butterfly.git
synced 2026-04-16 17:50:54 +08:00
This commit is contained in:
@@ -76,10 +76,10 @@ function isDesktop () {
|
||||
return !this.isMobile()
|
||||
}
|
||||
|
||||
function scrollTo (name) {
|
||||
function scrollToDest (name, offset = 0) {
|
||||
var scrollOffset = $(name).offset()
|
||||
$('body,html').animate({
|
||||
scrollTop: scrollOffset.top
|
||||
scrollTop: scrollOffset.top - offset
|
||||
})
|
||||
};
|
||||
|
||||
@@ -117,6 +117,33 @@ function snackbarShow (text, showAction, duration) {
|
||||
})
|
||||
}
|
||||
|
||||
var Cookies = {
|
||||
get: function (name) {
|
||||
const value = `; ${document.cookie}`
|
||||
const parts = value.split(`; ${name}=`)
|
||||
if (parts.length === 2) return parts.pop().split(';').shift()
|
||||
},
|
||||
set: function (name, value, days) {
|
||||
var expires = ''
|
||||
if (days) {
|
||||
var date = new Date()
|
||||
date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000))
|
||||
expires = '; expires=' + date.toUTCString()
|
||||
}
|
||||
document.cookie = name + '=' + (value || '') + expires + '; path=/'
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* lazyload
|
||||
*/
|
||||
if (GLOBAL_CONFIG.islazyload) {
|
||||
window.lazyLoadOptions = {
|
||||
elements_selector: 'img',
|
||||
threshold: 0
|
||||
}
|
||||
}
|
||||
|
||||
window.debounce = debounce
|
||||
|
||||
window.throttle = throttle
|
||||
|
||||
Reference in New Issue
Block a user