admin_bar_menu.js
3 years ago
bootstrap.bundle.min.js
4 years ago
bootstrap.min.js
6 years ago
gravity_forms.js
3 years ago
math_captcha.js
3 years ago
metabox.js
6 years ago
np_notices.js
3 years ago
np_safemode.js
4 years ago
overlay.js
6 years ago
popper.min.js
4 years ago
widgets_ajax.js
3 years ago
np_notices.js
60 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('notification_id', e.target.dataset.notification_id); |
| 16 | data.append('notification_end', e.target.dataset.notification_end); |
| 17 | |
| 18 | xhr.onreadystatechange = function() { |
| 19 | if (xhr.readyState === XMLHttpRequest.DONE) { |
| 20 | if (xhr.status === 200) { |
| 21 | var response = JSON.parse(xhr.responseText); |
| 22 | if (response.transient_status === true) { |
| 23 | var notifications_count = document.getElementById('notifications-list').querySelectorAll('li').length; |
| 24 | |
| 25 | if ( notifications_count === 1 ) { |
| 26 | document.getElementById('notifications').parentNode.parentNode.remove(); |
| 27 | } else { |
| 28 | e.target.parentNode.parentNode.remove(); |
| 29 | } |
| 30 | |
| 31 | } |
| 32 | } else { |
| 33 | console.log('Error: ' + xhr.status); |
| 34 | } |
| 35 | } |
| 36 | }; |
| 37 | xhr.open('POST', ajaxurl); |
| 38 | xhr.send(data); |
| 39 | } |
| 40 | }, true); |
| 41 | |
| 42 | })(); |
| 43 | |
| 44 | var loadDismissibleNotices = function() { |
| 45 | var $ = jQuery; |
| 46 | |
| 47 | $(".notice.is-dismissible").each(function() { |
| 48 | var b = $(this) |
| 49 | , c = $('<button type="button" class="notice-dismiss"><span class="screen-reader-text"></span></button>'); |
| 50 | c.on("click.wp-dismiss-notice", function($) { |
| 51 | $.preventDefault(), |
| 52 | b.fadeTo(100, 0, function() { |
| 53 | b.slideUp(100, function() { |
| 54 | b.remove() |
| 55 | }) |
| 56 | }) |
| 57 | }), |
| 58 | b.append(c) |
| 59 | }); |
| 60 | } |