menu-toggle sidebar

This commit is contained in:
Jana Deutschländer 2017-01-05 15:48:32 +01:00
commit 5939959969
3 changed files with 48 additions and 0 deletions

View file

@ -36,8 +36,46 @@
}
};
var sideMenu = function(){
var $menu = $('.tools').find('.toggle-menu');
try{
if($menu.length > 0){
var $toggler = $menu.find('h6'),
$submenu = $menu.find('nav > ul >li, nav > div');
if($toggler.length > 0 && $submenu.length > 0){
$toggler.addClass('closed');
$toggler.wrapInner('<a href="#toggleMenu" class="toggler"></a>');
$toggler.each(function( index ) {
$(this).on( "click", function(e) {
e.preventDefault();
var $this = $(this);
$this.toggleClass('closed');
$this.toggleClass('opened');
if($this.hasClass('opened')){
var $foc = $this.closest('li.level1').find('li.level2:first-child').find('a:first-child');
if($foc.length > 0){
$foc.focus();
}
}
});
});
//FIXME: store current nav state with local storage
}
}
}catch(err){
alert('err');
}
};
$(function(){
mainMenu();
sideMenu();
});
} )( jQuery, spc );