RA-#27 back button on menu opened
This commit is contained in:
@@ -117,9 +117,31 @@ $(document).ready(function(){
|
||||
//Adding Background for Gradient
|
||||
if(!$('.menu-hider').length){$('#page').append('<div class="menu-hider"><div>');}
|
||||
|
||||
var menuOpened = function() {
|
||||
log('Menu opened', history.state);
|
||||
if ((history.state === null) || (history.state.menu !== 'opened')) {
|
||||
history.pushState({ menu: 'opened' }, '');
|
||||
log('state pushed');
|
||||
}
|
||||
}
|
||||
var menuClosed = function() {
|
||||
log('Menu closed', history.state);
|
||||
if ((history.state !== null) && (history.state.menu === 'opened')) {
|
||||
history.back();
|
||||
log('history.back')
|
||||
}
|
||||
}
|
||||
|
||||
/*Menu Extender Function*/
|
||||
$.fn.showMenu = function() {$(this).addClass('menu-active'); $('#footer-bar').addClass('footer-menu-hidden');setTimeout(function(){$('.menu-hider').addClass('menu-active');},250);$('body').addClass('modal-open')};
|
||||
$.fn.hideMenu = function() {$(this).removeClass('menu-active'); $('#footer-bar').removeClass('footer-menu-hidden');$('.menu-hider').removeClass('menu-active menu-active-clear');$('body').removeClass('modal-open')};
|
||||
$.fn.showMenu = function() {$(this).addClass('menu-active'); $('#footer-bar').addClass('footer-menu-hidden');setTimeout(function(){$('.menu-hider').addClass('menu-active');},250);$('body').addClass('modal-open');menuOpened();};
|
||||
$.fn.hideMenu = function() {$(this).removeClass('menu-active'); $('#footer-bar').removeClass('footer-menu-hidden');$('.menu-hider').removeClass('menu-active menu-active-clear');$('body').removeClass('modal-open');menuClosed();};
|
||||
|
||||
window.onpopstate = function(event) {
|
||||
log('popstate event fired. location:' + document.location + ', state:' + JSON.stringify(event.state));
|
||||
if ((event.state === null) || (event.state.menu !== 'opened')) {
|
||||
$('.menu').hideMenu();
|
||||
}
|
||||
};
|
||||
|
||||
//Add your programatically triggered menus here
|
||||
|
||||
@@ -180,14 +202,9 @@ $(document).ready(function(){
|
||||
if(menuID.hasClass('menu-box-right')){headerAndContent.css("transform", "translateX(-100%)");}
|
||||
}
|
||||
menuActivate();
|
||||
menuOpened();
|
||||
});
|
||||
|
||||
var autoActivateMenu = $('[data-auto-activate]');
|
||||
if (autoActivateMenu.length){
|
||||
autoActivateMenu.addClass('menu-active');
|
||||
menuHider.addClass('menu-active');
|
||||
}
|
||||
|
||||
//Allows clicking even if menu is loaded externally.
|
||||
$('body').removeClass('modal-open');
|
||||
$('.menu-hider, .close-menu, .menu-close').on('click', function(){
|
||||
@@ -197,6 +214,7 @@ $(document).ready(function(){
|
||||
menuHider.css('transform','translate(0,0)');
|
||||
$('#footer-bar').removeClass('footer-menu-hidden');
|
||||
$('body').removeClass('modal-open');
|
||||
menuClosed();
|
||||
return false;
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user