| 1 |
( function( $ ) { |
| 2 |
'use strict'; |
| 3 |
|
| 4 |
$( function() { |
| 5 |
|
| 6 |
/* |
| 7 |
* AJAX Reset cache |
| 8 |
*/ |
| 9 |
$( document ).on( 'click dblclick', 'a[href*="action=powerkit_reset_cache"]', function( e ) { |
| 10 |
var $this = this; |
| 11 |
$.ajax( { |
| 12 |
type: 'POST', |
| 13 |
url: window.pk_connect.ajax_url + '?action=powerkit_reset_cache', |
| 14 |
data: { |
| 15 |
page: $( $this ).attr( 'href' ).split( 'page=' ).pop().split( '&' ).shift(), |
| 16 |
}, |
| 17 |
beforeSend: function() { |
| 18 |
$( $this ).siblings( '.spinner, .status' ).remove(); |
| 19 |
|
| 20 |
$( $this ).after( '<span class="spinner is-active"></span>' ); |
| 21 |
}, |
| 22 |
success: function( data ) { |
| 23 |
$( $this ).after( '<span class="status dashicons dashicons-yes"></span>' ); |
| 24 |
}, |
| 25 |
error: function() { |
| 26 |
$( $this ).after( '<span class="status dashicons dashicons-no-alt"></span>' ); |
| 27 |
}, |
| 28 |
complete: function() { |
| 29 |
$( $this ).siblings( '.spinner' ).remove(); |
| 30 |
|
| 31 |
setTimeout( function() { |
| 32 |
$( $this ).siblings( '.status' ).fadeOut(); |
| 33 |
}, 2000 ); |
| 34 |
} |
| 35 |
} ); |
| 36 |
|
| 37 |
// Refresh customizer. |
| 38 |
if ( $( 'body' ).hasClass( 'wp-customizer' ) ) { |
| 39 |
wp.customize.previewer.refresh(); |
| 40 |
} |
| 41 |
|
| 42 |
return false; |
| 43 |
} ); |
| 44 |
|
| 45 |
} ); |
| 46 |
|
| 47 |
} )( jQuery ); |