3 $('a[rel=tooltip]').tooltip({
9 $(document).ready(function() {
10 function filterPath(string) {
13 .replace(/(index|default).[a-zA-Z]{3,4}$/,'')
16 var locationPath = filterPath(location.pathname);
17 var scrollElem = scrollableElement('html', 'body');
19 $('a[href^=#]').each(function() {
20 var thisPath = filterPath(this.pathname) || locationPath;
21 if ( locationPath == thisPath
22 && (location.hostname == this.hostname || !this.hostname)
23 && this.hash.replace(/#/,'') ) {
24 var $target = $(this.hash), target = this.hash;
26 var targetOffset = $target.offset().top;
27 $(this).click(function(event) {
28 event.preventDefault();
29 $(scrollElem).animate({scrollTop: targetOffset}, 400, function() {
30 location.hash = target;
37 // use the first element that is "scrollable"
38 function scrollableElement(els) {
39 for (var i = 0, argLength = arguments.length; i <argLength; i++) {
40 var el = arguments[i],
41 $scrollElement = $(el);
42 if ($scrollElement.scrollTop()> 0) {
45 $scrollElement.scrollTop(1);
46 var isScrollable = $scrollElement.scrollTop()> 0;
47 $scrollElement.scrollTop(0);
64 // fix sub nav on scroll
68 navHeight = $('.navbar').first().height(),
69 subnavHeight = $('.subnav').first().height(),
70 subnavTop = $('.subnav').length && $('.subnav').offset().top - navHeight,
71 marginTop = parseInt($body.css('margin-top'), 10);
76 $win.on('scroll', processScroll);
78 function processScroll() {
79 var i, scrollTop = $win.scrollTop();
81 if (scrollTop >= subnavTop && !isFixed) {
83 $nav.addClass('subnav-fixed');
84 $body.css('margin-top', marginTop + subnavHeight + 'px');
85 } else if (scrollTop <= subnavTop && isFixed) {
87 $nav.removeClass('subnav-fixed');
88 $body.css('margin-top', marginTop + 'px');