daux.io/js/custom.js

66 lines
1.9 KiB
JavaScript
Raw Normal View History

2014-02-16 23:06:28 +01:00
$(function () {
$('.aj-nav').click(function (e) {
e.preventDefault();
$(this).parent().siblings().find('ul').slideUp();
$(this).next().slideToggle();
});
2013-06-12 00:28:29 +02:00
2014-02-16 23:06:28 +01:00
// Bootstrap Table Class
$('table').addClass('table');
2014-02-16 23:06:28 +01:00
// Responsive menu spinner
$('#menu-spinner-button').click(function () {
$('#sub-nav-collapse').slideToggle();
});
2014-02-16 23:06:28 +01:00
// Catch browser resize
$(window).resize(function () {
// Remove transition inline style on large screens
if ($(window).width() >= 768)
$('#sub-nav-collapse').removeAttr('style');
});
});
//Fix GitHub Ribbon overlapping Scrollbar
var t = $('#github-ribbon');
var a = $('article');
if (t[0] && a[0] && a[0].scrollHeight > $('.right-column').height()) t[0].style.right = '16px';
//Toggle Code Block Visibility
function toggleCodeBlocks() {
var t = localStorage.getItem("toggleCodeStats")
t = (t + 1) % 3;
localStorage.setItem("toggleCodeStats", t);
var a = $('.content-page article');
2014-02-16 23:06:28 +01:00
var c = a.children().filter('pre');
var d = $('.right-column');
if (d.hasClass('float-view')) {
d.removeClass('float-view');
$('#toggleCodeBlockBtn')[0].innerHTML = "Hide Code Blocks";
} else {
2014-02-16 23:06:28 +01:00
if (c.hasClass('hidden')) {
d.addClass('float-view');
2014-02-16 23:06:28 +01:00
c.removeClass('hidden');
$('#toggleCodeBlockBtn')[0].innerHTML = "Show Code Blocks Inline";
} else {
2014-02-16 23:06:28 +01:00
c.addClass('hidden');
$('#toggleCodeBlockBtn')[0].innerHTML = "Show Code Blocks";
}
}
}
if (localStorage.getItem("toggleCodeStats") >= 0) {
var t = localStorage.getItem("toggleCodeStats");
if (t == 1) {
toggleCodeBlocks();
localStorage.setItem("toggleCodeStats", 1);
}
if (t == 2) {
toggleCodeBlocks();
toggleCodeBlocks();
localStorage.setItem("toggleCodeStats", 2);
}
} else {
localStorage.setItem("toggleCodeStats", 0);
}