[Libreoffice-commits] online.git: loleaflet/src

Ashod Nakashian (via logerrit) logerrit at kemper.freedesktop.org
Thu Dec 12 08:12:25 UTC 2019


 loleaflet/src/control/Control.MobileWizard.js |   21 ++++++++++++++-------
 loleaflet/src/control/Control.Toolbar.js      |   14 +++++++++++++-
 loleaflet/src/layer/tile/TileLayer.js         |    6 +++---
 loleaflet/src/map/Map.js                      |    6 +++++-
 4 files changed, 35 insertions(+), 12 deletions(-)

New commits:
commit f11946bf40ab48317acbdc8af7495688f9a28979
Author:     Ashod Nakashian <ashod.nakashian at collabora.co.uk>
AuthorDate: Thu Dec 12 01:32:48 2019 -0500
Commit:     Jan Holesovsky <kendy at collabora.com>
CommitDate: Thu Dec 12 09:11:25 2019 +0100

    leaflet: improved sidebar wizard handling
    
    Now the Hamburger works and the sidebar updates
    are more accurate.
    
    Change-Id: I2f8df05801297d8ec29bf1d966624f06df685d31
    Reviewed-on: https://gerrit.libreoffice.org/85010
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
    Reviewed-by: Jan Holesovsky <kendy at collabora.com>

diff --git a/loleaflet/src/control/Control.MobileWizard.js b/loleaflet/src/control/Control.MobileWizard.js
index 4715f0694..912c4602d 100644
--- a/loleaflet/src/control/Control.MobileWizard.js
+++ b/loleaflet/src/control/Control.MobileWizard.js
@@ -26,7 +26,7 @@ L.Control.MobileWizard = L.Control.extend({
 		this.map = map;
 		map.on('mobilewizard', this._onMobileWizard, this);
 		map.on('closemobilewizard', this._hideWizard, this);
-		map.on('showmobilewizard', this._showWizard, this);
+		map.on('showwizardsidebar', this._showWizardSidebar, this);
 
 		this._setupBackButton();
 	},
@@ -60,6 +60,12 @@ L.Control.MobileWizard = L.Control.extend({
 		$('#toolbar-down').hide();
 	},
 
+	_showWizardSidebar: function() {
+		this.map.showSidebar = true;
+		this._refreshSidebar();
+		this._showWizard();
+	},
+
 	_hideWizard: function() {
 		$('#mobile-wizard').hide();
 		$('#mobile-wizard-content').empty();
@@ -67,6 +73,7 @@ L.Control.MobileWizard = L.Control.extend({
 			$('#toolbar-down').show();
 		}
 
+		this.map.showSidebar = false;
 		this._isActive = false;
 		this._currentPath = [];
 		if (window.mobileWizard === true) {
@@ -228,8 +235,10 @@ L.Control.MobileWizard = L.Control.extend({
 		if (data) {
 			var isSidebar = data.id !== 'menubar' && data.id !== 'insertshape' && data.id !== 'funclist';
 
-			if (!this._isActive && isSidebar)
-				this._refreshSidebar();
+			if (!this._isActive && isSidebar) {
+				if (this.map.showSidebar == false)
+					return;
+			}
 
 			this._isActive = true;
 			var currentPath = null;
@@ -242,10 +251,8 @@ L.Control.MobileWizard = L.Control.extend({
 
 			this._reset();
 
-			if (window.mobileWizard) {
-				this._showWizard();
-				this._hideKeyboard();
-			}
+			this._showWizard();
+			this._hideKeyboard();
 
 			// We can change the sidebar as we want here
 			if (data.id === '') { // sidebar indicator
diff --git a/loleaflet/src/control/Control.Toolbar.js b/loleaflet/src/control/Control.Toolbar.js
index 4e8c1943e..a068c3af9 100644
--- a/loleaflet/src/control/Control.Toolbar.js
+++ b/loleaflet/src/control/Control.Toolbar.js
@@ -346,7 +346,19 @@ function onClick(e, id, item, subItem) {
 			if (window.insertionMobileWizard)
 				this.onClick(null, 'insertion_mobile_wizard');
 			window.mobileWizard = true;
-			map.fire('showmobilewizard');
+			if (!map._sidebarVisible) {
+				map._sidebarVisible = true;
+				map.sendUnoCommand('.uno:Sidebar');
+			} else {
+				// As the sidebar LOKWindowId can and does change,
+				// esp. between chart and other elements, we apparently
+				// lose track, and there is currently no reliable way to
+				// recover it (which is needed to request updates).
+				// The following disable and enable the sidebar to get it.
+				map.sendUnoCommand('.uno:Sidebar');
+				map.sendUnoCommand('.uno:Sidebar');
+			}
+			map.fire('showwizardsidebar');
 			toolbar.check(id);
 		}
 	}
diff --git a/loleaflet/src/layer/tile/TileLayer.js b/loleaflet/src/layer/tile/TileLayer.js
index d6e406884..491d14731 100644
--- a/loleaflet/src/layer/tile/TileLayer.js
+++ b/loleaflet/src/layer/tile/TileLayer.js
@@ -875,8 +875,8 @@ L.TileLayer = L.GridLayer.extend({
 		this._map.fire('mobilewizard', data);
 	},
 
-	_closeMobileWizard: function(data) {
-		this._map.fire('closemobilewizard', data);
+	_closeMobileWizard: function() {
+		this._map.fire('closemobilewizard');
 	},
 
 	_onJSDialogMsg: function (textMsg) {
@@ -885,7 +885,7 @@ L.TileLayer = L.GridLayer.extend({
 			if (msgData.enabled) {
 				this._openMobileWizard(msgData);
 			} else {
-				this._closeMobileWizard(msgData);
+				this._closeMobileWizard();
 			}
 		}
 	},
diff --git a/loleaflet/src/map/Map.js b/loleaflet/src/map/Map.js
index af149f236..8e9f98d45 100644
--- a/loleaflet/src/map/Map.js
+++ b/loleaflet/src/map/Map.js
@@ -110,6 +110,8 @@ L.Map = L.Evented.extend({
 		this._disableDefaultAction = {}; // The events for which the default handler is disabled and only issues postMessage.
 		this._winId = 0;
 		this._activeDialog = null;
+		this._sidebarVisible = false; // The state of the sidebar in Core.
+		this._showSidebar = false; // Whether we have the sidebar visible in the UI or not (i.e. does the user want to see it or not).
 
 		vex.dialogID = -1;
 
@@ -294,7 +296,9 @@ L.Map = L.Evented.extend({
 					// thinks it is shown, so the command has to be triggered
 					// once again for it to be visible on the desktop
 					// (because the first .uno:Sidebar has actually hid it)
-					map._socket.sendMessage('uno .uno:Sidebar');
+					if (!window.mode.isMobile() && !window.mode.isTablet() && !window.ThisIsAMobileApp) {
+						map._socket.sendMessage('uno .uno:Sidebar');
+					}
 				}, 200);
 			}
 


More information about the Libreoffice-commits mailing list