Add FieldDisplayManager.

Refactor admin field show/hide.
This commit is contained in:
Pedro Silva 2023-09-14 17:48:46 +01:00
parent d3a02e79c5
commit 0cddf83b9d
No known key found for this signature in database
GPG key ID: E2EE20C0669D24B3
13 changed files with 320 additions and 100 deletions

View file

@ -1,10 +1,24 @@
import FieldDisplayManager from "./common/FieldDisplayManager";
import moveWrappedElements from "./common/wrapped-elements";
document.addEventListener(
'DOMContentLoaded',
() => {
// Wait for current execution context to end.
setTimeout(function () {
moveWrappedElements();
}, 0);
// Initialize FieldDisplayManager.
const fieldDisplayManager = new FieldDisplayManager();
jQuery( '*[data-ppcp-display]' ).each( (index, el) => {
const rules = jQuery(el).data('ppcpDisplay');
for (const rule of rules) {
fieldDisplayManager.addRule(rule);
}
});
}
);