2018-09-15 05:00:59 +00:00
|
|
|
jQuery(function($) {
|
2018-09-12 16:14:09 +00:00
|
|
|
|
2018-09-15 05:00:59 +00:00
|
|
|
'use strict';
|
2018-09-12 16:14:09 +00:00
|
|
|
|
2018-09-15 05:00:59 +00:00
|
|
|
var _Blog = window._Blog || {};
|
|
|
|
|
|
|
|
_Blog.prettify = function() {
|
|
|
|
$('pre').addClass('prettyprint linenums').attr('style', 'overflow:auto;');
|
|
|
|
window.prettyPrint && prettyPrint();
|
|
|
|
};
|
|
|
|
|
|
|
|
_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.toggleTheme = function() {
|
|
|
|
const currentTheme = window.localStorage && window.localStorage.getItem('theme')
|
2018-12-22 16:42:24 +00:00
|
|
|
const isDark = currentTheme === undefined || currentTheme === 'dark'
|
2018-09-15 05:00:59 +00:00
|
|
|
$('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', )
|
|
|
|
})
|
2018-09-12 16:14:09 +00:00
|
|
|
}
|
2018-09-15 05:00:59 +00:00
|
|
|
|
|
|
|
_Blog.toggleMobileMenu = function() {
|
|
|
|
$('.menu-toggle').on('click', () => {
|
|
|
|
$('.menu-toggle').toggleClass('active')
|
|
|
|
$('#mobile-menu').toggleClass('active')
|
|
|
|
})
|
2018-09-12 16:14:09 +00:00
|
|
|
}
|
2018-09-15 05:00:59 +00:00
|
|
|
|
|
|
|
$(document).ready(function() {
|
|
|
|
_Blog.prettify()
|
|
|
|
_Blog.toggleTheme()
|
|
|
|
_Blog.toggleMobileMenu()
|
|
|
|
});
|
2018-12-22 16:42:24 +00:00
|
|
|
});
|