Test Failed
Push — master ( 9811b7...5b4ca1 )
by Chad
16:14 queued 01:44
created

doc/build/_static/js/theme.js   B

Complexity

Total Complexity 39
Complexity/F 1.7

Size

Lines of Code 153
Function Count 23

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 39
dl 0
loc 153
rs 8.2857
c 1
b 0
f 0
cc 0
nc 64
mnd 3
bc 31
fnc 23
bpm 1.3478
cpm 1.6956
noi 7
1
require=(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({"sphinx-rtd-theme":[function(require,module,exports){
0 ignored issues
show
Comprehensibility introduced by
Usage of the sequence operator is discouraged, since it may lead to obfuscated code.

The sequence or comma operator allows the inclusion of multiple expressions where only is permitted. The result of the sequence is the value of the last expression.

This operator is most often used in for statements.

Used in another places it can make code hard to read, especially when people do not realize it even exists as a seperate operator.

This check looks for usage of the sequence operator in locations where it is not necessary and could be replaced by a series of expressions or statements.

var a,b,c;

a = 1, b = 1,  c= 3;

could just as well be written as:

var a,b,c;

a = 1;
b = 1;
c = 3;

To learn more about the sequence operator, please refer to the MDN.

Loading history...
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
2
var jQuery = (typeof(window) != 'undefined') ? window.jQuery : require('jquery');
3
4
// Sphinx theme nav state
5
function ThemeNav () {
6
7
    var nav = {
8
        navBar: null,
9
        win: null,
10
        winScroll: false,
11
        winResize: false,
12
        linkScroll: false,
13
        winPosition: 0,
14
        winHeight: null,
15
        docHeight: null,
16
        isRunning: null
17
    };
18
19
    nav.enable = function () {
20
        var self = this;
21
22
        jQuery(function ($) {
23
            self.init($);
24
25
            self.reset();
26
            self.win.on('hashchange', self.reset);
27
28
            // Set scroll monitor
29
            self.win.on('scroll', function () {
30
                if (!self.linkScroll) {
31
                    self.winScroll = true;
32
                }
33
            });
34
            setInterval(function () { if (self.winScroll) self.onScroll(); }, 25);
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
35
36
            // Set resize monitor
37
            self.win.on('resize', function () {
38
                self.winResize = true;
39
            });
40
            setInterval(function () { if (self.winResize) self.onResize(); }, 25);
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
41
            self.onResize();
42
        });
43
    };
44
45
    nav.init = function ($) {
46
        var doc = $(document),
0 ignored issues
show
Unused Code introduced by
The variable doc seems to be never used. Consider removing it.
Loading history...
47
            self = this;
48
49
        this.navBar = $('div.wy-side-scroll:first');
50
        this.win = $(window);
51
52
        // Set up javascript UX bits
53
        $(document)
54
            // Shift nav in mobile when clicking the menu.
55
            .on('click', "[data-toggle='wy-nav-top']", function() {
56
                $("[data-toggle='wy-nav-shift']").toggleClass("shift");
57
                $("[data-toggle='rst-versions']").toggleClass("shift");
58
            })
59
60
            // Nav menu link click operations
61
            .on('click', ".wy-menu-vertical .current ul li a", function() {
62
                var target = $(this);
63
                // Close menu when you click a link.
64
                $("[data-toggle='wy-nav-shift']").removeClass("shift");
65
                $("[data-toggle='rst-versions']").toggleClass("shift");
66
                // Handle dynamic display of l3 and l4 nav lists
67
                self.toggleCurrent(target);
68
                self.hashChange();
69
            })
70
            .on('click', "[data-toggle='rst-current-version']", function() {
71
                $("[data-toggle='rst-versions']").toggleClass("shift-up");
72
            })
73
74
        // Make tables responsive
75
        $("table.docutils:not(.field-list)")
76
            .wrap("<div class='wy-table-responsive'></div>");
77
78
        // Add expand links to all parents of nested ul
79
        $('.wy-menu-vertical ul').not('.simple').siblings('a').each(function () {
80
            var link = $(this);
81
                expand = $('<span class="toctree-expand"></span>');
0 ignored issues
show
Bug introduced by
The variable expand 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.expand.
Loading history...
82
            expand.on('click', function (ev) {
83
                self.toggleCurrent(link);
84
                ev.stopPropagation();
85
                return false;
86
            });
87
            link.prepend(expand);
88
        });
89
    };
90
91
    nav.reset = function () {
92
        // Get anchor from URL and open up nested nav
93
        var anchor = encodeURI(window.location.hash);
94
        if (anchor) {
95
            try {
96
                var link = $('.wy-menu-vertical')
97
                    .find('[href="' + anchor + '"]');
98
                $('.wy-menu-vertical li.toctree-l1 li.current')
99
                    .removeClass('current');
100
                link.closest('li.toctree-l2').addClass('current');
101
                link.closest('li.toctree-l3').addClass('current');
102
                link.closest('li.toctree-l4').addClass('current');
103
            }
104
            catch (err) {
105
                console.log("Error expanding nav for anchor", err);
0 ignored issues
show
Debugging Code introduced by
console.log looks like debug code. Are you sure you do not want to remove it?
Loading history...
106
            }
107
        }
108
    };
109
110
    nav.onScroll = function () {
111
        this.winScroll = false;
112
        var newWinPosition = this.win.scrollTop(),
113
            winBottom = newWinPosition + this.winHeight,
114
            navPosition = this.navBar.scrollTop(),
115
            newNavPosition = navPosition + (newWinPosition - this.winPosition);
116
        if (newWinPosition < 0 || winBottom > this.docHeight) {
117
            return;
118
        }
119
        this.navBar.scrollTop(newNavPosition);
120
        this.winPosition = newWinPosition;
121
    };
122
123
    nav.onResize = function () {
124
        this.winResize = false;
125
        this.winHeight = this.win.height();
126
        this.docHeight = $(document).height();
127
    };
128
129
    nav.hashChange = function () {
130
        this.linkScroll = true;
131
        this.win.one('hashchange', function () {
132
            this.linkScroll = false;
133
        });
134
    };
135
136
    nav.toggleCurrent = function (elem) {
137
        var parent_li = elem.closest('li');
138
        parent_li.siblings('li.current').removeClass('current');
139
        parent_li.siblings().find('li.current').removeClass('current');
140
        parent_li.find('> ul li.current').removeClass('current');
141
        parent_li.toggleClass('current');
142
    }
143
144
    return nav;
145
};
146
147
module.exports.ThemeNav = ThemeNav();
148
149
if (typeof(window) != 'undefined') {
150
    window.SphinxRtdTheme = { StickyNav: module.exports.ThemeNav };
151
}
152
153
},{"jquery":"jquery"}]},{},["sphinx-rtd-theme"]);
154