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

Szymon KÅ‚os (via logerrit) logerrit at kemper.freedesktop.org
Fri May 8 14:26:39 UTC 2020


 loleaflet/src/control/Control.Notebookbar.js        |   16 ++++++++++++++++
 loleaflet/src/control/Control.NotebookbarCalc.js    |    3 ++-
 loleaflet/src/control/Control.NotebookbarImpress.js |    6 ++++--
 loleaflet/src/control/Control.NotebookbarWriter.js  |    6 ++++--
 loleaflet/src/layer/tile/TileLayer.js               |    7 +++++++
 5 files changed, 33 insertions(+), 5 deletions(-)

New commits:
commit 5fd446863bec4f6cb61a58852135d27188792b8a
Author:     Szymon Kłos <szymon.klos at collabora.com>
AuthorDate: Fri May 8 15:18:19 2020 +0200
Commit:     Szymon Kłos <szymon.klos at collabora.com>
CommitDate: Fri May 8 16:26:20 2020 +0200

    notebookbar: switch tab on context change
    
    Change-Id: Ib485cfdbd06291de6b03a544fe0975f61823bf24
    Reviewed-on: https://gerrit.libreoffice.org/c/online/+/93731
    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.Notebookbar.js b/loleaflet/src/control/Control.Notebookbar.js
index 2be2c8443..7b62e1123 100644
--- a/loleaflet/src/control/Control.Notebookbar.js
+++ b/loleaflet/src/control/Control.Notebookbar.js
@@ -13,6 +13,8 @@ L.Control.Notebookbar = L.Control.extend({
 
 		this.createScrollButtons();
 		this.setupResizeHandler();
+
+		this.map.on('contextchange', this.onContextChange, this);
 	},
 
 	clearNotebookbar: function() {
@@ -129,4 +131,18 @@ L.Control.Notebookbar = L.Control.extend({
 		$(window).resize(handler);
 		$('.notebookbar-scroll-wrapper').scroll(handler);
 	},
+
+	onContextChange: function(event) {
+		var tabs = this.getTabs();
+		for (var tab in tabs) {
+			if (tabs[tab].context) {
+				var contexts = tabs[tab].context.split('|');
+				for (var context in contexts) {
+					if (contexts[context] === event.context) {
+						this.selectedTab(tabs[tab].name);
+					}
+				}
+			}
+		}
+	}
 });
diff --git a/loleaflet/src/control/Control.NotebookbarCalc.js b/loleaflet/src/control/Control.NotebookbarCalc.js
index 08a7875cc..9dc98d183 100644
--- a/loleaflet/src/control/Control.NotebookbarCalc.js
+++ b/loleaflet/src/control/Control.NotebookbarCalc.js
@@ -27,7 +27,8 @@ L.Control.NotebookbarCalc = L.Control.NotebookbarWriter.extend({
 			{
 				'text': '~Home',
 				'id': '2',
-				'name': 'HomeLabel'
+				'name': 'HomeLabel',
+				'context': 'default|Cell'
 			},
 			{
 				'text': '~Insert',
diff --git a/loleaflet/src/control/Control.NotebookbarImpress.js b/loleaflet/src/control/Control.NotebookbarImpress.js
index f36ae8511..1ece53d51 100644
--- a/loleaflet/src/control/Control.NotebookbarImpress.js
+++ b/loleaflet/src/control/Control.NotebookbarImpress.js
@@ -62,7 +62,8 @@ L.Control.NotebookbarImpress = L.Control.NotebookbarWriter.extend({
 			{
 				'text': '~Home',
 				'id': '2',
-				'name': 'HomeLabel'
+				'name': 'HomeLabel',
+				'context': 'default|DrawText'
 			},
 			{
 				'text': '~Insert',
@@ -77,7 +78,8 @@ L.Control.NotebookbarImpress = L.Control.NotebookbarWriter.extend({
 			{
 				'text': '~Table',
 				'id': '8',
-				'name': 'TableLabel'
+				'name': 'TableLabel',
+				'context': 'Table'
 			}
 		];
 	},
diff --git a/loleaflet/src/control/Control.NotebookbarWriter.js b/loleaflet/src/control/Control.NotebookbarWriter.js
index 5351b1d08..a67461274 100644
--- a/loleaflet/src/control/Control.NotebookbarWriter.js
+++ b/loleaflet/src/control/Control.NotebookbarWriter.js
@@ -39,7 +39,8 @@ L.Control.NotebookbarWriter = L.Control.Notebookbar.extend({
 			{
 				'text': '~Home',
 				'id': '2',
-				'name': 'HomeLabel'
+				'name': 'HomeLabel',
+				'context': 'default|Text'
 			},
 			{
 				'text': '~Insert',
@@ -64,7 +65,8 @@ L.Control.NotebookbarWriter = L.Control.Notebookbar.extend({
 			{
 				'text': '~Table',
 				'id': '8',
-				'name': 'TableLabel'
+				'name': 'TableLabel',
+				'context': 'Table'
 			}
 		];
 	},
diff --git a/loleaflet/src/layer/tile/TileLayer.js b/loleaflet/src/layer/tile/TileLayer.js
index 1b413f9d7..4b51906fa 100644
--- a/loleaflet/src/layer/tile/TileLayer.js
+++ b/loleaflet/src/layer/tile/TileLayer.js
@@ -719,6 +719,13 @@ L.TileLayer = L.GridLayer.extend({
 		else if (textMsg.startsWith('tabstoplistupdate:')) {
 			this._onTabStopListUpdate(textMsg);
 		}
+		else if (textMsg.startsWith('context:')) {
+			var message = textMsg.substring('context:'.length + 1);
+			message = message.split(' ');
+			if (message.length > 1) {
+				this._map.fire('contextchange', {context: message[1]});
+			}
+		}
 	},
 
 	_onTabStopListUpdate: function (textMsg) {


More information about the Libreoffice-commits mailing list