User:Canadabonk/common.js: Difference between revisions
Content deleted Content added
Canadabonk (talk | contribs) No edit summary |
Canadabonk (talk | contribs) No edit summary |
||
Line 27: | Line 27: | ||
}); |
}); |
||
hideOnClickOutside('.ct-toc', '.ct-stickytoc'); |
|||
} |
} |
||
function hideOnClickOutside( |
function hideOnClickOutside(container, hiddenitem) { |
||
window.onclick = function (event) { |
|||
const $target = $(event.target); |
const $target = $(event.target); |
||
if (!$target.closest( |
if (!$target.closest(container).length && $(hiddenitem).is(':visible')) { |
||
$( |
$(hiddenitem).fadeOut(200); |
||
} |
|||
}; |
|||
} |
|||
}; |
|||
const removeClickListener = () => { |
|||
document.removeEventListener('click', outsideClickListener); |
|||
}; |
|||
document.addEventListener('click', outsideClickListener); |
|||
} |
|||
}); |
}); |