diff --git a/css/admin_notices.css b/css/admin_notices.css index cc182c5..4fab8f7 100644 --- a/css/admin_notices.css +++ b/css/admin_notices.css @@ -49,4 +49,29 @@ .notices-above-title .wrap > div.notice, .notices-above-title .wrap > div.update-nag{ display: none; +} + +#meta-link-notices .plugin-count { + display: inline-block; + /* vertical-align: top; */ + box-sizing: border-box; + margin: 1px 0 -1px 2px; + padding: 0 5px; + min-width: 18px; + height: 18px; + border-radius: 9px; + background-color: #72aee6; + color: #fff; + font-size: 11px; + line-height: 1.6; + text-align: center; + z-index: 26; +} + +#meta-link-notices .plugin-count.warning { + background-color: #dba617; +} + +#meta-link-notices .plugin-count.error { + background-color: #d63638; } \ No newline at end of file diff --git a/js/notice_manager_panel.js b/js/notice_manager_panel.js index e074dba..f5d01d5 100644 --- a/js/notice_manager_panel.js +++ b/js/notice_manager_panel.js @@ -31,6 +31,7 @@ var NoticeManager = (function ($, document) { if (! haveClosed){ NoticeManager.collectNotices(); } + NoticeManager.addCounter(); }); //original wp focus on click function @@ -43,8 +44,14 @@ var NoticeManager = (function ($, document) { // could use event.target instead button.on("click", function () { if ($(this).hasClass("screen-meta-active")) { + if (haveClosed) { + NoticeManager.addCounter(); + } + // $(window).scrollTop(true); } else { + NoticeManager.removeCounter(); + // wait (500).then(function(){ //still jumpy sometimes - but scrolls to correct position 400 ~ 600 // $(window).scrollTop(true); // }); @@ -100,6 +107,7 @@ var NoticeManager = (function ($, document) { wait(4000).then(() => { if (haveClosed && NoticeManager.getNoticesTopPriority() != 'error') { screenMeta.close(panel, button); + NoticeManager.addCounter(); } }); } @@ -158,6 +166,20 @@ var NoticeManager = (function ($, document) { ); }, + addCounter: () => { + if (!button.children('.plugin-count').length){ + button.append( + $("").text(notices.length).attr({ + class: "plugin-count", + }).addClass(NoticeManager.getNoticesTopPriority()) + ); + } + }, + + removeCounter: () => { + button.children(".plugin-count").remove(); + }, + /** * Remove meta-links-notices if no notices on page * Remove screen-meta-links wrapper if no panels on page