Total Complexity | 5 |
Complexity/F | 1.67 |
Lines of Code | 22 |
Function Count | 3 |
Duplicated Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
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 |