Skip to content
Snippets Groups Projects
Commit 327fbe02 authored by Michael Enz's avatar Michael Enz
Browse files

FXOLAT-480: fixed offcanvas, menu should always show when toggle is clicked

parent d46cd51c
No related branches found
No related tags found
No related merge requests found
...@@ -28,7 +28,6 @@ ...@@ -28,7 +28,6 @@
this.addExtraElements(); this.addExtraElements();
this.state = { this.state = {
rightVisible: false,
busy: false, busy: false,
brandW : 0, brandW : 0,
sitesW : 0, sitesW : 0,
...@@ -355,18 +354,19 @@ ...@@ -355,18 +354,19 @@
} }
Navbar.prototype.showRight = function() { Navbar.prototype.showRight = function() {
if (!this.state.rightVisible) { if (!this.isOffcanvasVisible() && !this.offcanvasTransitioning) {
this.offcanvasTransitioning = true;
var that = this; var that = this;
var box = $('#o_offcanvas_right'); var box = $('#o_offcanvas_right');
box.show().transition({ x: -that.state.offCanvasWidth}, function() { box.show().transition({ x: -that.state.offCanvasWidth}, function() {
that.offcanvasTransitioning = false;
$('body').addClass('o_offcanvas_right_visible'); $('body').addClass('o_offcanvas_right_visible');
that.state.rightVisible = true; // hide menu when clicking anywhere in content (timeout to pass the event in IE8/9 which hide the navbar)
var listener = $.proxy(that.hideRightOnClick, that);
setTimeout(function() {
$('html').on('click', listener);
}, 10);
} ); } );
// hide menu when clicking anywhere in content (timeout to pass the event in IE8/9 which hide the navbar)
var listener = $.proxy(this.hideRightOnClick, this);
setTimeout(function() {
$('html').on('click', listener);
}, 10);
} }
} }
Navbar.prototype.hideRightOnClick = function(e) { Navbar.prototype.hideRightOnClick = function(e) {
...@@ -375,26 +375,31 @@ ...@@ -375,26 +375,31 @@
} }
} }
Navbar.prototype.hideRight = function() { Navbar.prototype.hideRight = function() {
if (this.state.rightVisible) { if (this.isOffcanvasVisible() && !this.offcanvasTransitioning) {
this.offcanvasTransitioning = true;
// remove listener to hide menu
$('html').off('click', $.proxy(this.hideRight,this));
var that = this; var that = this;
var box = $('#o_offcanvas_right'); var box = $('#o_offcanvas_right');
box.transition({ x: that.state.offCanvasWidth}, function() { box.transition({ x: that.state.offCanvasWidth}, function() {
that.offcanvasTransitioning = false;
box.hide(); box.hide();
$('body').removeClass('o_offcanvas_right_visible'); $('body').removeClass('o_offcanvas_right_visible');
that.state.rightVisible = false;
} ); } );
// remove listener to hide menu
$('html').off('click', $.proxy(this.hideRight,this));
} }
} }
Navbar.prototype.toggleRight = function() { Navbar.prototype.toggleRight = function() {
if (this.state.rightVisible) { if (this.isOffcanvasVisible()) {
this.hideRight(); this.hideRight();
} else { } else {
this.showRight(); this.showRight();
} }
} }
Navbar.prototype.isOffcanvasVisible = function() {
return $('#o_offcanvas_right:visible').length;
}
Navbar.prototype.getSites = function() { Navbar.prototype.getSites = function() {
return $('#o_navbar_container .o_navbar_sites'); return $('#o_navbar_container .o_navbar_sites');
} }
......
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment