Backend Modul Worpress Import added
This commit is contained in:
1 parent
b08ea7a55f
commit
4ef3ad0026
10 files changed
+1259
-29
No files matched your search
@@ -0,0 +1,45 @@
|
||||
/**
|
||||
* Select-all for the WordPress import list.
|
||||
*
|
||||
* Lives in a module rather than in an onclick attribute: the backend enforces a
|
||||
* Content Security Policy that blocks inline event handlers, so the attribute
|
||||
* version simply did nothing.
|
||||
*
|
||||
* Also keeps the header box honest - it shows indeterminate while only some
|
||||
* rows are ticked, which matters on a list of a hundred posts.
|
||||
*/
|
||||
|
||||
function boxes() {
|
||||
return Array.from(document.querySelectorAll('[data-vitec-post]'));
|
||||
}
|
||||
|
||||
function sync(toggle) {
|
||||
const all = boxes();
|
||||
const checked = all.filter((box) => box.checked).length;
|
||||
toggle.checked = all.length > 0 && checked === all.length;
|
||||
toggle.indeterminate = checked > 0 && checked < all.length;
|
||||
}
|
||||
|
||||
function init() {
|
||||
const toggle = document.querySelector('[data-vitec-toggle-all]');
|
||||
if (toggle === null) {
|
||||
return;
|
||||
}
|
||||
|
||||
toggle.addEventListener('change', () => {
|
||||
const state = toggle.checked;
|
||||
boxes().forEach((box) => {
|
||||
box.checked = state;
|
||||
});
|
||||
toggle.indeterminate = false;
|
||||
});
|
||||
|
||||
boxes().forEach((box) => box.addEventListener('change', () => sync(toggle)));
|
||||
sync(toggle);
|
||||
}
|
||||
|
||||
if (document.readyState === 'loading') {
|
||||
document.addEventListener('DOMContentLoaded', init);
|
||||
} else {
|
||||
init();
|
||||
}
|
||||
Reference in new issue
Block a user