migration-required.js
1.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
/*globals jQuery, ajaxurl */
jQuery(function () {
'use strict';
var notice = jQuery('[data-id="icl-20-migration"][data-group="icl-20-migration"]');
var confirm;
var startButton;
var updateButton = function () {
if (confirm.prop('checked')) {
startButton.removeClass('disabled');
startButton.on('click', userConfirms);
} else {
startButton.addClass('disabled');
startButton.off('click');
}
};
var userConfirms = function (e) {
e.preventDefault();
e.stopPropagation();
if (confirm.prop('checked')) {
jQuery.ajax(ajaxurl, {
method: 'POST',
data: {
action: confirm.data('action'),
nonce: confirm.data('nonce')
},
complete: function () {
location.reload();
}
});
}
};
if (notice.length) {
confirm = notice.find('#wpml-icl20-migrate-confirm');
startButton = notice.find('.notice-action.button-secondary.notice-action-button-secondary');
if (confirm.length && startButton.length) {
updateButton();
confirm.on('click', updateButton);
}
}
});