I'd like to programmatically (either with js or php, but I imagine it'd simpler with js) hide the dashboard admin menu using the same functionality that is already built in. All I want is, when the user click on a custom link in the dashboard the admin menu will collapse so I can more screen space. Does anyone knows how to do this? I've been search for a couple days and can only find how to remove the menu completely which is not what I want. I could do that with a custom js script, however I'd rather just add an additional event handler to the current js function that hides the menu. Thanks for the help.
We want to catch all clicks inside the admin menu. If we catch a click inside the admin menu, we have to check if the admin menu is already folded. Now we have to check if the unfold button (uncollapse button) was clicked. This is a bit tricky, because if the admin menu is folded, the unfold button has no class or id. It is simply a
Now put all together: If the admin menu is not folded AND the clicked element is not a div element AND the clicked element has a class, then we expect it was not the unfold button that was clicked and the menu should be folded.
In this case we add the class