Add ".plugin-count" counter to notice panel tag when closed
This commit is contained in:
parent
28ac8f941b
commit
296051fac1
@ -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;
|
||||
}
|
||||
@ -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(
|
||||
$("<span/>").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
|
||||
|
||||
Loading…
Reference in New Issue
Block a user