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: | ||
}); |
}); |
||
$(document).click(hideOnClickOutside('.ct-stickytoc')); |
|||
window.onclick = function(event) { |
|||
⚫ | |||
stickytoc.fadeOut(200); |
|||
} |
|||
}; |
|||
} |
} |
||
function hideOnClickOutside(selector) { |
|||
const outsideClickListener = (event) => { |
|||
const $target = $(event.target); |
|||
⚫ | |||
$(selector).fadeOut(200); |
|||
removeClickListener(); |
|||
} |
|||
}; |
|||
const removeClickListener = () => { |
|||
document.removeEventListener('click', outsideClickListener); |
|||
}; |
|||
document.addEventListener('click', outsideClickListener); |
|||
} |
|||
}); |
}); |