Completed
Pull Request — dev/6.0.0 (#296)
by Rajan
13:51 queued 10:53
created

assets/js/src/bulk-delete-post-type.js   A

Complexity

Total Complexity 3
Complexity/F 1.5

Size

Lines of Code 17
Function Count 2

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

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

1 Function

Rating   Name   Duplication   Size   Complexity  
A bulk-delete-post-type.js ➔ formatLabel 0 10 2
1
jQuery( document ).ready( function () {
2
	jQuery( '.select2-post' ).select2( {
3
		width: '300px',
4
		templateSelection: formatLabel
5
	} );
6
});
7
8
function formatLabel (state) {
9
  if (!state.id) {
10
    return state.text;
11
  }
12
  var parentLabel = state.element.parentElement.label;
13
  var $state = jQuery(
14
  	    '<span>' + parentLabel + '-' + state.text + '</span>'
15
  );
16
  return $state;
17
}