/** 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. */ (function($ , undefined) { //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 is_element_pos = 'getcomputedstyle' in window ? //el.offsetheight is used to force redraw and recalculate 'el.style.position' esp. for webkit! function(el, pos) { el.offsetheight; return window.getcomputedstyle(el).position == pos } : function(el, pos) { el.offsetheight; return $(el).css('position') == pos } function sidebar_scroll(sidebar , settings) { var self = this; var $window = $(window); var $sidebar = $(sidebar), $nav = $sidebar.find('.nav-list'), $toggle = $sidebar.find('.sidebar-toggle').eq(0), $shortcuts = $sidebar.find('.sidebar-shortcuts').eq(0); var nav = $nav.get(0); if(!nav) return; var attrib_values = ace.helper.getattrsettings(sidebar, $.fn.ace_sidebar_scroll.defaults); this.settings = $.extend({}, $.fn.ace_sidebar_scroll.defaults, settings, attrib_values); var scroll_to_active = self.settings.scroll_to_active; var ace_sidebar = $sidebar.ace_sidebar('ref'); $sidebar.attr('data-sidebar-scroll', 'true'); var scroll_div = null, scroll_content = null, scroll_content_div = null, bar = null, track = null, ace_scroll = null; this.is_scrolling = false; var _initiated = false; this.sidebar_fixed = is_element_pos(sidebar, 'fixed'); var $avail_height, $content_height; var available_height = function() { //available window space var offset = $nav.parent().offset();//because `$nav.offset()` considers the "scrolled top" amount as well if(self.sidebar_fixed) offset.top -= ace.helper.scrolltop(); return $window.innerheight() - offset.top - ( self.settings.include_toggle ? 0 : $toggle.outerheight() ); } var content_height = function() { return nav.clientheight;//we don't use nav.scrollheight here, because hover submenus are considered in calculating scrollheight despite position=absolute! } var initiate = function(on_page_load) { if( _initiated ) return; if( !self.sidebar_fixed ) return;//eligible?? //return if we want scrollbars only on "fixed" sidebar and sidebar is not "fixed" yet! //initiate once $nav.wrap('