Move from miccall theme to kaze
This commit is contained in:
260
js/main.js
260
js/main.js
@@ -1,259 +1 @@
|
||||
(function($) {
|
||||
|
||||
skel.breakpoints({
|
||||
xlarge: '(max-width: 1680px)',
|
||||
large: '(max-width: 1280px)',
|
||||
medium: '(max-width: 980px)',
|
||||
small: '(max-width: 736px)',
|
||||
xsmall: '(max-width: 480px)',
|
||||
xxsmall: '(max-width: 360px)'
|
||||
});
|
||||
|
||||
/**
|
||||
* Applies parallax scrolling to an element's background image.
|
||||
* @return {jQuery} jQuery object.
|
||||
*/
|
||||
$.fn._parallax = function(intensity) {
|
||||
|
||||
var $window = $(window),
|
||||
$this = $(this);
|
||||
|
||||
if (this.length == 0 || intensity === 0)
|
||||
return $this;
|
||||
|
||||
if (this.length > 1) {
|
||||
|
||||
for (var i=0; i < this.length; i++)
|
||||
$(this[i])._parallax(intensity);
|
||||
|
||||
return $this;
|
||||
|
||||
}
|
||||
|
||||
if (!intensity)
|
||||
intensity = 0.25;
|
||||
|
||||
$this.each(function() {
|
||||
|
||||
var $t = $(this),
|
||||
$bg = $('<div class="bg"></div>').appendTo($t),
|
||||
on, off;
|
||||
|
||||
on = function() {
|
||||
|
||||
$bg
|
||||
.removeClass('fixed')
|
||||
.css('transform', 'none');
|
||||
|
||||
$window
|
||||
.on('scroll._parallax', function() {
|
||||
|
||||
$bg.css('transform', 'none');
|
||||
|
||||
});
|
||||
};
|
||||
|
||||
off = function() {
|
||||
|
||||
$bg
|
||||
.addClass('fixed')
|
||||
.css('transform', 'none');
|
||||
|
||||
$window
|
||||
.off('scroll._parallax');
|
||||
|
||||
};
|
||||
|
||||
// Disable parallax on ..
|
||||
if (skel.vars.browser == 'ie' // IE
|
||||
|| skel.vars.browser == 'edge' // Edge
|
||||
|| window.devicePixelRatio > 1 // Retina/HiDPI (= poor performance)
|
||||
|| skel.vars.mobile) // Mobile devices
|
||||
off();
|
||||
|
||||
// Enable everywhere else.
|
||||
else {
|
||||
|
||||
skel.on('!large -large', on);
|
||||
skel.on('+large', off);
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
$window
|
||||
.off('load._parallax resize._parallax')
|
||||
.on('load._parallax resize._parallax', function() {
|
||||
$window.trigger('scroll');
|
||||
});
|
||||
|
||||
return $(this);
|
||||
|
||||
};
|
||||
|
||||
$(function() {
|
||||
|
||||
var $window = $(window),
|
||||
$body = $('body'),
|
||||
$wrapper = $('#wrapper'),
|
||||
$header = $('#header'),
|
||||
$nav = $('#nav'),
|
||||
$main = $('#main'),
|
||||
$navPanelToggle, $navPanel, $navPanelInner;
|
||||
|
||||
// Disable animations/transitions until the page has loaded.
|
||||
$window.on('load', function() {
|
||||
window.setTimeout(function() {
|
||||
$body.removeClass('is-loading');
|
||||
}, 100);
|
||||
});
|
||||
|
||||
// Prioritize "important" elements on medium.
|
||||
skel.on('+medium -medium', function() {
|
||||
$.prioritize(
|
||||
'.important\\28 medium\\29',
|
||||
skel.breakpoint('medium').active
|
||||
);
|
||||
});
|
||||
|
||||
// Scrolly.
|
||||
$('.scrolly').scrolly();
|
||||
|
||||
// Background.
|
||||
$wrapper._parallax(0.925);
|
||||
|
||||
// Nav Panel.
|
||||
|
||||
// Toggle.
|
||||
$navPanelToggle = $(
|
||||
'<a href="#navPanel" id="navPanelToggle">Menu</a>'
|
||||
)
|
||||
.appendTo($wrapper);
|
||||
|
||||
// Change toggle styling once we've scrolled past the header.
|
||||
$header.scrollex({
|
||||
bottom: '5vh',
|
||||
enter: function() {
|
||||
$navPanelToggle.removeClass('alt');
|
||||
},
|
||||
leave: function() {
|
||||
$navPanelToggle.addClass('alt');
|
||||
}
|
||||
});
|
||||
|
||||
// Panel.
|
||||
$navPanel = $(
|
||||
'<div id="navPanel">' +
|
||||
'<nav>' +
|
||||
'</nav>' +
|
||||
'<a href="#navPanel" class="close"></a>' +
|
||||
'</div>'
|
||||
)
|
||||
.appendTo($body)
|
||||
.panel({
|
||||
delay: 500,
|
||||
hideOnClick: true,
|
||||
hideOnSwipe: true,
|
||||
resetScroll: true,
|
||||
resetForms: true,
|
||||
side: 'right',
|
||||
target: $body,
|
||||
visibleClass: 'is-navPanel-visible'
|
||||
});
|
||||
|
||||
// Get inner.
|
||||
$navPanelInner = $navPanel.children('nav');
|
||||
|
||||
// Move nav content on breakpoint change.
|
||||
var $navContent = $nav.children();
|
||||
|
||||
skel.on('!medium -medium', function() {
|
||||
|
||||
// NavPanel -> Nav.
|
||||
$navContent.appendTo($nav);
|
||||
|
||||
// Flip icon classes.
|
||||
$nav.find('.icons, .icon')
|
||||
.removeClass('alt');
|
||||
|
||||
});
|
||||
|
||||
skel.on('+medium', function() {
|
||||
|
||||
// Nav -> NavPanel.
|
||||
$navContent.appendTo($navPanelInner);
|
||||
|
||||
// Flip icon classes.
|
||||
$navPanelInner.find('.icons, .icon')
|
||||
.addClass('alt');
|
||||
|
||||
});
|
||||
|
||||
// Hack: Disable transitions on WP.
|
||||
if (skel.vars.os == 'wp'
|
||||
&& skel.vars.osVersion < 10)
|
||||
$navPanel
|
||||
.css('transition', 'none');
|
||||
|
||||
// Intro.
|
||||
var $intro = $('#intro');
|
||||
|
||||
if ($intro.length > 0) {
|
||||
|
||||
// Hack: Fix flex min-height on IE.
|
||||
if (skel.vars.browser == 'ie') {
|
||||
$window.on('resize.ie-intro-fix', function() {
|
||||
|
||||
var h = $intro.height();
|
||||
|
||||
if (h > $window.height())
|
||||
$intro.css('height', 'auto');
|
||||
else
|
||||
$intro.css('height', h);
|
||||
|
||||
}).trigger('resize.ie-intro-fix');
|
||||
}
|
||||
|
||||
// Hide intro on scroll (> small).
|
||||
skel.on('!small -small', function() {
|
||||
|
||||
$main.unscrollex();
|
||||
|
||||
$main.scrollex({
|
||||
mode: 'bottom',
|
||||
top: '25vh',
|
||||
bottom: '-50vh',
|
||||
enter: function() {
|
||||
$intro.addClass('hidden');
|
||||
},
|
||||
leave: function() {
|
||||
$intro.removeClass('hidden');
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
// Hide intro on scroll (<= small).
|
||||
skel.on('+small', function() {
|
||||
|
||||
$main.unscrollex();
|
||||
|
||||
$main.scrollex({
|
||||
mode: 'middle',
|
||||
top: '15vh',
|
||||
bottom: '-15vh',
|
||||
enter: function() {
|
||||
$intro.addClass('hidden');
|
||||
},
|
||||
leave: function() {
|
||||
$intro.removeClass('hidden');
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
})(jQuery);
|
||||
!function(){"use strict";console.log(" \nThis blog is using hexo-theme-kaze based on MIT license\nSee theme at https://github.com/theme-kaze/hexo-theme-kaze\n");const e=document.body.scrollWidth||document.documentElement.scrollWidth;let t=null;function o(e){const t=e.target,n=document.getElementById("mobiletoc");n&&t&&!n.contains(t)&&(n.style.display="none",window.mask.remove(),document.removeEventListener("click",o))}window.searchControlButton=null,e<=742?(t=document.getElementsByClassName("darkwidget")[0],window.searchControlButton=document.getElementsByClassName("searchwidget")[0]):(t=document.getElementsByClassName("darknavbar")[0],window.searchControlButton=document.getElementsByClassName("searchnavbar")[0]),t.addEventListener("click",(()=>{window.setDarkmode(window.reverseDarkModeSetting())}));const n=()=>{const e=document.getElementById("mobiletoc");if(!e)return;e.style.display="block";const t=document.createElement("div");t.id="mask",document.body.append(t),setTimeout((()=>{document.addEventListener("click",o)}),0)};setTimeout((()=>{const e=document.getElementById("menubutton");e&&(e.onclick=n)}),0);const l=()=>{const e=document.getElementById("scrollbutton"),t=document.getElementById("menubutton"),o=document.getElementById("popbutton"),n=document.body.scrollWidth||document.documentElement.scrollWidth;"1"===e.style.opacity?(e.style.bottom="32px",e.style.opacity="0",o.style.transform="none"):(o.style.transform="rotate(90deg)",e.style.bottom="85px",e.style.opacity="1");const l=document.getElementById("mobiletoc");n<=862&&l&&("1"===t.style.opacity?(t.style.right="32px",t.style.opacity="0"):(t.style.right="85px",t.style.opacity="1"));const s=document.querySelector(".darkwidget"),c=document.querySelector(".searchwidget");n<=742&&("1"===s.style.opacity?(s.style.bottom="32px",s.style.opacity="0",s.style.transform="none"):(s.style.display="flex",o.style.transform="rotate(90deg)",s.style.bottom="138px",s.style.opacity="1"),"1"===c.style.opacity?(c.style.bottom="32px",c.style.opacity="0",c.style.transform="none"):(c.style.display="flex",c.style.transform="rotate(90deg)",c.style.bottom="191px",c.style.opacity="1"))};setTimeout((()=>{document.getElementById("popbutton").addEventListener("click",l)}),0);const s=()=>{let e=window.pageYOffset||document.body.scrollTop||document.documentElement.scrollTop;e>1?(window.requestAnimationFrame(s),scrollTo(0,Math.floor(.85*e))):scrollTo(0,0)};function c(e){const t=document.querySelector("#local-search");if(!t.contains(e.target)){const e=document.querySelector("#search-input"),o=document.querySelector("#search-content");e.value="",t.style.display="none",o.innerHTML="",window.mask.remove(),document.removeEventListener("click",c)}}setTimeout((()=>{const e=document.getElementById("scrollbutton");e&&(e.onclick=s)}),0),setTimeout((()=>{window.searchControlButton&&window.searchControlButton.addEventListener("click",(()=>{const e=document.createElement("div");e.id="mask",document.body.append(e);document.querySelector("#local-search").style.display="block",setTimeout((()=>{document.addEventListener("click",c)}),0)}))})),window.localSearch=function(e){fetch(e).then((e=>e.json())).then((e=>{let t=document.getElementById("search-input"),o=document.getElementById("search-content");t.addEventListener("input",(function(){let t='<ul class="search-result-list">',n=this.value.trim().toLowerCase().replace(/[<>&"]/g,(e=>({"<":"<",">":">","&":"&",'"':"""}[e])));if(o.innerHTML="",!(this.value.trim().length<=0)){if(e.forEach((function(e){let o=!0;e.title&&""!==e.title.trim()||(e.title="Untitled");let l=e.title.trim().toLowerCase();const s=e.content.trim().replace(/<[^>]+>/g,"").toLowerCase();let c=-1;const i=l.indexOf(n);let r=0;if(""!==s&&(r=s.indexOf(n),c=r),i<0&&r<0&&(o=!1),r<0&&(c=0),o){t+=`<li><a href="${e.url}" class="search-result-title" >'${l}</a>`;const o=e.content;if(c>=0){const e=Math.max(0,c-12),l=Math.min(o.length,c+12);let s=o.substr(e,l);s=s.replace(new RegExp(n,"gi"),'<em class="search-keyword">'+n+"</em>"),t+='<p class="search-result">'+s+"...</p>"}t+="</li>"}})),t+="</ul>",-1===t.indexOf("<li>"))return o.innerHTML='<ul><span class="local-search-empty">没有搜索到结果<span></ul>';o.innerHTML=t}}))}))}}();
|
||||
|
||||
Reference in New Issue
Block a user