Issues (54)

docs/js/jquery.smooth-scroll.js (2 issues)

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;
0 ignored issues
show
The variable $target seems to be never used. Consider removing it.
Loading history...
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;
0 ignored issues
show
The variable position seems to be never declared. Assigning variables without defining them first makes them global. If this was intended, consider making it explicit like using window.position.
Loading history...
24
25
                    $('html,body').animate({scrollTop: position}, 400, function() {
26
                        location.hash = target;
27
                    });
28
                });
29
            }
30
        }
31
    });
32
});
33