js - remove all semi-colons
This commit is contained in:
parent
1cbb0a5aea
commit
bffd39afe5
@ -3,58 +3,58 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
var NoticeManager = (function ($, document) {
|
var NoticeManager = (function ($, document) {
|
||||||
let options = window.notice_manager_options;
|
let options = window.notice_manager_options
|
||||||
|
|
||||||
let selectors_notice = [
|
let selectors_notice = [
|
||||||
"div.notice",
|
"div.notice",
|
||||||
"div.updated",
|
"div.updated",
|
||||||
];
|
]
|
||||||
|
|
||||||
let selectors_warning = [
|
let selectors_warning = [
|
||||||
"div.notice-warning",
|
"div.notice-warning",
|
||||||
"div.update-nag",
|
"div.update-nag",
|
||||||
];
|
]
|
||||||
|
|
||||||
let selectors_error = [
|
let selectors_error = [
|
||||||
"div.error",
|
"div.error",
|
||||||
"div.notice-error",
|
"div.notice-error",
|
||||||
];
|
]
|
||||||
|
|
||||||
let selectors_all = selectors_notice.concat(selectors_warning, selectors_error);
|
let selectors_all = selectors_notice.concat(selectors_warning, selectors_error)
|
||||||
|
|
||||||
// wait function used with autoCollapse
|
// wait function used with autoCollapse
|
||||||
let wait = function (ms) {
|
let wait = function (ms) {
|
||||||
var dfd = $.Deferred();
|
var dfd = $.Deferred()
|
||||||
setTimeout(dfd.resolve, ms); //callback, timeout till callback
|
setTimeout(dfd.resolve, ms) //callback, timeout till callback
|
||||||
return dfd.promise();
|
return dfd.promise()
|
||||||
};
|
}
|
||||||
|
|
||||||
let notices;
|
let notices
|
||||||
|
|
||||||
let button;
|
let button
|
||||||
let panel;
|
let panel
|
||||||
let haveClosed; // set to true on first close/collect
|
let haveClosed // set to true on first close/collect
|
||||||
let dismissNoticesButton;
|
let dismissNoticesButton
|
||||||
|
|
||||||
// bootstrap
|
// bootstrap
|
||||||
// some of these need to run BEFORE document.ready - don't know why really
|
// some of these need to run BEFORE document.ready - don't know why really
|
||||||
button = $("#meta-link-notices");
|
button = $("#meta-link-notices")
|
||||||
panel = $("#meta-link-notices-wrap");
|
panel = $("#meta-link-notices-wrap")
|
||||||
haveClosed = false;
|
haveClosed = false
|
||||||
dismissNoticesButton = $("#meta-link-notices-wrap button.notice-dismiss");
|
dismissNoticesButton = $("#meta-link-notices-wrap button.notice-dismiss")
|
||||||
|
|
||||||
dismissNoticesButton.on("click", () => {
|
dismissNoticesButton.on("click", () => {
|
||||||
screenMeta.close(panel, button);
|
screenMeta.close(panel, button)
|
||||||
if (! haveClosed){
|
if (! haveClosed){
|
||||||
NoticeManager.collectNotices();
|
NoticeManager.collectNotices()
|
||||||
}
|
}
|
||||||
NoticeManager.addCounter();
|
NoticeManager.addCounter()
|
||||||
});
|
})
|
||||||
|
|
||||||
//original wp focus on click function
|
//original wp focus on click function
|
||||||
button.on("focus.scroll-into-view", (e) => {
|
button.on("focus.scroll-into-view", (e) => {
|
||||||
if (e.target.scrollIntoView) e.target.scrollIntoView(false);
|
if (e.target.scrollIntoView) e.target.scrollIntoView(false)
|
||||||
});
|
})
|
||||||
|
|
||||||
// scroll page to top when closing notice panel
|
// scroll page to top when closing notice panel
|
||||||
// function used to work with $(this)
|
// function used to work with $(this)
|
||||||
@ -63,47 +63,47 @@ var NoticeManager = (function ($, document) {
|
|||||||
button.on("click", (e) => {
|
button.on("click", (e) => {
|
||||||
if ($(e.target).hasClass("screen-meta-active")) {
|
if ($(e.target).hasClass("screen-meta-active")) {
|
||||||
if (haveClosed) {
|
if (haveClosed) {
|
||||||
NoticeManager.addCounter();
|
NoticeManager.addCounter()
|
||||||
}
|
}
|
||||||
|
|
||||||
// $(window).scrollTop(true);
|
// $(window).scrollTop(true)
|
||||||
} else {
|
} else {
|
||||||
NoticeManager.removeCounter();
|
NoticeManager.removeCounter()
|
||||||
|
|
||||||
// wait (500).then(function(){ //still jumpy sometimes - but scrolls to correct position 400 ~ 600
|
// wait (500).then(function(){ //still jumpy sometimes - but scrolls to correct position 400 ~ 600
|
||||||
// $(window).scrollTop(true);
|
// $(window).scrollTop(true)
|
||||||
// });
|
// })
|
||||||
}
|
}
|
||||||
});
|
})
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* document.on.ready
|
* document.on.ready
|
||||||
*/
|
*/
|
||||||
$(() => {
|
$(() => {
|
||||||
|
|
||||||
console.log("NoticeManager.on.ready");
|
console.log("NoticeManager.on.ready")
|
||||||
console.log("options");
|
console.log("options")
|
||||||
console.log(options);
|
console.log(options)
|
||||||
|
|
||||||
// bootstrap notices
|
// bootstrap notices
|
||||||
// get all notices that are not explicitly marked as `.inline` or `.below-h2`
|
// get all notices that are not explicitly marked as `.inline` or `.below-h2`
|
||||||
// we add .update-nag.inline for WordPress Update notice
|
// we add .update-nag.inline for WordPress Update notice
|
||||||
notices = $( selectors_all.join(', ') )
|
notices = $( selectors_all.join(', ') )
|
||||||
.not(".inline, .below-h2")
|
.not(".inline, .below-h2")
|
||||||
.add("div.update-nag");
|
.add("div.update-nag")
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove panel if there are no notices on this page
|
* Remove panel if there are no notices on this page
|
||||||
*/
|
*/
|
||||||
if (options.screen_panel) {
|
if (options.screen_panel) {
|
||||||
NoticeManager.maybeRemoveNoticesPanel();
|
NoticeManager.maybeRemoveNoticesPanel()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (options.screen_panel && options.auto_collect) {
|
if (options.screen_panel && options.auto_collect) {
|
||||||
NoticeManager.collectNotices();
|
NoticeManager.collectNotices()
|
||||||
} else {
|
} else {
|
||||||
if (options.above_title) {
|
if (options.above_title) {
|
||||||
NoticeManager.moveAboveTitle();
|
NoticeManager.moveAboveTitle()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -111,9 +111,9 @@ var NoticeManager = (function ($, document) {
|
|||||||
* auto-open notices panel
|
* auto-open notices panel
|
||||||
*/
|
*/
|
||||||
if (button.length) {
|
if (button.length) {
|
||||||
panel.toggle();
|
panel.toggle()
|
||||||
button.addClass("screen-meta-active");
|
button.addClass("screen-meta-active")
|
||||||
screenMeta.open(panel, button);
|
screenMeta.open(panel, button)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -124,17 +124,17 @@ var NoticeManager = (function ($, document) {
|
|||||||
if (options.auto_collapse) {
|
if (options.auto_collapse) {
|
||||||
wait(4000).then(() => {
|
wait(4000).then(() => {
|
||||||
if (haveClosed && NoticeManager.getNoticesTopPriority() != 'error') {
|
if (haveClosed && NoticeManager.getNoticesTopPriority() != 'error') {
|
||||||
screenMeta.close(panel, button);
|
screenMeta.close(panel, button)
|
||||||
NoticeManager.addCounter();
|
NoticeManager.addCounter()
|
||||||
}
|
}
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
}); // end document.on.ready
|
}) // end document.on.ready
|
||||||
|
|
||||||
// prevent jumpy scrollRestoration on reload page
|
// prevent jumpy scrollRestoration on reload page
|
||||||
// fixed below on 'beforeunload'
|
// fixed below on 'beforeunload'
|
||||||
// if (history.scrollRestoration) {
|
// if (history.scrollRestoration) {
|
||||||
// history.scrollRestoration = 'manual';
|
// history.scrollRestoration = 'manual'
|
||||||
//}
|
//}
|
||||||
/**
|
/**
|
||||||
* Set history.scrollTop to prevent jump on page refresh when scrollRestoration = auto
|
* Set history.scrollTop to prevent jump on page refresh when scrollRestoration = auto
|
||||||
@ -144,18 +144,18 @@ var NoticeManager = (function ($, document) {
|
|||||||
{ scrollTop: document.body.scrollTop },
|
{ scrollTop: document.body.scrollTop },
|
||||||
document.title,
|
document.title,
|
||||||
document.location.pathname
|
document.location.pathname
|
||||||
);
|
)
|
||||||
});
|
})
|
||||||
|
|
||||||
return {
|
return {
|
||||||
getNotices: () => notices,
|
getNotices: () => notices,
|
||||||
|
|
||||||
getNoticesTopPriority: () => {
|
getNoticesTopPriority: () => {
|
||||||
if (notices.filter(":visible").filter(selectors_error.join(", ")).length)
|
if (notices.filter(":visible").filter(selectors_error.join(", ")).length)
|
||||||
return 'error';
|
return 'error'
|
||||||
if (notices.filter(":visible").filter(selectors_warning.join(", ")).length)
|
if (notices.filter(":visible").filter(selectors_warning.join(", ")).length)
|
||||||
return 'warning';
|
return 'warning'
|
||||||
return 'notice';
|
return 'notice'
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -163,10 +163,10 @@ var NoticeManager = (function ($, document) {
|
|||||||
* Remove dismiss-notices button.
|
* Remove dismiss-notices button.
|
||||||
*/
|
*/
|
||||||
collectNotices: () => {
|
collectNotices: () => {
|
||||||
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 occurred.
|
haveClosed = true // initial collection has occurred.
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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.
|
||||||
@ -178,10 +178,10 @@ var NoticeManager = (function ($, document) {
|
|||||||
() => {
|
() => {
|
||||||
notices = panel
|
notices = panel
|
||||||
.find(selectors_all.join(", "))
|
.find(selectors_all.join(", "))
|
||||||
.filter(":visible");
|
.filter(":visible")
|
||||||
NoticeManager.maybeRemoveNoticesPanel();
|
NoticeManager.maybeRemoveNoticesPanel()
|
||||||
}
|
}
|
||||||
);
|
)
|
||||||
},
|
},
|
||||||
|
|
||||||
addCounter: () => {
|
addCounter: () => {
|
||||||
@ -190,12 +190,12 @@ var NoticeManager = (function ($, document) {
|
|||||||
$("<span/>").text(notices.filter(":visible").length).attr({
|
$("<span/>").text(notices.filter(":visible").length).attr({
|
||||||
class: "plugin-count",
|
class: "plugin-count",
|
||||||
}).addClass(NoticeManager.getNoticesTopPriority())
|
}).addClass(NoticeManager.getNoticesTopPriority())
|
||||||
);
|
)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
removeCounter: () => {
|
removeCounter: () => {
|
||||||
button.children(".plugin-count").remove();
|
button.children(".plugin-count").remove()
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -204,13 +204,13 @@ var NoticeManager = (function ($, document) {
|
|||||||
*/
|
*/
|
||||||
maybeRemoveNoticesPanel: () => {
|
maybeRemoveNoticesPanel: () => {
|
||||||
if (!notices.length) {
|
if (!notices.length) {
|
||||||
screenMeta.close(panel, button);
|
screenMeta.close(panel, button)
|
||||||
|
|
||||||
$("#meta-link-notices-link-wrap").detach();
|
$("#meta-link-notices-link-wrap").detach()
|
||||||
$("#meta-link-notices-wrap").detach();
|
$("#meta-link-notices-wrap").detach()
|
||||||
|
|
||||||
if (!$("#screen-meta-links").children().length)
|
if (!$("#screen-meta-links").children().length)
|
||||||
$("#screen-meta-links").detach();
|
$("#screen-meta-links").detach()
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -220,7 +220,7 @@ var NoticeManager = (function ($, document) {
|
|||||||
* I HATE it when WordPress moves notices below title.
|
* I HATE it when WordPress moves notices below title.
|
||||||
*/
|
*/
|
||||||
moveAboveTitle: () => {
|
moveAboveTitle: () => {
|
||||||
notices.insertBefore(".wrap:first");
|
notices.insertBefore(".wrap:first")
|
||||||
},
|
},
|
||||||
};
|
}
|
||||||
}(jQuery,document) )
|
}(jQuery,document) )
|
||||||
Loading…
Reference in New Issue
Block a user