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

Szymon KÅ‚os (via logerrit) logerrit at kemper.freedesktop.org
Tue May 19 10:56:44 UTC 2020


 loleaflet/src/control/Control.JSDialogBuilder.js |    4 +++-
 loleaflet/src/control/Control.LokDialog.js       |   21 +++++++++++++++++++--
 loleaflet/src/control/Control.MobileWizard.js    |   11 +++++++++++
 3 files changed, 33 insertions(+), 3 deletions(-)

New commits:
commit e55892b997337c0a122b0fe4809983742c753036
Author:     Szymon Kłos <szymon.klos at collabora.com>
AuthorDate: Fri Feb 21 09:54:33 2020 +0100
Commit:     Szymon Kłos <szymon.klos at collabora.com>
CommitDate: Tue May 19 12:56:27 2020 +0200

    jsdialog: handle events for dialogs in mobilewizard
    
    - remember window id
    - close mobile wizard on dialog close
    - close dialog on mobile wizard close
    - don't show dialogs on mobile devices
    
    Change-Id: I585c5b92192655684eedd62d88817a92fc1fc0a8
    Reviewed-on: https://gerrit.libreoffice.org/c/online/+/93005
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
    Reviewed-by: Szymon Kłos <szymon.klos at collabora.com>

diff --git a/loleaflet/src/control/Control.JSDialogBuilder.js b/loleaflet/src/control/Control.JSDialogBuilder.js
index 4ecbc0ad9..ab0996c22 100644
--- a/loleaflet/src/control/Control.JSDialogBuilder.js
+++ b/loleaflet/src/control/Control.JSDialogBuilder.js
@@ -228,7 +228,9 @@ L.Control.JSDialogBuilder = L.Control.extend({
 			builder.map.sendUnoCommand(encodedCommand);
 		} else if (object) {
 			data = typeof data === 'string' ? data.replace('"', '\\"') : data;
-			var message = 'dialogevent ' + (window.sidebarId !== undefined ? window.sidebarId : -1) +
+			var windowId = window.mobileDialogId !== undefined ? window.mobileDialogId :
+								(window.sidebarId !== undefined ? window.sidebarId : -1);
+			var message = 'dialogevent ' + windowId +
 			    ' {\"id\":\"' + object.id + '\", \"cmd\": \"' + eventType + '\", \"data\":\"' + data + '\"}';
 			builder.map._socket.sendMessage(message);
 		}
diff --git a/loleaflet/src/control/Control.LokDialog.js b/loleaflet/src/control/Control.LokDialog.js
index 43a8ee7f4..a96ae309f 100644
--- a/loleaflet/src/control/Control.LokDialog.js
+++ b/loleaflet/src/control/Control.LokDialog.js
@@ -59,6 +59,10 @@ L.Control.LokDialog = L.Control.extend({
 
 	dialogIdPrefix: 'lokdialog-',
 
+	hasDialogInMobilePanelOpened: function() {
+		return window.mobileDialogId !== undefined;
+	},
+
 	onPan: function (ev) {
 		if (!draggedObject)
 			return;
@@ -289,7 +293,7 @@ L.Control.LokDialog = L.Control.extend({
 		}
 
 		if (e.action === 'created') {
-			if (e.winType === 'dialog') {
+			if (e.winType === 'dialog' && !window.mode.isMobile()) {
 				// When left/top are invalid, the dialog shows in the center.
 				this._launchDialog(e.id, left, top, width, height, e.title);
 			} else if (e.winType === 'calc-input-win') {
@@ -335,7 +339,17 @@ L.Control.LokDialog = L.Control.extend({
 		}
 
 		// All other callbacks doen't make sense without an active dialog.
-		if (!(this._isOpen(e.id) || this._getParentId(e.id)))
+		if (!(this._isOpen(e.id) || this._getParentId(e.id))) {
+			if (e.action == 'close' && window.mobileDialogId == e.id) {
+				window.mobileDialogId = undefined;
+				this._map.fire('closemobilewizard');
+			}
+
+			return;
+		}
+
+		// We don't want dialogs and sidebar on smartphones, only calc input window is allowed
+		if (window.mode.isMobile() && e.winType !== 'calc-input-win' && !this.isCalcInputBar(e.id))
 			return;
 
 		if (e.action === 'invalidate') {
@@ -1401,6 +1415,9 @@ L.Control.LokDialog = L.Control.extend({
 				this._onDialogClose(dialogId, true);
 			}
 		}
+		if (this.hasDialogInMobilePanelOpened()) {
+			this._onDialogClose(window.mobileDialogId, true);
+		}
 	},
 
 	onCloseCurrentPopUp: function() {
diff --git a/loleaflet/src/control/Control.MobileWizard.js b/loleaflet/src/control/Control.MobileWizard.js
index 926f9f707..958eeb985 100644
--- a/loleaflet/src/control/Control.MobileWizard.js
+++ b/loleaflet/src/control/Control.MobileWizard.js
@@ -93,6 +93,12 @@ L.Control.MobileWizard = L.Control.extend({
 	},
 
 	_hideWizard: function() {
+		// dialog
+		if (this.map.dialog.hasDialogInMobilePanelOpened()) {
+			this.map.dialog._onDialogClose(window.mobileDialogId, true);
+			window.mobileDialogId = undefined;
+		}
+
 		$('#mobile-wizard').hide();
 		$('#mobile-wizard-content').empty();
 		if (this.map._permission === 'edit') {
@@ -320,6 +326,11 @@ L.Control.MobileWizard = L.Control.extend({
 				return;
 			}
 
+			if (data.id && !isNaN(data.id) && !isSidebar) {
+				// id is a number - remember window id for interaction
+				window.mobileDialogId = data.id;
+			}
+
 			// Sometimes it happens that we get the same sidebar
 			// structure twice. This makes hard to test mobile wizard.
 			if (isSidebar && L.Browser.cypressTest) {


More information about the Libreoffice-commits mailing list