option: distraction_free
This commit is contained in:
parent
bc1a864dd1
commit
2bdd4b24b7
@ -110,7 +110,7 @@ var NoticeManager = (function ($, document) {
|
||||
/**
|
||||
* auto-open notices panel
|
||||
*/
|
||||
if (button.length) {
|
||||
if (button.length && ! options.distraction_free) {
|
||||
panel.toggle()
|
||||
button.addClass("screen-meta-active")
|
||||
screenMeta.open(panel, button)
|
||||
@ -121,7 +121,7 @@ var NoticeManager = (function ($, document) {
|
||||
* only auto-close if we have collected notices previously
|
||||
* only auto-close if no error messages
|
||||
*/
|
||||
if (options.auto_collapse) {
|
||||
if (options.auto_collapse && ! options.distraction_free) {
|
||||
wait(4000).then(() => {
|
||||
if (haveClosed && NoticeManager.getNoticesTopPriority() != 'error') {
|
||||
screenMeta.close(panel, button)
|
||||
@ -129,6 +129,11 @@ var NoticeManager = (function ($, document) {
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
if (options.distraction_free) {
|
||||
NoticeManager.addCounterWhenClosed()
|
||||
}
|
||||
|
||||
}) // end document.on.ready
|
||||
|
||||
// prevent jumpy scrollRestoration on reload page
|
||||
@ -158,6 +163,19 @@ var NoticeManager = (function ($, document) {
|
||||
return 'notice'
|
||||
},
|
||||
|
||||
/**
|
||||
* .filter(":visible") unreliable when closed
|
||||
*
|
||||
* @returns {string} top priority
|
||||
*/
|
||||
getNoticesTopPriorityWhenClosed: () => {
|
||||
if (notices.filter(selectors_error.join(", ")).length)
|
||||
return 'error'
|
||||
if (notices.filter(selectors_warning.join(", ")).length)
|
||||
return 'warning'
|
||||
return 'notice'
|
||||
},
|
||||
|
||||
/**
|
||||
* Collect notices into panel.
|
||||
* Remove dismiss-notices button.
|
||||
@ -194,6 +212,19 @@ var NoticeManager = (function ($, document) {
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* cannot rely on filter(:visible)
|
||||
*/
|
||||
addCounterWhenClosed: () => {
|
||||
if (!button.children('.plugin-count').length){
|
||||
button.append(
|
||||
$("<span/>").text(notices.length).attr({
|
||||
class: "plugin-count",
|
||||
}).addClass(NoticeManager.getNoticesTopPriorityWhenClosed())
|
||||
)
|
||||
}
|
||||
},
|
||||
|
||||
removeCounter: () => {
|
||||
button.children(".plugin-count").remove()
|
||||
},
|
||||
|
||||
@ -62,6 +62,12 @@ new PluginCore(
|
||||
'type' => 'checkbox',
|
||||
'description' => 'If auto-collect is enabled - Notices panel will stay open for a few seconds on page load, and then close automatically. Panel will not auto-collapse if it contains `error` level notices.',
|
||||
],
|
||||
[
|
||||
'id' => 'distraction_free',
|
||||
'title' => 'Distraction Free',
|
||||
'type' => 'checkbox',
|
||||
'description' => 'Notice Panel is closed on page load. Requires auto_collect.'
|
||||
],
|
||||
]
|
||||
]
|
||||
]
|
||||
|
||||
Loading…
Reference in New Issue
Block a user