More actions
No edit summary |
No edit summary |
||
Line 8: | Line 8: | ||
originalHandler.call(this, event); | originalHandler.call(this, event); | ||
}); | }); | ||
element.classList.add('FixCatTreeClick'); | |||
} | } | ||
} | } | ||
addOnLoadHandler(function() { | addOnLoadHandler(function() { | ||
const observer = new MutationObserver((mutations) => { | |||
mutations.forEach((mutation) => { | |||
const target = mutation.target; | |||
if ( | |||
mutation.attributeName === 'class' && | |||
target.classList.contains('CategoryTreeToggleHandlerAttached') && | |||
!target.classList.contains('FixCatTreeClick') | |||
) { | |||
attachModifiedClickHandler(target); | |||
} | |||
}); | |||
}); | |||
observer.observe(document.body, { | |||
attributes: true, | |||
attributeFilter: ['class'], | |||
subtree: true | |||
}); | }); | ||
}); | }); |
Revision as of 10:35, 30 October 2024
function attachModifiedClickHandler(element) {
const handlers = $._data(element, 'events')?.click;
if (handlers && handlers.length > 0) {
const originalHandler = handlers[0].handler;
$(element).off('click').on('click', function(event) {
event.stopPropagation();
originalHandler.call(this, event);
});
element.classList.add('FixCatTreeClick');
}
}
addOnLoadHandler(function() {
const observer = new MutationObserver((mutations) => {
mutations.forEach((mutation) => {
const target = mutation.target;
if (
mutation.attributeName === 'class' &&
target.classList.contains('CategoryTreeToggleHandlerAttached') &&
!target.classList.contains('FixCatTreeClick')
) {
attachModifiedClickHandler(target);
}
});
});
observer.observe(document.body, {
attributes: true,
attributeFilter: ['class'],
subtree: true
});
});