admin_bar_menu.js
2 years ago
flowbite.min.js
2 years ago
gravity_forms.js
3 years ago
math_captcha.js
3 years ago
metabox.js
2 years ago
nitropackUI.js
2 years ago
np_notices.js
2 years ago
np_safemode.js
2 years ago
np_settings.js
2 years ago
popper.min.js
4 years ago
widgets_ajax.js
3 years ago
np_notices.js
61 lines
| 1 | (function() { |
| 2 | document.addEventListener("click", function(e) { |
| 3 | if (e.target.matches(".notice.is-dismissible[data-dismissible-id] button.notice-dismiss")) { |
| 4 | let noticeId = e.target.closest(".notice.is-dismissible[data-dismissible-id]").dataset.dismissibleId; |
| 5 | document.cookie = "dismissed_notice_" + noticeId + "=1;path=/;max-age=" + (86400 * 30) + "; secure"; |
| 6 | } |
| 7 | }, true); |
| 8 | |
| 9 | |
| 10 | document.addEventListener("click", function(e) { |
| 11 | if (e.target.matches(".rml_btn")) { |
| 12 | var xhr = new XMLHttpRequest(); |
| 13 | var data = new FormData(); |
| 14 | data.append('action', 'nitropack_rml_notification'); |
| 15 | data.append('nonce', nitropack_notices_vars.nonce); |
| 16 | data.append('notification_id', e.target.dataset.notification_id); |
| 17 | data.append('notification_end', e.target.dataset.notification_end); |
| 18 | |
| 19 | xhr.onreadystatechange = function() { |
| 20 | if (xhr.readyState === XMLHttpRequest.DONE) { |
| 21 | if (xhr.status === 200) { |
| 22 | var response = JSON.parse(xhr.responseText); |
| 23 | if (response.transient_status === true) { |
| 24 | var notifications_count = document.getElementById('notifications-list').querySelectorAll('li').length; |
| 25 | |
| 26 | if ( notifications_count === 1 ) { |
| 27 | document.getElementById('notifications').parentNode.parentNode.remove(); |
| 28 | } else { |
| 29 | e.target.parentNode.parentNode.remove(); |
| 30 | } |
| 31 | |
| 32 | } |
| 33 | } else { |
| 34 | console.log('Error: ' + xhr.status); |
| 35 | } |
| 36 | } |
| 37 | }; |
| 38 | xhr.open('POST', ajaxurl); |
| 39 | xhr.send(data); |
| 40 | } |
| 41 | }, true); |
| 42 | |
| 43 | })(); |
| 44 | |
| 45 | var loadDismissibleNotices = function() { |
| 46 | var $ = jQuery; |
| 47 | |
| 48 | $(".notice.is-dismissible").each(function() { |
| 49 | var b = $(this) |
| 50 | , c = $('<button type="button" class="notice-dismiss"><span class="screen-reader-text"></span></button>'); |
| 51 | c.on("click.wp-dismiss-notice", function($) { |
| 52 | $.preventDefault(), |
| 53 | b.fadeTo(100, 0, function() { |
| 54 | b.slideUp(100, function() { |
| 55 | b.remove() |
| 56 | }) |
| 57 | }) |
| 58 | }), |
| 59 | b.append(c) |
| 60 | }); |
| 61 | } |