Passed
Push — master ( 33081a...0dd98d )
by Paul
05:28
created

+/scripts/admin/ajax.js   A

Complexity

Total Complexity 5
Complexity/F 1.67

Size

Lines of Code 22
Function Count 3

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

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

1 Function

Rating   Name   Duplication   Size   Complexity  
A GLSR.Ajax 0 17 2
1
/** global: GLSR, jQuery */
2
;(function( x ) {
3
4
	'use strict';
5
6
	GLSR.Ajax = function( ev, request, callback ) {
7
		ev.preventDefault();
8
		var el = x( ev.target );
9
		if( el.is( ':disabled' ))return;
10
		request.nonce = request.nonce || el.closest( 'form' ).find( '#_wpnonce' ).val();
11
		var data = {
12
			action: GLSR.action,
13
			request: request,
14
		};
15
		el.prop( 'disabled', true );
16
		x.post( GLSR.ajaxurl, data, function( response ) {
17
			if( typeof callback === 'function' ) {
18
				callback( response );
19
			}
20
			el.prop( 'disabled', false );
21
		});
22
	};
23
})( jQuery );
24