$(document).ready(function() { var self = $(this); // Helpers $.fn.elementText = function() { return $(this).clone().children().remove().end().text(); }; // Aesthetical enhancements $('table').addClass('table table-striped table-responsive') // Sidebar expanding self.sidebarExpanded = false; self.originalSidebarStyle = { 'width': '', 'position': '', 'box-shadow': '', }; self.originalSidebarLeftMargin = parseInt($('#p-sidebar').css( 'margin-left')); self.sidebarLeftMarginAnimationWidth = 10; self.sidebarExpandedStyle = { 'width': '80%', 'right': '20px', 'position': 'absolute', 'box-shadow': '0 0 0 9999px rgba(0, 0, 0, 0.3)', }; self.sidebarWidthToggleOriginalText = $('#p-sidebar-width-toggle').text(); self.sidebarWidthToggleExpandedText = 'Narrow sidebar'; self.previousScrollPosition = null; self.toggleSidebarWidth = function() { if (self.sidebarExpanded) { self.sidebarExpanded = false; $('#p-sidebar-width-toggle') .text(self.sidebarWidthToggleOriginalText); $('#p-sidebar').css(self.originalSidebarStyle); // Scroll to the previous scroll position. $('html').scrollTop(self.previousScrollPosition); } else { self.sidebarExpanded = true; $('#p-sidebar-width-toggle') .text(self.sidebarWidthToggleExpandedText); $('#p-sidebar').css(self.sidebarExpandedStyle); // Scroll to thetop of the page. self.previousScrollPosition = $('html').scrollTop(); $('html').scrollTop(0); } }; $('#p-sidebar-width-toggle').click(function(e) { e.preventDefault(); self.toggleSidebarWidth(); }); // Collapse the sidebar when clicking on a link while the sidebar is // expanded. So when hitting the back button the sidebar will be // collapsed. This is moreintuitive. $('#toc a').click(function() { if (self.sidebarExpanded) { self.toggleSidebarWidth(); } }); // Keybinding $('body').append( '\
?
: Toggle key bindings help
w
: Toggle sidebar width
s
: Select sidebar search box
Esc
: Unselect sidebar search box
p
: Go to page search page
e
: Edit selected text
Ctrl
+ RET
: Save changes \
Alt
+ p
: Go to previous match \
Alt
+ n
: Go to next match \