mirror of
https://github.com/jerryc127/hexo-theme-butterfly.git
synced 2026-04-16 17:40:55 +08:00
pjax
This commit is contained in:
@@ -59,25 +59,6 @@ function sidebarPaddingR () {
|
||||
}
|
||||
}
|
||||
|
||||
// iPadOS
|
||||
function isIpad () {
|
||||
return navigator.platform === 'MacIntel' && navigator.maxTouchPoints > 1
|
||||
}
|
||||
|
||||
function isTMobile () {
|
||||
const ua = navigator.userAgent
|
||||
const pa = /iPad|iPhone|iPod|Android|Opera Mini|BlackBerry|webOS|UCWEB|Blazer|PSP|IEMobile|Symbian/g
|
||||
return window.screen.width < 992 && pa.test(ua)
|
||||
}
|
||||
|
||||
function isMobile () {
|
||||
return this.isIpad() || this.isTMobile()
|
||||
}
|
||||
|
||||
function isDesktop () {
|
||||
return !this.isMobile()
|
||||
}
|
||||
|
||||
function scrollToDest (name, offset = 0) {
|
||||
const scrollOffset = $(name).offset()
|
||||
$('body,html').animate({
|
||||
@@ -85,26 +66,6 @@ function scrollToDest (name, offset = 0) {
|
||||
})
|
||||
};
|
||||
|
||||
function loadScript (url, callback) {
|
||||
const script = document.createElement('script')
|
||||
script.type = 'text/javascript'
|
||||
if (script.readyState) { // IE
|
||||
script.onreadystatechange = function () {
|
||||
if (script.readyState === 'loaded' ||
|
||||
script.readyState === 'complete') {
|
||||
script.onreadystatechange = null
|
||||
callback()
|
||||
}
|
||||
}
|
||||
} else { // Others
|
||||
script.onload = function () {
|
||||
callback()
|
||||
}
|
||||
}
|
||||
script.src = url
|
||||
document.body.appendChild(script)
|
||||
};
|
||||
|
||||
function snackbarShow (text, showAction, duration) {
|
||||
const sa = (typeof showAction !== 'undefined') ? showAction : false
|
||||
const dur = (typeof duration !== 'undefined') ? duration : 2000
|
||||
@@ -147,12 +108,10 @@ const initJustifiedGallery = function (selector) {
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* lazyload
|
||||
*/
|
||||
if (GLOBAL_CONFIG.islazyload) {
|
||||
window.lazyLoadOptions = {
|
||||
elements_selector: 'img',
|
||||
threshold: 0
|
||||
}
|
||||
const diffDate = function (d) {
|
||||
const dateNow = new Date()
|
||||
const datePost = new Date(d.replace(/-/g, '/'))
|
||||
const dateDiff = dateNow.getTime() - datePost.getTime()
|
||||
const dayDiff = Math.floor(dateDiff / (24 * 3600 * 1000))
|
||||
return dayDiff
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user