Passed
Push — 247-fix/delete-term-meta ( 3ce805...0c7c80 )
by Rajan
09:27
created

$(document).ready   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 41

Duplication

Lines 41
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
nc 1
nop 0
dl 41
loc 41
rs 8.896
c 1
b 0
f 0

1 Function

Rating   Name   Duplication   Size   Complexity  
B 37 37 1
1
/**
2
 * Add select2 functionality..
3
 */
4
 /*global ajaxurl*/
5 View Code Duplication
jQuery( document ).ready( function () {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
6
	
7
	jQuery( 'input[name=smbd_meta_term_taxonomy]' ).change(function(){
8
		jQuery( '.select2-terms' ).select2( {
9
			data: function(){
10
				return [];
11
			},
12
		} );
13
		jQuery( '.select2-terms' ).select2( {
14
			ajax: {
15
				url: ajaxurl,
16
				dataType: 'json',
17
				delay: 250,
18
				data: function ( params ) {
19
					return {
20
						q: params.term,
21
						taxonomy: jQuery('input[name=smbd_meta_term_taxonomy]:checked').val(),
22
						action: 'bd_load_taxonomy_term'
23
					};
24
				},
25
				processResults: function ( data ) {
26
					var options = [];
27
28
					if ( data ) {
29
						jQuery.each( data, function ( index, dataPair ) {
30
							options.push( { id: dataPair[ 0 ], text: dataPair[ 1 ] } );
31
						} );
32
					}
33
34
					return {
35
						results: options
36
					};
37
				},
38
				cache: true
39
			},
40
			minimumInputLength: 2, // the minimum of symbols to input before perform a search
41
			width: '300px'
42
		} );
43
	});
44
	
45
} );