batch_operations/js/batch.js

37 строки
1016 B
JavaScript
Исходник Обычный вид История

2015-06-10 14:13:55 +00:00
jQuery( document ).ready( function($) {
2015-06-10 09:51:19 +00:00
var batch_progress = function ( data ) {
$( '.batch-progress-message' ).html( data['progress_message'] );
2015-06-10 14:13:55 +00:00
var percent = 0;
if ( 'undefined' != typeof data['percent'] ) {
percent = data['percent'];
}
$( '.batch-percent' ).html( percent + "%" );
$( '.batch-progress > span' ).animate({ width: percent + "%" }, 500);
2015-06-05 19:26:11 +00:00
};
2015-06-10 09:51:19 +00:00
function batch_process() {
2015-06-05 19:26:11 +00:00
$.post(
2015-06-10 14:13:55 +00:00
ajaxurl + '?action=batch_operations&id=' + batch_id,
function( data ) {
if ( 'finish' == data['do'] )
2015-06-05 19:26:11 +00:00
{
2015-06-10 09:51:19 +00:00
batch_progress( data );
2015-06-10 14:13:55 +00:00
$( '.batch-message' ).html( data['message'] ).delay( 1500 ).queue( function () {
$( location ).attr( 'href', successful_page );
$( this ).dequeue();
2015-06-05 19:26:11 +00:00
}
);
}
else
{
2015-06-10 14:13:55 +00:00
$( '.batch-message' ).html( data['message'] );
2015-06-10 09:51:19 +00:00
batch_progress( data );
2015-06-05 19:26:11 +00:00
batch_process()
}
}
);
}
batch_process();
});