Create Hook Javascript
Summary
generate class all
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// Hook registry
const builderHooks = {
// Modal
onSave: [],
onModalSaveImage: [],
double: [],
triple: []
};
// Register hook function
function registerClickHook(type, callback) {
if (builderHooks[type]) {
builderHooks[type].push(callback);
}
}
function addHooks(type) {
builderHooks[type].forEach(hook => hook());
}
registerClickHook('onSave', function () {
initBuilderContent(); // Reload the builder iframe to reflect changes
});
registerClickHook('onShowModalEditSection', function () {
hljs.highlightAll();
});
registerClickHook('onModalSaveImage', function () {
initBuilderContent(); // Reload the builder iframe to reflect changes
});