assets/scripts/taxonomy.js   A
last analyzed

Complexity

Total Complexity 4
Complexity/F 1

Size

Lines of Code 52
Function Count 4

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 0
nc 1
dl 0
loc 52
rs 10
c 0
b 0
f 0
wmc 4
mnd 0
bc 4
fnc 4
bpm 1
cpm 1
noi 0

1 Function

Rating   Name   Duplication   Size   Complexity  
A taxonomy.js ➔ Taxonomy 0 48 1
1
import select2 from 'select2';
2
3
var Taxonomy = function(className) {
4
5
    /**
6
     * taxonomy variable is created to represent Taxonomy instance.
7
     */
8
    var taxonomy = this;
9
10
    /**
11
     * element variable is created to represent master element of the Taxonomy.
12
     */
13
    var element = $(className);
14
15
    /**
16
     * selectElement variable is created to represent select input of the Taxonomy.
17
     */
18
    var selectElement = element.find('.taxonomy-multiple-select');
19
20
    /** 
21
     * Initialize actions.
22
     */
23
    this._init = function() {
24
        /* Initialize multiple select with select2 library. */
25
        taxonomy._multipleSelect();
26
        
27
    }
28
29
    /**
30
     * Initialize multiple select with select2 library.
31
     */
32
    this._multipleSelect = function() {
33
34
        selectElement.select2({
35
            placeholder: 'Please choose your terms'
36
        });
37
38
    }
39
40
    /**
41
     * Delete the Taxonomy.
42
     */ 
43
    this.delete = function() {
44
        /* Remove the taxonomy element. */
45
        element.remove();
46
    }
47
48
    taxonomy._init();
49
50
}
51
52
export default Taxonomy;