Passed
Push — dev/6.0.0 ( 1c71e1...e60df2 )
by Sudar
09:05 queued 06:18
created

assets/js/src/delete-posts-by-post-type.js   A

Complexity

Total Complexity 5
Complexity/F 1.67

Size

Lines of Code 25
Function Count 3

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

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

1 Function

Rating   Name   Duplication   Size   Complexity  
A BulkWP.validatePostTypeSelect2 0 7 2
1
/* global BulkWP */
2
jQuery( document ).ready( function () {
3
	jQuery( '.select2-post' ).select2( {
4
		width: '300px',
5
		templateSelection: function (state) {
6
			if (!state.id) {
7
				return state.text;
8
			}
9
10
			var parentLabel = state.element.parentElement.label;
11
			var $state = jQuery(
12
				'<span>' + parentLabel + '-' + state.text + '</span>'
13
			);
14
15
			return $state;
16
		}
17
	});
18
});
19
20
BulkWP.validatePostTypeSelect2 = function(that) {
21
	if (null !== jQuery(that).parent().prev().children().find(".select2-post[multiple]").val()) {
22
		return true;
23
	} else {
24
		return false;
25
	}
26
};
27