You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1 line
2.0 KiB
JavaScript

"use strict";var WPFormsAdminNotifications=window.WPFormsAdminNotifications||function(t){var i={$notifications:t("#wpforms-notifications"),$nextButton:t("#wpforms-notifications .navigation .next"),$prevButton:t("#wpforms-notifications .navigation .prev"),$adminBarCounter:t("#wp-admin-bar-wpforms-menu .wpforms-menu-notification-counter"),$adminBarMenuItem:t("#wp-admin-bar-wpforms-notifications")},a={init:function(){t(a.ready)},ready:function(){a.updateNavigation(),a.events()},events:function(){i.$notifications.on("click",".dismiss",a.dismiss).on("click",".next",a.navNext).on("click",".prev",a.navPrev)},dismiss:function(e){var n,s;0!==i.$currentMessage.length&&(1<(s=parseInt(i.$adminBarCounter.text(),10))?i.$adminBarCounter.html(--s):(i.$adminBarCounter.remove(),i.$adminBarMenuItem.remove()),s=i.$nextMessage.length<1?i.$prevMessage:i.$nextMessage,n=i.$currentMessage.data("message-id"),0===s.length?i.$notifications.remove():(i.$currentMessage.remove(),s.addClass("current"),a.updateNavigation()),s={action:"wpforms_notification_dismiss",nonce:wpforms_admin.nonce,id:n},t.post(wpforms_admin.ajax_url,s,function(e){e.success||WPFormsAdmin.debug(e)}).fail(function(e,n,s){WPFormsAdmin.debug(e.responseText)}))},navNext:function(e){i.$nextButton.hasClass("disabled")||(i.$currentMessage.removeClass("current"),i.$nextMessage.addClass("current"),a.updateNavigation())},navPrev:function(e){i.$prevButton.hasClass("disabled")||(i.$currentMessage.removeClass("current"),i.$prevMessage.addClass("current"),a.updateNavigation())},updateNavigation:function(){i.$currentMessage=i.$notifications.find(".wpforms-notifications-message.current"),i.$nextMessage=i.$currentMessage.next(".wpforms-notifications-message"),i.$prevMessage=i.$currentMessage.prev(".wpforms-notifications-message"),0===i.$nextMessage.length?i.$nextButton.addClass("disabled"):i.$nextButton.removeClass("disabled"),0===i.$prevMessage.length?i.$prevButton.addClass("disabled"):i.$prevButton.removeClass("disabled")}};return a}((document,window,jQuery));WPFormsAdminNotifications.init();