Quick-fix mobile menu

Will be reworked asap.
This commit is contained in:
Eric Lippmann 2015-12-21 14:06:42 +01:00
parent 95879dd26f
commit 887a688781
1 changed files with 46 additions and 22 deletions

View File

@ -525,6 +525,24 @@
$('a.close-toggle').show(); $('a.close-toggle').show();
}, },
toggleMobileMenu: function(e) {
var $sidebar = $('#sidebar');
var $target = $(e.target);
var href = $target.attr('href');
if (href) {
if (href !== '#') {
$sidebar.removeClass('expanded');
}
} else if (! $target.is('input')) {
$sidebar.toggleClass('expanded');
}
$('#search').keypress(function(e) {
if (e.which === 13) {
$sidebar.removeClass('expanded');
}
});
},
fixControls: function ($parent) { fixControls: function ($parent) {
var self = this; var self = this;
if ($('#layout').hasClass('fullscreen-layout')) { if ($('#layout').hasClass('fullscreen-layout')) {
@ -537,36 +555,42 @@
$('#header').css({height: 'auto'}); $('#header').css({height: 'auto'});
if ($('#layout').hasClass('minimal-layout')) { if ($('#layout').hasClass('minimal-layout')) {
if (! this.mobileMenu) { if (! this.mobileMenu) {
$('#header').css({top: $('#sidebar').height() + 'px'}); $('#header-logo').css({
display: 'none'
});
$('#header').css({top: $('#sidebar').outerHeight() + 'px'});
$('#main').css({ $('#main').css({
top: $('#header').height() + $('#sidebar').height() top: $('#header').height() + $('#sidebar').outerHeight(),
zIndex: 1
}); });
$('#sidebar').css({ $('#sidebar')
zIndex: 2 .css({
}).on('click', function (e) { top: 0,
var $sidebar = $('#sidebar'); zIndex: 2
var $target = $(e.target); })
var href = $target.attr('href'); .on('click', this.toggleMobileMenu)
if (href) { .prepend(
if (href !== '#') { '<i id="mobile-menu-toggle" class="icon-menu" style="vertical-align: middle;"></i>'
$sidebar.removeClass('expanded'); )
} .css({
} else if (! $target.is('input')) { paddingBottom: 32
$sidebar.toggleClass('expanded');
}
$('#search').keypress(function(e) {
if (e.which === 13) {
$sidebar.removeClass('expanded');
}
}); });
}).prepend('<i class="icon-menu" style="vertical-align: middle;"></i>').css({
paddingBottom: 32
});
this.mobileMenu = true; this.mobileMenu = true;
} }
} else { } else {
$('#main').css({top: $('#header').css('height')}); $('#main').css({top: $('#header').css('height')});
$('#sidebar').css({top: $('#header').height() + 'px'}); $('#sidebar').css({top: $('#header').height() + 'px'});
if (this.mobileMenu) {
$('#header-logo').css({
display: 'block'
});
$('#sidebar').off('click', this.toggleMobileMenu);
$('#header').css({
top: 0
});
$('#mobile-menu-toggle').remove();
this.mobileMenu = false;
}
} }
$('#header').css({height: $('#header').height() + 'px'}); $('#header').css({height: $('#header').height() + 'px'});
$('#inner-layout').css({top: $('#header').css('height')}); $('#inner-layout').css({top: $('#header').css('height')});