Subversion Repositories Applications.framework

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
464 jpm 1
$(document).ready(function() {
2
    function filterPath(string) {
3
        return string
4
            .replace(/^\//,'')
5
            .replace(/(index|default).[a-zA-Z]{3,4}$/,'')
6
            .replace(/\/$/,'');
7
    }
8
    var locationPath = filterPath(location.pathname);
9
 
10
    $('a[href*=#]').each(function() {
11
        var thisPath = filterPath(this.pathname) || locationPath;
12
        if (  locationPath == thisPath
13
            && (location.hostname == this.hostname || !this.hostname)
14
            && this.hash.replace(/#/,'') ) {
15
            var $target = $(this.hash), target = this.hash;
16
            if (target) {
17
                $(this).click(function(event) {
18
                    if (!$(this.hash).offset()) {
19
                        return;
20
                    }
21
 
22
                    event.preventDefault();
23
                    position = $(this.hash).offset().top;
24
 
25
                    $('html,body').animate({scrollTop: position}, 400, function() {
26
                        location.hash = target;
27
                    });
28
                });
29
            }
30
        }
31
    });
32
});