misc-settings.js
2.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
/* global _SEARCHWP */
( function($) {
'use strict';
const app = {
/**
* Init.
*
* @since 4.3.0
*/
init: () => {
$( app.ready );
},
/**
* Document ready
*
* @since 4.3.0
*/
ready: () => {
app.events();
},
/**
* Page events.
*
* @since 4.3.0
*/
events: () => {
$( '#swp-wake-up-indexer-continue-btn' ).on('click', app.wakeUpIndexer );
},
wakeUpIndexer: function(e) {
e.preventDefault();
$(e.target).closest('.swp-modal').find('.swp-modal--close').click();
$('.swp-content-container button').attr('disabled','disabled');
$('#swp-wake-up-indexer-btn').addClass('swp-button--processing');
jQuery.post(ajaxurl, {
_ajax_nonce: _SEARCHWP.nonce,
action: _SEARCHWP.prefix + 'wake_indexer'
}, function(response) {
$('.swp-content-container button').removeAttr('disabled');
$('#swp-wake-up-indexer-btn').removeClass('swp-button--processing');
if (response.success) {
$('#swp-wake-up-indexer-btn').addClass('swp-button--completed');
setTimeout(
() => {
$('#swp-wake-up-indexer-btn').removeClass('swp-button--completed');
},
1500
);
} else {
console.log(response);
$('#swp-wake-up-indexer-btn').after('<span class="swp-error-msg swp-text-red swp-b ">Waking indexer FAILED. View console for more information.</span>');
setTimeout(
function () {
$('#swp-wake-up-indexer-btn').siblings('.swp-error-msg').remove();
},
3000
);
}
});
},
};
app.init();
window.searchwp = window.searchwp || {};
window.searchwp.AdminMiscSettingsPage = app;
}( jQuery ) );