1 line
1.8 KiB
JavaScript
1 line
1.8 KiB
JavaScript
"use strict";var WPMailSMTPAdminNotifications=window.WPMailSMTPAdminNotifications||function(e,t){var a={$notifications:t("#wp-mail-smtp-notifications"),$nextButton:t("#wp-mail-smtp-notifications .navigation .next"),$prevButton:t("#wp-mail-smtp-notifications .navigation .prev"),$adminBarCounter:t("#wp-admin-bar-wp-mail-smtp-menu .wp-mail-smtp-admin-bar-menu-notification-counter")},s={init:function(){t(e).ready(s.ready)},ready:function(){s.updateNavigation(),s.events()},events:function(){a.$notifications.on("click",".dismiss",s.dismiss).on("click",".next",s.navNext).on("click",".prev",s.navPrev)},dismiss:function(e){if(0!==a.$currentMessage.length){var n={action:"wp_mail_smtp_notification_dismiss",nonce:wp_mail_smtp.nonce,id:a.$currentMessage.data("message-id")};t.post(ajaxurl,n,function(e){if(e.success){var n=parseInt(a.$adminBarCounter.text(),10);1<n?(--n,a.$adminBarCounter.html("<span>"+n+"</span>")):a.$adminBarCounter.remove();var t=a.$nextMessage.length<1?a.$prevMessage:a.$nextMessage;0===t.length?a.$notifications.remove():(a.$currentMessage.remove(),t.addClass("current"),s.updateNavigation())}})}},navNext:function(e){a.$nextButton.hasClass("disabled")||(a.$currentMessage.removeClass("current"),a.$nextMessage.addClass("current"),s.updateNavigation())},navPrev:function(e){a.$prevButton.hasClass("disabled")||(a.$currentMessage.removeClass("current"),a.$prevMessage.addClass("current"),s.updateNavigation())},updateNavigation:function(){a.$currentMessage=a.$notifications.find(".message.current"),a.$nextMessage=a.$currentMessage.next(".message"),a.$prevMessage=a.$currentMessage.prev(".message"),0===a.$nextMessage.length?a.$nextButton.addClass("disabled"):a.$nextButton.removeClass("disabled"),0===a.$prevMessage.length?a.$prevButton.addClass("disabled"):a.$prevButton.removeClass("disabled")}};return s}(document,(window,jQuery));WPMailSMTPAdminNotifications.init(); |