Completed
Push — dev5 ( 76b71a...013a5b )
by Ron
11:53
created

resources/js/template_files/documentation.js   A

Complexity

Total Complexity 6
Complexity/F 1.2

Size

Lines of Code 24
Function Count 5

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
wmc 6
eloc 12
mnd 1
bc 1
fnc 5
dl 0
loc 24
rs 10
bpm 0.2
cpm 1.2
noi 1
c 0
b 0
f 0

1 Function

Rating   Name   Duplication   Size   Complexity  
A documentation.js ➔ offsetAnchor 0 6 4
1
(function($) {
2
  'use strict';
3
  $(function() {
4
    // The function actually applying the offset
5
    function offsetAnchor() {
6
        if (location.hash.length !== 0) {
7
            // window.scrollTo(window.scrollX, window.scrollY - 140);
8
            $("html").animate({ scrollTop: $(location.hash).offset().top - 160 }, 500);
9
        }
10
    }
11
    
12
    // Captures click events of all <a> elements with href starting with #
13
    $(document).on('click', 'a[href^="#"]', function(event) {
0 ignored issues
show
Unused Code introduced by
The parameter event is not used and could be removed.

This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.

Loading history...
14
        // Click events are captured before hashchanges. Timeout
15
        // causes offsetAnchor to be called after the page jump.
16
        window.setTimeout(function() {
17
        offsetAnchor();
18
        }, 0);
19
    });
20
    
21
    // Set the offset when entering page with hash present in the url
22
    window.setTimeout(offsetAnchor, 0);
23
    });
24
})(jQuery);