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

Szymon KÅ‚os (via logerrit) logerrit at kemper.freedesktop.org
Wed Jul 29 09:26:48 UTC 2020


 loleaflet/reference.html              |   17 +++++++++++++++--
 loleaflet/src/map/handler/Map.WOPI.js |   24 +++++++++++++++++-------
 2 files changed, 32 insertions(+), 9 deletions(-)

New commits:
commit d8e6b2689344fde9d13a4c716685983e51223668
Author:     Szymon Kłos <szymon.klos at collabora.com>
AuthorDate: Wed Jul 29 10:57:07 2020 +0200
Commit:     Szymon Kłos <szymon.klos at collabora.com>
CommitDate: Wed Jul 29 11:26:29 2020 +0200

    Update Hide_Button documentation & cleanup the code
    
    Code update allows to search in all toolbars not
    only main one like in the past.
    
    Change-Id: I76c9cdbbdade287748ec19d537b564206d52eab5
    Reviewed-on: https://gerrit.libreoffice.org/c/online/+/99671
    Tested-by: Jenkins
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
    Reviewed-by: Szymon Kłos <szymon.klos at collabora.com>

diff --git a/loleaflet/reference.html b/loleaflet/reference.html
index 4c07de27d..c6fe9e008 100644
--- a/loleaflet/reference.html
+++ b/loleaflet/reference.html
@@ -3351,8 +3351,21 @@ Editor to WOPI host
 </table>
 
 <h5><a name="toolbar-button-ids">Finding toolbar button IDs</a></h5>
-<p>Toolbar button IDs are defined in the <a href="https://opengrok.libreoffice.org/search?project=online&q=&defs=createToolbar">createToolbar</a>
-function in <a href="https://opengrok.libreoffice.org/xref/online/loleaflet/src/control/Control.Toolbar.js">Control.Toolbar.js</a>.
+<p>Toolbar button IDs are defined in getToolItems/create functions in:
+<ul>
+	<li>
+		<a href="https://opengrok.libreoffice.org/xref/online/loleaflet/src/control/Control.TopToolbar.js">Control.TopToolbar.js</a> for the top toolbar on desktop or tablet.
+	</li>
+	<li>
+		<a href="https://opengrok.libreoffice.org/xref/online/loleaflet/src/control/Control.MobileTopBar.js">Control.MobileTopBar.js</a> for the top toolbar on smartphone.
+	</li>
+	<li>
+		<a href="https://opengrok.libreoffice.org/xref/online/loleaflet/src/control/Control.MobileBottomBar.js">Control.MobileBottomBar.js</a> for the bottom toolbar on smartphone.
+	</li>
+	<li>
+		<a href="https://opengrok.libreoffice.org/xref/online/loleaflet/src/control/Control.StatusBar.js">Control.StatusBar.js</a> for the statusbar on desktop.
+	</li>
+</ul>
 Note that they usually don't change but there is no guarantee that they are stable.</p>
 
 <h5><a name="statusbar-element-ids">Finding statusbar element IDs</a></h5>
diff --git a/loleaflet/src/map/handler/Map.WOPI.js b/loleaflet/src/map/handler/Map.WOPI.js
index 39c1520fe..99a566025 100644
--- a/loleaflet/src/map/handler/Map.WOPI.js
+++ b/loleaflet/src/map/handler/Map.WOPI.js
@@ -220,20 +220,30 @@ L.Map.WOPI = L.Handler.extend({
 				console.error('Property "Values" not set');
 				return;
 			}
+
 			if (!msg.Values.id) {
 				console.error('Property "Values.id" not set');
 				return;
 			}
-			var toolbar = w2ui['toolbar-up'] ? w2ui['toolbar-up'] : (w2ui['actionbar'] ? w2ui['actionbar'] : w2ui['editbar']);
-			if (!toolbar || !toolbar.get(msg.Values.id)) {
+
+			var toolbars = [w2ui['toolbar-up'], w2ui['actionbar'], w2ui['editbar']];
+			var found = false;
+
+			toolbars.forEach(function(toolbar) {
+				if (toolbar && toolbar.get(msg.Values.id)) {
+					found = true;
+					if (msg.MessageId === 'Show_Button') {
+						toolbar.show(msg.Values.id);
+					} else {
+						toolbar.hide(msg.Values.id);
+					}
+				}
+			});
+
+			if (!found) {
 				console.error('Toolbar button with id "' + msg.Values.id + '" not found.');
 				return;
 			}
-			if (msg.MessageId === 'Show_Button') {
-				toolbar.show(msg.Values.id);
-			} else {
-				toolbar.hide(msg.Values.id);
-			}
 		}
 		else if (msg.MessageId === 'Remove_Statusbar_Element') {
 			if (!msg.Values) {


More information about the Libreoffice-commits mailing list