| 1 |
/* global beyondwordsData, jQuery */ |
| 2 |
|
| 3 |
( function ( $ ) { |
| 4 |
'use strict'; |
| 5 |
|
| 6 |
$( document ).ready( function () { |
| 7 |
$( '#beyondwords_notice_review' ).on( |
| 8 |
'click', |
| 9 |
'.notice-dismiss', |
| 10 |
function ( event ) { |
| 11 |
event.preventDefault(); |
| 12 |
|
| 13 |
// eslint-disable-next-line max-len |
| 14 |
const endpoint = `${ beyondwordsData.root }beyondwords/v1/settings/notices/review/dismiss`; |
| 15 |
|
| 16 |
$.ajax( { |
| 17 |
url: endpoint, |
| 18 |
method: 'POST', |
| 19 |
// eslint-disable-next-line object-shorthand |
| 20 |
beforeSend: function ( xhr ) { |
| 21 |
xhr.setRequestHeader( |
| 22 |
'X-WP-Nonce', |
| 23 |
beyondwordsData.nonce |
| 24 |
); |
| 25 |
}, |
| 26 |
// eslint-disable-next-line object-shorthand |
| 27 |
success: function ( response ) { |
| 28 |
if ( response.success ) { |
| 29 |
$( '#beyondwords_notice_review' ).hide(); |
| 30 |
} else { |
| 31 |
// eslint-disable-next-line no-console |
| 32 |
console.error( |
| 33 |
'🔊 REST API Error dismissing notice', |
| 34 |
response |
| 35 |
); |
| 36 |
} |
| 37 |
}, |
| 38 |
// eslint-disable-next-line object-shorthand |
| 39 |
error: function ( error ) { |
| 40 |
// eslint-disable-next-line no-console |
| 41 |
console.error( '🔊 Error dismissing notice', error ); |
| 42 |
}, |
| 43 |
} ); |
| 44 |
} |
| 45 |
); |
| 46 |
} ); |
| 47 |
} )( jQuery ); |
| 48 |
|