js - re-factor/improve functionality
This commit is contained in:
parent
ba26708c9f
commit
57c54c756a
@ -28,7 +28,9 @@ var NoticeManager = (function ($, document) {
|
|||||||
|
|
||||||
dismissNoticesButton.on("click", () => {
|
dismissNoticesButton.on("click", () => {
|
||||||
screenMeta.close(panel, button);
|
screenMeta.close(panel, button);
|
||||||
|
if (! haveClosed){
|
||||||
NoticeManager.collectNotices();
|
NoticeManager.collectNotices();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
//original wp focus on click function
|
//original wp focus on click function
|
||||||
@ -40,7 +42,6 @@ var NoticeManager = (function ($, document) {
|
|||||||
// cannot convert to arrow function - uses this
|
// cannot convert to arrow function - uses this
|
||||||
// could use event.target instead
|
// could use event.target instead
|
||||||
button.on("click", function () {
|
button.on("click", function () {
|
||||||
haveClosed = true;
|
|
||||||
if ($(this).hasClass("screen-meta-active")) {
|
if ($(this).hasClass("screen-meta-active")) {
|
||||||
// $(window).scrollTop(true);
|
// $(window).scrollTop(true);
|
||||||
} else {
|
} else {
|
||||||
@ -69,9 +70,11 @@ var NoticeManager = (function ($, document) {
|
|||||||
/**
|
/**
|
||||||
* Remove panel if there are no notices on this page
|
* Remove panel if there are no notices on this page
|
||||||
*/
|
*/
|
||||||
|
if (options.screen_panel) {
|
||||||
NoticeManager.maybeRemoveNoticesPanel();
|
NoticeManager.maybeRemoveNoticesPanel();
|
||||||
|
}
|
||||||
|
|
||||||
if (options.auto_collect) {
|
if (options.screen_panel && options.auto_collect) {
|
||||||
NoticeManager.collectNotices();
|
NoticeManager.collectNotices();
|
||||||
} else {
|
} else {
|
||||||
/**
|
/**
|
||||||
@ -95,11 +98,11 @@ var NoticeManager = (function ($, document) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* auto-close notices panel after short delay
|
* auto-close notices panel after short delay
|
||||||
* only auto-close if we have not interacted (opened/closed) with panel previously
|
* only auto-close if we have collected notices previously
|
||||||
*/
|
*/
|
||||||
if (options.auto_collapse) {
|
if (options.auto_collapse) {
|
||||||
wait(4000).then(() => {
|
wait(4000).then(() => {
|
||||||
if (!haveClosed) {
|
if (haveClosed) {
|
||||||
screenMeta.close(panel, button);
|
screenMeta.close(panel, button);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -133,6 +136,8 @@ var NoticeManager = (function ($, document) {
|
|||||||
notices.appendTo(".notice_container").eq(0);
|
notices.appendTo(".notice_container").eq(0);
|
||||||
$(".notice_container").removeClass("empty"); // .empty removes padding
|
$(".notice_container").removeClass("empty"); // .empty removes padding
|
||||||
|
|
||||||
|
haveClosed = true; // initial collection has occured.
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* When dismissible notices are dismissed, check if any notices are left on page.
|
* When dismissible notices are dismissed, check if any notices are left on page.
|
||||||
* If no notices are left - remove Notice Panel entirely
|
* If no notices are left - remove Notice Panel entirely
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user