integrations-requirements.js
1.22 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
/*globals jQuery, ajaxurl */
jQuery(function ($) {
"use strict";
$('[data-js-callback="js-set-translation-editor"]').click(function () {
var enable_button = $(this);
var notice = enable_button.closest('.otgs-notice');
var nonce = notice.find('input[name="wpml_set_translation_editor_nonce"]').val();
var success = notice.find('.js-done');
var error = notice.find('.js-error');
$.ajax({
url: ajaxurl,
type: "POST",
data: {
action: 'wpml_set_translation_editor',
nonce: nonce
},
success: function (response) {
error.hide();
success.hide();
notice.removeClass('notice-error error notice-info info');
if (response.success) {
notice.addClass('notice-success');
notice.addClass('success');
enable_button.hide();
success.show();
setTimeout(function () {
notice.fadeOut('slow');
}, 2500);
} else {
notice.addClass('notice-error');
notice.addClass('error');
error.show();
if (null !== response.data) {
error.find('strong').text(response.data);
}
}
}
});
});
});