feat: new style and faster
This commit is contained in:
52
assets/js/dynamicToTop.js
Executable file
52
assets/js/dynamicToTop.js
Executable file
@@ -0,0 +1,52 @@
|
||||
var mv_dynamic_to_top = {
|
||||
'text': '0',
|
||||
'version': '0',
|
||||
'min': '200',
|
||||
"speed": '300',
|
||||
'easing': 'easeInOutExpo',
|
||||
'margin': '20',
|
||||
};
|
||||
|
||||
jQuery(function($) {
|
||||
$.fn.DynamicToTop = function(options) {
|
||||
var defaults = {
|
||||
text: mv_dynamic_to_top.text,
|
||||
min: parseInt(mv_dynamic_to_top.min, 10),
|
||||
fade_in: 600,
|
||||
fade_out: 400,
|
||||
speed: parseInt(mv_dynamic_to_top.speed, 10),
|
||||
easing: mv_dynamic_to_top.easing,
|
||||
version: mv_dynamic_to_top.version,
|
||||
id: 'dynamic-to-top',
|
||||
},
|
||||
settings = $.extend(defaults, options);
|
||||
if (settings.version === '' || settings.version === '0') {
|
||||
settings.text = '<span> </span>';
|
||||
}
|
||||
if (!$.isFunction(settings.easing)) {
|
||||
settings.easing = 'linear';
|
||||
}
|
||||
var $toTop = $('<a href=\"#\" id=\"' + settings.id + '\"></a>').html(settings.text);
|
||||
$toTop.hide().appendTo('body').click(function() {
|
||||
$('html, body').stop().animate({
|
||||
scrollTop: 0
|
||||
}, settings.speed, settings.easing);
|
||||
return false;
|
||||
});
|
||||
$(window).scroll(function() {
|
||||
var sd = $(window).scrollTop();
|
||||
if (typeof document.body.style.maxHeight === 'undefined') {
|
||||
$toTop.css({
|
||||
'position': 'absolute',
|
||||
'top': sd + $(window).height() - mv_dynamic_to_top.margin
|
||||
});
|
||||
}
|
||||
if (sd > settings.min) {
|
||||
$toTop.fadeIn(settings.fade_in);
|
||||
} else {
|
||||
$toTop.fadeOut(settings.fade_out);
|
||||
}
|
||||
});
|
||||
};
|
||||
$('body').DynamicToTop();
|
||||
});
|
||||
13
assets/js/dynamicToTop.min.js
vendored
13
assets/js/dynamicToTop.min.js
vendored
@@ -1,13 +0,0 @@
|
||||
/*
|
||||
* Dynamic To Top Plugin
|
||||
* http://www.mattvarone.com
|
||||
*
|
||||
* By Matt Varone
|
||||
* @sksmatt
|
||||
*
|
||||
*/
|
||||
var mv_dynamic_to_top = {"text":"0","version":"0","min":"200","speed":"300","easing":"easeInOutExpo","margin":"20"};
|
||||
(function($,mv_dynamic_to_top){jQuery.fn.DynamicToTop=function(options){var defaults={text:mv_dynamic_to_top.text,min:parseInt(mv_dynamic_to_top.min,10),fade_in:600,fade_out:400,speed:parseInt(mv_dynamic_to_top.speed,10),easing:mv_dynamic_to_top.easing,version:mv_dynamic_to_top.version,id:'dynamic-to-top'},settings=$.extend(defaults,options);if(settings.version===""||settings.version==='0'){settings.text='<span> </span>';}
|
||||
if(!$.isFunction(settings.easing)){settings.easing='linear';}
|
||||
var $toTop=$('<a href=\"#\" id=\"'+settings.id+'\"></a>').html(settings.text);$toTop.hide().appendTo('body').click(function(){$('html, body').stop().animate({scrollTop:0},settings.speed,settings.easing);return false;});$(window).scroll(function(){var sd=jQuery(window).scrollTop();if(typeof document.body.style.maxHeight==="undefined"){$toTop.css({'position':'absolute','top':sd+$(window).height()-mv_dynamic_to_top.margin});}
|
||||
if(sd>settings.min){$toTop.fadeIn(settings.fade_in);}else{$toTop.fadeOut(settings.fade_out);}});};$('body').DynamicToTop();})(jQuery,mv_dynamic_to_top);
|
||||
2
assets/js/jquery.slim.min.js
vendored
2
assets/js/jquery.slim.min.js
vendored
File diff suppressed because one or more lines are too long
2
assets/js/lazysizes.min.js
vendored
2
assets/js/lazysizes.min.js
vendored
File diff suppressed because one or more lines are too long
5
assets/js/lightGallery-all.min.js
vendored
5
assets/js/lightGallery-all.min.js
vendored
File diff suppressed because one or more lines are too long
@@ -1,54 +0,0 @@
|
||||
$(document).ready(function () {
|
||||
let items = [];
|
||||
$('.post-content figure').each(function () {
|
||||
if ($(this).attr('class') == 'gallery-ignore') return true; // ignore any figures where class="pswp-ignore"
|
||||
// get properties from child a/img/figcaption elements,
|
||||
let $figure = $(this),
|
||||
$img = $figure.find('img'),
|
||||
$src = $img.attr('data-src'),
|
||||
$title = $figure.find('figcaption').html();
|
||||
|
||||
if ($img.data('size')) {
|
||||
let $size = $a.data('size').split('x');
|
||||
var item = {
|
||||
'src': $src,
|
||||
'thumb': $src,
|
||||
'subHtml': $title,
|
||||
'width': $size[0],
|
||||
'height': $size[1]
|
||||
}
|
||||
} else {
|
||||
var item = {
|
||||
'src': $src,
|
||||
'thumb': $src,
|
||||
'subHtml': $title
|
||||
}
|
||||
var img = new Image();
|
||||
img.src = $src;
|
||||
var wait = setInterval(function () {
|
||||
var w = img.naturalWidth,
|
||||
h = img.naturalHeight;
|
||||
if (w && h) {
|
||||
clearInterval(wait);
|
||||
item.width = w;
|
||||
item.height = h;
|
||||
}
|
||||
}, 30);
|
||||
}
|
||||
|
||||
var index = items.length;
|
||||
items.push(item);
|
||||
// console.log(item)
|
||||
|
||||
$figure.on('click', function (event) {
|
||||
event.preventDefault();
|
||||
$(this).lightGallery({
|
||||
dynamic: true,
|
||||
download: false,
|
||||
showThumbByDefault: false,
|
||||
dynamicEl: items,
|
||||
index: index
|
||||
})
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -4,6 +4,59 @@ jQuery(function($) {
|
||||
|
||||
var _Blog = window._Blog || {};
|
||||
|
||||
_Blog.toggleMobileMenu = function() {
|
||||
$('.menu-toggle').on('click', () => {
|
||||
$('.menu-toggle').toggleClass('active');
|
||||
$('#mobile-menu').toggleClass('active');
|
||||
});
|
||||
};
|
||||
|
||||
_Blog.toggleTheme = function() {
|
||||
const currentTheme = window.localStorage && window.localStorage.getItem('theme');
|
||||
const isDark = currentTheme === 'dark';
|
||||
$('body').toggleClass('dark-theme', isDark);
|
||||
$('.theme-switch').on('click', () => {
|
||||
$('body').toggleClass('dark-theme');
|
||||
window.localStorage &&
|
||||
window.localStorage.setItem('theme', document.body.classList.contains('dark-theme') ? 'dark' : 'light', );
|
||||
});
|
||||
};
|
||||
|
||||
_Blog.changeTitle = function() {
|
||||
var currentTitle = document.title;
|
||||
window.onblur = function() {
|
||||
document.title = currentTitle;
|
||||
};
|
||||
window.onfocus = function() {
|
||||
document.title = currentTitle;
|
||||
};
|
||||
};
|
||||
|
||||
_Blog.chroma = function() {
|
||||
const blocks = document.querySelectorAll('.highlight > .chroma');
|
||||
for (let i = 0; i < blocks.length; i++) {
|
||||
const block = blocks[i];
|
||||
const afterHighLight = block.querySelector('pre.chroma > code');
|
||||
const lang = afterHighLight ? afterHighLight.className : '';
|
||||
block.className += ' ' + lang;
|
||||
}
|
||||
};
|
||||
|
||||
_Blog.countdown = function() {
|
||||
if (window.countdownMap) {
|
||||
for (let id in countdownMap) {
|
||||
$(id).countdown(countdownMap[id], {elapse: true})
|
||||
.on('update.countdown', function(event) {
|
||||
var $this = $(this).html(event.strftime(''
|
||||
+ '<span>%D</span> 天 <br />'
|
||||
+ '<span>%H</span> 时 '
|
||||
+ '<span>%M</span> 分 '
|
||||
+ '<span>%S</span> 秒'));
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
_Blog.typeit = function() {
|
||||
if (window.typeitMap) {
|
||||
for (let id in typeitMap) {
|
||||
@@ -33,64 +86,12 @@ jQuery(function($) {
|
||||
}
|
||||
};
|
||||
|
||||
_Blog.countdown = function() {
|
||||
if (window.countdownMap) {
|
||||
for (let id in countdownMap) {
|
||||
$(id).countdown(countdownMap[id], {elapse: true})
|
||||
.on('update.countdown', function(event) {
|
||||
var $this = $(this).html(event.strftime(''
|
||||
+ '<span>%D</span> 天 <br />'
|
||||
+ '<span>%H</span> 时 '
|
||||
+ '<span>%M</span> 分 '
|
||||
+ '<span>%S</span> 秒'));
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
_Blog.externalUrl = function() {
|
||||
$.expr[':'].external = function(obj) {
|
||||
return !obj.href.match(/^mailto\:/) &&
|
||||
(obj.hostname != location.hostname);
|
||||
};
|
||||
$('a:external').addClass('external');
|
||||
$(".external").attr('target', '_blank');
|
||||
|
||||
}
|
||||
|
||||
_Blog.changeTitle = function() {
|
||||
var currentTitle = document.title;
|
||||
window.onblur = function() {
|
||||
document.title = currentTitle;
|
||||
}
|
||||
window.onfocus = function() {
|
||||
document.title = currentTitle;
|
||||
}
|
||||
};
|
||||
|
||||
_Blog.toggleTheme = function() {
|
||||
const currentTheme = window.localStorage && window.localStorage.getItem('theme');
|
||||
const isDark = currentTheme === 'dark';
|
||||
$('body').toggleClass('dark-theme', isDark);
|
||||
$('.theme-switch').on('click', () => {
|
||||
$('body').toggleClass('dark-theme');
|
||||
window.localStorage &&
|
||||
window.localStorage.setItem('theme', document.body.classList.contains('dark-theme') ? 'dark' : 'light', );
|
||||
});
|
||||
}
|
||||
|
||||
_Blog.toggleMobileMenu = function() {
|
||||
$('.menu-toggle').on('click', () => {
|
||||
$('.menu-toggle').toggleClass('active');
|
||||
$('#mobile-menu').toggleClass('active');
|
||||
});
|
||||
}
|
||||
|
||||
$(document).ready(function() {
|
||||
_Blog.toggleTheme();
|
||||
_Blog.countdown();
|
||||
_Blog.changeTitle();
|
||||
_Blog.toggleMobileMenu();
|
||||
_Blog.toggleTheme();
|
||||
_Blog.changeTitle();
|
||||
_Blog.chroma();
|
||||
_Blog.countdown();
|
||||
_Blog.typeit();
|
||||
});
|
||||
});
|
||||
|
||||
8
assets/js/prettify.min.js
vendored
8
assets/js/prettify.min.js
vendored
File diff suppressed because one or more lines are too long
@@ -1,4 +0,0 @@
|
||||
jQuery 3.4.1 https://github.com/jquery/jquery/releases
|
||||
lazysizes 5.1.1 https://github.com/aFarkas/lazysizes/releases
|
||||
lightGallery 1.6.12 https://github.com/sachinchoolur/lightGallery/releases
|
||||
prettify 2013.03.04 https://github.com/google/code-prettify/releases
|
||||
Reference in New Issue
Block a user