web/assets/js/chosen.js   A
last analyzed

Complexity

Total Complexity 5
Complexity/F 5

Size

Lines of Code 23
Function Count 1

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
dl 0
loc 23
rs 10
c 1
b 0
f 0
cc 0
nc 4
mnd 1
bc 3
fnc 1
bpm 3
cpm 5
noi 0

1 Function

Rating   Name   Duplication   Size   Complexity  
B $.fn.chosen 0 22 5
1
//chosen workaround to fix behavior with HTML 5 required tag
2
$.fn.oldChosen = $.fn.chosen
3
$.fn.chosen = function (options) {
4
    var select = $(this)
5
        , is_creating_chosen = !!options
6
7
    if (is_creating_chosen && select.css('position') === 'absolute') {
8
        // if we are creating a chosen and the select already has the appropriate styles added
9
        // we remove those (so that the select hasn't got a crazy width), then create the chosen
10
        // then we re-add them later
11
        select.removeAttr('style')
12
    }
13
14
    var ret = select.oldChosen(options)
15
16
    // only act if the select has display: none, otherwise chosen is unsupported (iPhone, etc)
17
    if (is_creating_chosen && select.css('display') === 'none') {
18
        // https://github.com/harvesthq/chosen/issues/515#issuecomment-33214050
19
        // only do this if we are initializing chosen (no params, or object params) not calling a method
20
        select.attr('style', 'display:visible; position:absolute; clip:rect(0,0,0,0)');
21
        select.attr('tabindex', -1);
22
    }
23
    return ret
24
};