um-admin-global.js
1.76 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
jQuery(document).ready(function() {
jQuery(document.body).on('click', '#um_add_review_love', function (e) {
jQuery(this).parents('#um_start_review_notice').hide();
jQuery('.um_hidden_notice[data-key="love"]').show();
});
jQuery(document.body).on('click', '#um_add_review_good', function (e) {
jQuery(this).parents('#um_start_review_notice').hide();
jQuery('.um_hidden_notice[data-key="good"]').show();
});
jQuery(document.body).on('click', '#um_add_review_bad', function (e) {
jQuery(this).parents('#um_start_review_notice').hide();
jQuery('.um_hidden_notice[data-key="bad"]').show();
});
jQuery(document.body).on('click', '.um_review_link', function (e) {
jQuery(this).parents('.um-admin-notice').find( '.notice-dismiss' ).trigger('click');
});
jQuery(document.body).on('click', '.um_secondary_dimiss', function (e) {
jQuery(this).parents('.um-admin-notice').find( '.notice-dismiss' ).trigger('click');
});
jQuery(document.body).on( 'click', '.um-admin-notice.is-dismissible .notice-dismiss', function(e) {
var notice_key = jQuery(this).parents('.um-admin-notice').data('key');
wp.ajax.send( 'um_dismiss_notice', {
data: {
key: notice_key,
nonce: um_admin_scripts.nonce
},
success: function( data ) {
return true;
},
error: function( data ) {
um_admin_dismiss_notice_fallback( notice_key );
return false;
}
});
});
});
/**
* Dismiss fallback of ajax request
*/
function um_admin_dismiss_notice_fallback( notice_key ) {
var href_index = "";
if ( window.location.href.indexOf("?") > -1 ) {
href_index = window.location.href + "&";
} else {
href_index = window.location.href + "?";
}
window.location.href = href_index + "um_dismiss_notice=" + notice_key + "&um_admin_nonce=" + um_admin_scripts.nonce;
}