2015-07-29 19:34:48 +08:00
|
|
|
$( document ).ready(function() {
|
|
|
|
|
2015-09-05 23:26:17 +08:00
|
|
|
// url
|
|
|
|
var url = window.location.pathname;
|
|
|
|
|
2015-08-06 00:28:59 +08:00
|
|
|
// Syntax highlighting Configuration
|
|
|
|
hljs.configure({
|
|
|
|
tabReplace: ' ', // 4 spaces
|
|
|
|
languages: [], // Languages used for auto-detection
|
|
|
|
});
|
|
|
|
|
|
|
|
$('code').each(function(i, block) {
|
|
|
|
hljs.highlightBlock(block);
|
|
|
|
});
|
|
|
|
|
|
|
|
|
2015-07-29 19:34:48 +08:00
|
|
|
// Interesting DOM Elements
|
|
|
|
var sidebar = $("#sidebar");
|
|
|
|
var page_wrapper = $("#page-wrapper");
|
|
|
|
|
|
|
|
$("#sidebar-toggle").click(function(event){
|
|
|
|
if(sidebar.position().left === 0){
|
|
|
|
sidebar.css({left: "-300px"});
|
|
|
|
page_wrapper.css({left: "15px"});
|
|
|
|
} else {
|
|
|
|
sidebar.css({left: "0"});
|
|
|
|
page_wrapper.css({left: "315px"});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2015-09-05 23:26:17 +08:00
|
|
|
// Print button
|
|
|
|
$("#print-button").click(function(){
|
|
|
|
var printWindow = window.open("print.html");
|
|
|
|
});
|
|
|
|
|
|
|
|
if( url.substring(url.lastIndexOf('/')+1) == "print.html" ) {
|
|
|
|
window.print();
|
|
|
|
}
|
|
|
|
|
2015-09-11 07:16:29 +08:00
|
|
|
// Theme button
|
|
|
|
$("#theme-toggle").click(function(){
|
|
|
|
if($('.theme-popup').length) {
|
|
|
|
$('.theme-popup').remove();
|
|
|
|
} else {
|
|
|
|
var popup = $('<div class="theme-popup"></div>')
|
|
|
|
.append($('<div class="theme" id="light">Light (default)<div>'))
|
|
|
|
.append($('<div class="theme" id="dark">Dark</div>'));
|
|
|
|
|
|
|
|
|
|
|
|
$(this).append(popup);
|
|
|
|
|
|
|
|
$('.theme').click(function(){
|
|
|
|
var theme = $(this).attr('id');
|
|
|
|
$('body').removeClass().addClass(theme);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
2015-07-29 19:34:48 +08:00
|
|
|
});
|