Clean up custom.js, rename to daux.js
This commit is contained in:
parent
848e68ea55
commit
0298b7bf91
@ -1,26 +1,48 @@
|
|||||||
$(function () {
|
|
||||||
$('.aj-nav').click(function (e) {
|
|
||||||
e.preventDefault();
|
|
||||||
$(this).parent().siblings().find('ul').slideUp();
|
|
||||||
$(this).next().slideToggle();
|
|
||||||
});
|
|
||||||
|
|
||||||
$('table').addClass('table');
|
_ = {};
|
||||||
$('#menu-spinner-button').click(function () {
|
|
||||||
$('#sub-nav-collapse').slideToggle();
|
|
||||||
});
|
|
||||||
|
|
||||||
$(window).resize(function () {
|
_.now = Date.now || function() {
|
||||||
// Remove transition inline style on large screens
|
return new Date().getTime();
|
||||||
if ($(window).width() >= 768)
|
};
|
||||||
$('#sub-nav-collapse').removeAttr('style');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
//Fix GitHub Ribbon overlapping Scrollbar
|
_.debounce = function(func, wait, immediate) {
|
||||||
var t = $('#github-ribbon');
|
var timeout, args, context, timestamp, result;
|
||||||
var a = $('article');
|
|
||||||
if (t[0] && a[0] && a[0].scrollHeight > $('.right-column').height()) t[0].style.right = '16px';
|
var later = function() {
|
||||||
|
var last = _.now() - timestamp;
|
||||||
|
|
||||||
|
if (last < wait && last >= 0) {
|
||||||
|
timeout = setTimeout(later, wait - last);
|
||||||
|
} else {
|
||||||
|
timeout = null;
|
||||||
|
if (!immediate) {
|
||||||
|
result = func.apply(context, args);
|
||||||
|
if (!timeout) context = args = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return function() {
|
||||||
|
context = this;
|
||||||
|
args = arguments;
|
||||||
|
timestamp = _.now();
|
||||||
|
var callNow = immediate && !timeout;
|
||||||
|
if (!timeout) timeout = setTimeout(later, wait);
|
||||||
|
if (callNow) {
|
||||||
|
result = func.apply(context, args);
|
||||||
|
context = args = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
var codeBlocks, codeBlockView, toggleCodeBlockBtn, codeBlockState;
|
||||||
|
function toggleCodeBlocks() {
|
||||||
|
codeBlockState = (codeBlockState + 1) % 3;
|
||||||
|
localStorage.setItem("codeBlockState", codeBlockState);
|
||||||
|
setCodeBlockStyle(codeBlockState);
|
||||||
|
}
|
||||||
|
|
||||||
function setCodeBlockStyle(x) {
|
function setCodeBlockStyle(x) {
|
||||||
switch (x) {
|
switch (x) {
|
||||||
@ -38,19 +60,39 @@ function setCodeBlockStyle(x) {
|
|||||||
case 2:
|
case 2:
|
||||||
toggleCodeBlockBtn.innerHTML = "Show Code Blocks";
|
toggleCodeBlockBtn.innerHTML = "Show Code Blocks";
|
||||||
codeBlockView.removeClass('float-view');
|
codeBlockView.removeClass('float-view');
|
||||||
codeBlocks.addClass('hidden');
|
codeBlocks.addClass('hidden');
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function toggleCodeBlocks() {
|
|
||||||
codeBlockState = (codeBlockState + 1) % 3;
|
|
||||||
localStorage.setItem("codeBlockState", codeBlockState);
|
|
||||||
setCodeBlockStyle(codeBlockState);
|
|
||||||
}
|
|
||||||
|
|
||||||
//Initialize CodeBlock Visibility Settings
|
|
||||||
$(function () {
|
$(function () {
|
||||||
|
// Tree navigation
|
||||||
|
$('.aj-nav').click(function (e) {
|
||||||
|
e.preventDefault();
|
||||||
|
$(this).parent().siblings().find('ul').slideUp();
|
||||||
|
$(this).next().slideToggle();
|
||||||
|
});
|
||||||
|
|
||||||
|
// Responsive navigation
|
||||||
|
$('#menu-spinner-button').click(function () {
|
||||||
|
$('#sub-nav-collapse').slideToggle();
|
||||||
|
});
|
||||||
|
|
||||||
|
//Github ribbon placement
|
||||||
|
var ribbon = $('#github-ribbon');
|
||||||
|
function onResize() {
|
||||||
|
//Fix GitHub Ribbon overlapping Scrollbar
|
||||||
|
var a = $('article');
|
||||||
|
if (ribbon[0] && a[0] && a[0].scrollHeight > $('.right-column').height()) {
|
||||||
|
ribbon[0].style.right = '16px';
|
||||||
|
} else {
|
||||||
|
ribbon[0].style.right = '';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$(window).resize(_.debounce(onResize, 100));
|
||||||
|
onResize();
|
||||||
|
|
||||||
|
//Initialize CodeBlock Visibility Settings
|
||||||
toggleCodeBlockBtn = $('#toggleCodeBlockBtn')[0];
|
toggleCodeBlockBtn = $('#toggleCodeBlockBtn')[0];
|
||||||
codeBlockView = $('.right-column');
|
codeBlockView = $('.right-column');
|
||||||
codeBlocks = $('.content-page article > pre');
|
codeBlocks = $('.content-page article > pre');
|
||||||
@ -65,4 +107,4 @@ $(function () {
|
|||||||
toggleCodeBlockBtn.classList.add('hidden');
|
toggleCodeBlockBtn.classList.add('hidden');
|
||||||
}
|
}
|
||||||
setCodeBlockStyle(codeBlockState);
|
setCodeBlockStyle(codeBlockState);
|
||||||
});
|
});
|
@ -56,6 +56,6 @@
|
|||||||
echo '<script src="' . $js . '"></script>';
|
echo '<script src="' . $js . '"></script>';
|
||||||
} ?>
|
} ?>
|
||||||
|
|
||||||
<script src="<?= $base_url; ?>resources/js/custom.js"></script>
|
<script src="<?= $base_url; ?>resources/js/daux.js"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
Loading…
Reference in New Issue
Block a user