Passed
Push — master ( 09cd0a...77f626 )
by Swen
01:13
created

➔ $(ꞌ.localized-fields-widget.tab labelꞌ).click   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
cc 2
nc 2
nop 1
1
(function($) {
2
    var syncTabs = function(lang) {
3
        $('.localized-fields-widget.tab label:contains("'+lang+'")').each(function(){
4
            $(this).parents('.localized-fields-widget[role="tabs"]').find('.localized-fields-widget.tab').removeClass('active');
5
            $(this).parents('.localized-fields-widget.tab').addClass('active');
6
            $(this).parents('.localized-fields-widget[role="tabs"]').children('.localized-fields-widget [role="tabpanel"]').hide();
7
            $('#'+$(this).attr('for')).show();
8
        });
9
    }
10
11
    $(function (){
12
        $('.localized-fields-widget [role="tabpanel"]').hide();
13
        // set first tab as active
14
        $('.localized-fields-widget[role="tabs"]').each(function () {
15
            $(this).find('.localized-fields-widget.tab:first').addClass('active');
16
            $('#'+$(this).find('.localized-fields-widget.tab:first label').attr('for')).show();
17
        });
18
        // try set active last selected tab
19
        if (window.sessionStorage) {
20
            var lang = window.sessionStorage.getItem('localized-field-lang');
21
            if (lang) {
22
                syncTabs(lang);
23
            }
24
        }
25
26
        $('.localized-fields-widget.tab label').click(function(event) {
27
            event.preventDefault();
28
            syncTabs(this.innerText);
29
            if (window.sessionStorage) {
30
                window.sessionStorage.setItem('localized-field-lang', this.innerText);
31
            }
32
            return false;
33
        });
34
    });
35
})(django.jQuery)
0 ignored issues
show
Bug introduced by
The variable django seems to be never declared. If this is a global, consider adding a /** global: django */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
36