Disable snapper on bigger screens and on public/login page
This commit is contained in:
parent
9063a25bb4
commit
584c47b433
|
@ -1132,40 +1132,59 @@ function initCore() {
|
||||||
|
|
||||||
setupMainMenu();
|
setupMainMenu();
|
||||||
|
|
||||||
|
// just add snapper for logged in users
|
||||||
|
if($('#body-login, #body-public').length === 0) {
|
||||||
|
|
||||||
// App sidebar on mobile
|
// App sidebar on mobile
|
||||||
var snapper = new Snap({
|
var snapper = new Snap({
|
||||||
element: document.getElementById('app-content'),
|
element: document.getElementById('app-content'),
|
||||||
disable: 'right',
|
disable: 'right',
|
||||||
maxPosition: 250
|
maxPosition: 250
|
||||||
});
|
});
|
||||||
$('#app-content').prepend('<div id="app-navigation-toggle" class="icon-menu" style="display:none;"></div>');
|
$('#app-content').prepend('<div id="app-navigation-toggle" class="icon-menu" style="display:none;"></div>');
|
||||||
$('#app-navigation-toggle').click(function(){
|
$('#app-navigation-toggle').click(function(){
|
||||||
if(snapper.state().state == 'left'){
|
if(snapper.state().state == 'left'){
|
||||||
|
snapper.close();
|
||||||
|
} else {
|
||||||
|
snapper.open('left');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
// close sidebar when switching navigation entry
|
||||||
|
var $appNavigation = $('#app-navigation');
|
||||||
|
$appNavigation.delegate('a', 'click', function(event) {
|
||||||
|
var $target = $(event.target);
|
||||||
|
// don't hide navigation when changing settings or adding things
|
||||||
|
if($target.is('.app-navigation-noclose') ||
|
||||||
|
$target.closest('.app-navigation-noclose').length) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if($target.is('.add-new') ||
|
||||||
|
$target.closest('.add-new').length) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if($target.is('#app-settings') ||
|
||||||
|
$target.closest('#app-settings').length) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
snapper.close();
|
snapper.close();
|
||||||
} else {
|
});
|
||||||
snapper.open('left');
|
|
||||||
}
|
var toggleSnapperOnSize = function() {
|
||||||
});
|
if($(window).width() > 768) {
|
||||||
// close sidebar when switching navigation entry
|
snapper.close();
|
||||||
var $appNavigation = $('#app-navigation');
|
snapper.disable();
|
||||||
$appNavigation.delegate('a', 'click', function(event) {
|
} else {
|
||||||
var $target = $(event.target);
|
snapper.enable();
|
||||||
// don't hide navigation when changing settings or adding things
|
}
|
||||||
if($target.is('.app-navigation-noclose') ||
|
};
|
||||||
$target.closest('.app-navigation-noclose').length) {
|
|
||||||
return;
|
$(window).resize(toggleSnapperOnSize);
|
||||||
}
|
|
||||||
if($target.is('.add-new') ||
|
// initial call
|
||||||
$target.closest('.add-new').length) {
|
toggleSnapperOnSize();
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
if($target.is('#app-settings') ||
|
|
||||||
$target.closest('#app-settings').length) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
snapper.close();
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$(document).ready(initCore);
|
$(document).ready(initCore);
|
||||||
|
|
Loading…
Reference in New Issue