/** Scrollbars for sidebar. This approach can only be used on fixed sidebar. It doesn't use "overflow:hidden" CSS property and therefore can be used with .hover submenus and minimized sidebar. Except when in mobile view and menu toggle button is not in the navbar. */ ace.sidebar_scrollable = function($ , scroll_to_active, include_shortcuts, include_toggle, smooth_scroll, scrollbars_outside) { if( !$.fn.ace_scroll ) return; var old_safari = ace.vars['safari'] && navigator.userAgent.match(/version\/[1-5]/i) //NOTE //Safari on windows has not been updated for a long time. //And it has a problem when sidebar is fixed&scrollable and there is a CSS3 animation inside page content. //Very probably windows users of safari have migrated to another browser by now! var $sidebar = $('.sidebar'), $navbar = $('.navbar'), $nav = $sidebar.find('.nav-list'), $toggle = $sidebar.find('.sidebar-toggle'), $shortcuts = $sidebar.find('.sidebar-shortcuts'), $window = $(window), sidebar = $sidebar.get(0), nav = $nav.get(0); if(!sidebar || !nav) return; var scroll_div = null, scroll_content = null, scroll_content_div = null, bar = null, ace_scroll = null; var is_scrolling = false, _initiated = false; var scroll_to_active = scroll_to_active || false, include_shortcuts = include_shortcuts || false, include_toggle = include_toggle || false, only_if_fixed = true; var is_sidebar_fixed = 'getComputedStyle' in window ? //sidebar.offsetHeight is used to force redraw and recalculate 'sidebar.style.position' esp for webkit! function() { sidebar.offsetHeight; return window.getComputedStyle(sidebar).position == 'fixed' } : function() { sidebar.offsetHeight; return $sidebar.css('position') == 'fixed' } //sometimes when navbar is fixed, sidebar automatically becomes fixed without needing ".sidebar-fixed" class //currently when mobile_style == 1 var $avail_height, $content_height; var sidebar_fixed = is_sidebar_fixed(), horizontal = $sidebar.hasClass('h-sidebar'); var scrollbars = ace.helper.sidebar_scroll = { available_height: function() { //available window space var offset = $nav.parent().offset();//because `$nav.offset()` considers the "scrolled top" amount as well if(sidebar_fixed) offset.top -= ace.helper.scrollTop(); return $window.innerHeight() - offset.top - ( include_toggle ? 0 : $toggle.outerHeight() ); }, content_height: function() { return nav.scrollHeight; }, initiate: function(on_page_load) { if( _initiated ) return; if( !sidebar_fixed ) return;//eligible?? //return if we want scrollbars only on "fixed" sidebar and sidebar is not "fixed" yet! //initiate once $nav.wrap('
'); $nav.after('
'); $nav.wrap('