diff --git a/resources/js/custom.js b/resources/js/daux.js
similarity index 51%
rename from resources/js/custom.js
rename to resources/js/daux.js
index 4eff71f..b804f37 100644
--- a/resources/js/custom.js
+++ b/resources/js/daux.js
@@ -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 () {
- // Remove transition inline style on large screens
- if ($(window).width() >= 768)
- $('#sub-nav-collapse').removeAttr('style');
- });
-});
+_.now = Date.now || function() {
+ return new Date().getTime();
+};
-//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';
+_.debounce = function(func, wait, immediate) {
+ var timeout, args, context, timestamp, result;
+
+ 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) {
switch (x) {
@@ -38,19 +60,39 @@ function setCodeBlockStyle(x) {
case 2:
toggleCodeBlockBtn.innerHTML = "Show Code Blocks";
codeBlockView.removeClass('float-view');
- codeBlocks.addClass('hidden');
+ codeBlocks.addClass('hidden');
break;
}
}
-function toggleCodeBlocks() {
- codeBlockState = (codeBlockState + 1) % 3;
- localStorage.setItem("codeBlockState", codeBlockState);
- setCodeBlockStyle(codeBlockState);
-}
-
-//Initialize CodeBlock Visibility Settings
$(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];
codeBlockView = $('.right-column');
codeBlocks = $('.content-page article > pre');
@@ -65,4 +107,4 @@ $(function () {
toggleCodeBlockBtn.classList.add('hidden');
}
setCodeBlockStyle(codeBlockState);
-});
\ No newline at end of file
+});
diff --git a/templates/layout/00_layout.php b/templates/layout/00_layout.php
index 31e266f..a536810 100644
--- a/templates/layout/00_layout.php
+++ b/templates/layout/00_layout.php
@@ -56,6 +56,6 @@
echo '';
} ?>
-
+