| 1 |
/** |
| 2 |
* Easy Invoice Promotion Banner JavaScript |
| 3 |
*/ |
| 4 |
jQuery(document).ready(function($) { |
| 5 |
|
| 6 |
// Handle promotion banner dismissal |
| 7 |
$('#easy-invoice-promotion-dismiss').on('click', function(e) { |
| 8 |
e.preventDefault(); |
| 9 |
|
| 10 |
$.ajax({ |
| 11 |
url: easyInvoicePromotion.ajaxUrl, |
| 12 |
type: 'POST', |
| 13 |
data: { |
| 14 |
action: 'easy_invoice_dismiss_promotion', |
| 15 |
nonce: easyInvoicePromotion.nonce |
| 16 |
}, |
| 17 |
success: function(response) { |
| 18 |
if (response.success) { |
| 19 |
// Hide the notice with a smooth fade out |
| 20 |
$('#easy-invoice-promotion-notice').fadeOut(300, function() { |
| 21 |
$(this).remove(); |
| 22 |
}); |
| 23 |
} |
| 24 |
}, |
| 25 |
error: function() { |
| 26 |
// If AJAX fails, still hide the notice |
| 27 |
$('#easy-invoice-promotion-notice').fadeOut(300, function() { |
| 28 |
$(this).remove(); |
| 29 |
}); |
| 30 |
} |
| 31 |
}); |
| 32 |
}); |
| 33 |
|
| 34 |
// Override the default WordPress notice dismiss handler for our promotion notice |
| 35 |
$(document).on('click', '#easy-invoice-promotion-notice .notice-dismiss', function(e) { |
| 36 |
e.preventDefault(); |
| 37 |
|
| 38 |
$.ajax({ |
| 39 |
url: easyInvoicePromotion.ajaxUrl, |
| 40 |
type: 'POST', |
| 41 |
data: { |
| 42 |
action: 'easy_invoice_dismiss_promotion', |
| 43 |
nonce: easyInvoicePromotion.nonce |
| 44 |
}, |
| 45 |
success: function(response) { |
| 46 |
if (response.success) { |
| 47 |
$('#easy-invoice-promotion-notice').fadeOut(300, function() { |
| 48 |
$(this).remove(); |
| 49 |
}); |
| 50 |
} |
| 51 |
}, |
| 52 |
error: function() { |
| 53 |
$('#easy-invoice-promotion-notice').fadeOut(300, function() { |
| 54 |
$(this).remove(); |
| 55 |
}); |
| 56 |
} |
| 57 |
}); |
| 58 |
}); |
| 59 |
}); |
| 60 |
|