Total Complexity | 11 |
Complexity/F | 1.22 |
Lines of Code | 68 |
Function Count | 9 |
Duplicated Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | /** |
||
5 | jQuery( document ).ready( function () { |
||
6 | |||
7 | jQuery( 'input[name=smbd_meta_term_taxonomy]' ).change(function(){ |
||
8 | jQuery( '.select2-terms' ).select2( { |
||
9 | ajax: { |
||
10 | url: ajaxurl, |
||
11 | dataType: 'json', |
||
12 | delay: 250, |
||
13 | data: function ( params ) { |
||
14 | return { |
||
15 | q: params.term, |
||
16 | taxonomy: jQuery('input[name=smbd_meta_term_taxonomy]:checked').val(), |
||
17 | action: 'bd_load_taxonomy_term' |
||
18 | }; |
||
19 | }, |
||
20 | processResults: function ( data ) { |
||
21 | var options = []; |
||
22 | |||
23 | if ( data ) { |
||
24 | jQuery.each( data, function ( index, dataPair ) { |
||
25 | options.push( { id: dataPair[ 0 ], text: dataPair[ 1 ] } ); |
||
26 | } ); |
||
27 | } |
||
28 | |||
29 | return { |
||
30 | results: options |
||
31 | }; |
||
32 | }, |
||
33 | cache: true |
||
34 | }, |
||
35 | minimumInputLength: 2, // the minimum of symbols to input before perform a search |
||
36 | width: '300px' |
||
37 | } ); |
||
38 | }); |
||
39 | |||
40 | jQuery( '.select2-terms' ).change(function(){ |
||
41 | jQuery( '.select2-term-meta' ).select2( { |
||
42 | ajax: { |
||
43 | url: ajaxurl, |
||
44 | dataType: 'json', |
||
45 | delay: 250, |
||
46 | data: function () { |
||
47 | return { |
||
48 | term_id: jQuery('.select2-terms').val(), |
||
49 | action: 'bd_load_taxonomy_term_meta' |
||
50 | }; |
||
51 | }, |
||
52 | processResults: function ( data ) { |
||
53 | var options = []; |
||
54 | |||
55 | if ( data ) { |
||
56 | jQuery.each( data, function ( index, dataPair ) { |
||
57 | options.push( { id: dataPair[ 0 ], text: dataPair[ 0 ] } ); |
||
58 | } ); |
||
59 | } |
||
60 | |||
61 | return { |
||
62 | results: options |
||
63 | }; |
||
64 | }, |
||
65 | cache: true |
||
66 | }, |
||
67 | minimumInputLength: 2, // the minimum of symbols to input before perform a search |
||
68 | width: '300px' |
||
69 | } ); |
||
70 | }); |
||
71 | |||
72 | } ); |