Cleanup js clicky stuff a bit more

Change-Id: I5c4d6da26ca1c6b92c4aeabd47421567c3adc673
isekai
Isarra 6 years ago
parent 93e2ce0cdc
commit 46bbcd9a0c

@ -7,22 +7,20 @@ $( function () {
/** /**
* Desktop menu click-toggling * Desktop menu click-toggling
*
* We're not even checking if it's desktop because the classes in play have no effect
* on mobile regardless... this may break things at some point, though.
*/ */
$( function () { $( function () {
// sidebar-chunk only applies to desktop-small, but the toggles are hidden at // sidebar-chunk only applies to desktop-small, but the toggles are hidden at
// other resolutions regardless and the css overrides any visible effects. So // other resolutions regardless and the css overrides any visible effects.
// whatever.
var dropdowns = '#personal, #p-variants-desktop, .sidebar-chunk'; var dropdowns = '#personal, #p-variants-desktop, .sidebar-chunk';
/** /**
* Close all dropdowns * Close all dropdowns
*/ */
function closeOpen() { function closeOpen() {
$( dropdowns ).each( function () { $( dropdowns ).removeClass( 'dropdown-active' );
if ( $( this ).hasClass( 'dropdown-active' ) ) {
$( this ).removeClass( 'dropdown-active' );
}
} );
} }
/** /**
@ -40,7 +38,7 @@ $( function () {
$( this ).addClass( 'dropdown-active' ); $( this ).addClass( 'dropdown-active' );
} }
} ); } );
$( document ).click( function ( e ) { $( document ).on( 'click', function ( e ) {
if ( $( e.target ).closest( dropdowns ).length > 0 ) { if ( $( e.target ).closest( dropdowns ).length > 0 ) {
// Clicked inside an open menu; don't close anything // Clicked inside an open menu; don't close anything
} else { } else {

Loading…
Cancel
Save