More actions
No edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
function attachModifiedClickHandler(element) { | function attachModifiedClickHandler(element) { | ||
const handlers = | const handlers = jQuery._data(element, 'events')?.click; | ||
if (handlers && handlers.length > 0) { | if (handlers && handlers.length > 0) { | ||
const originalHandler = handlers[0].handler; | const originalHandler = handlers[0].handler; |
Revision as of 10:37, 30 October 2024
function attachModifiedClickHandler(element) {
const handlers = jQuery._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
});
});