Skip to content

Commit

Permalink
Update sidebarEffects.js
Browse files Browse the repository at this point in the history
Added reset menu option. Simply add the id closeMenu to an item within the st-menu container.
  • Loading branch information
Braunson committed Oct 8, 2013
1 parent 8b96f99 commit 84ae317
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion js/sidebarEffects.js
Expand Up @@ -28,6 +28,7 @@
function init() {

var container = document.getElementById( 'st-container' ),
reset = document.getElementById( 'closeMenu' ),
buttons = Array.prototype.slice.call( document.querySelectorAll( '#st-trigger-effects > button' ) ),
// event type (if mobile use touch events)
eventtype = mobilecheck() ? 'touchstart' : 'click',
Expand All @@ -39,6 +40,12 @@
resetMenu();
document.removeEventListener( eventtype, bodyClickFn );
}
},
resetClickFn = function(evt) {
if (evt.target == reset) {
resetMenu();
document.removeEventListener(eventtype, bodyClickFn);
}
};

buttons.forEach( function( el, i ) {
Expand All @@ -53,11 +60,12 @@
classie.add( container, 'st-menu-open' );
}, 25 );
document.addEventListener( eventtype, bodyClickFn );
document.addEventListener( eventtype, resetClickFn );
});
} );

}

init();

})();
})();

0 comments on commit 84ae317

Please sign in to comment.