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

Szymon KÅ‚os (via logerrit) logerrit at kemper.freedesktop.org
Mon May 4 06:54:54 UTC 2020


 loleaflet/Makefile.am                              |    4 
 loleaflet/src/control/Control.Notebookbar.js       |   94 -------------------
 loleaflet/src/control/Control.NotebookbarCalc.js   |   52 +++++++++++
 loleaflet/src/control/Control.NotebookbarWriter.js |   99 +++++++++++++++++++++
 loleaflet/src/control/Control.UIManager.js         |    6 +
 5 files changed, 164 insertions(+), 91 deletions(-)

New commits:
commit b0e2bd990efda7c408d8ac4e76c15327b30a35f3
Author:     Szymon Kłos <szymon.klos at collabora.com>
AuthorDate: Fri May 1 12:19:29 2020 +0200
Commit:     Szymon Kłos <szymon.klos at collabora.com>
CommitDate: Mon May 4 08:54:32 2020 +0200

    notebookbar: separate file for each app
    
    Change-Id: If61ed762a3dd55c0cef7d58b7a3b1ddf8276cce3
    Reviewed-on: https://gerrit.libreoffice.org/c/online/+/93304
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
    Reviewed-by: Szymon Kłos <szymon.klos at collabora.com>

diff --git a/loleaflet/Makefile.am b/loleaflet/Makefile.am
index 94caedb92..4bb2b1c84 100644
--- a/loleaflet/Makefile.am
+++ b/loleaflet/Makefile.am
@@ -282,6 +282,8 @@ LOLEAFLET_JS =\
 	src/control/Control.UIManager.js \
 	src/control/Control.DocumentNameInput.js \
 	src/control/Control.Notebookbar.js \
+	src/control/Control.NotebookbarWriter.js \
+	src/control/Control.NotebookbarCalc.js \
 	src/control/Control.NotebookbarBuilder.js \
 	src/control/Control.Layers.js \
 	src/control/Search.js \
@@ -552,6 +554,8 @@ pot:
 		src/control/Control.UIManager.js \
 		src/control/Control.DocumentNameInput.js \
 		src/control/Control.Notebookbar.js \
+		src/control/Control.NotebookbarWriter.js \
+		src/control/Control.NotebookbarCalc.js \
 		src/control/Control.NotebookbarBuilder.js \
 		src/control/Ruler.js \
 		src/control/Signing.js \
diff --git a/loleaflet/src/control/Control.Notebookbar.js b/loleaflet/src/control/Control.Notebookbar.js
index 1a1bc37c1..0fca7d1ca 100644
--- a/loleaflet/src/control/Control.Notebookbar.js
+++ b/loleaflet/src/control/Control.Notebookbar.js
@@ -5,9 +5,6 @@
 
 /* global $ */
 L.Control.Notebookbar = L.Control.extend({
-	options: {
-		docType: ''
-	},
 
 	onAdd: function (map) {
 		this.map = map;
@@ -39,68 +36,13 @@ L.Control.Notebookbar = L.Control.extend({
 		$('nav').prepend(tabs);
 	},
 
-	selectedTab: function(tabText) {
-		console.log(tabText);
-		switch (tabText) {
-		case 'HomeLabel':
-			this.loadTab(this.getHomeTab());
-			break;
-
-		case 'InsertLabel':
-			this.loadTab(this.getInsertTab());
-			break;
-
-		case 'LayoutLabel':
-			this.loadTab(this.getLayoutTab());
-			break;
-		
-		case 'ReferencesLabel':
-			this.loadTab(this.getReferencesTab());
-			break;
-
-		case 'TableLabel':
-			this.loadTab(this.getTableTab());
-			break;
-
-		case 'ReviewLabel':
-			this.loadTab(this.getReviewTab());
-			break;
-		}
+	selectedTab: function() {
+		// implement in child classes
 	},
 	
 	getTabs: function() {
-		return [
-			{
-				'text': '~Home',
-				'id': '2',
-				'name': 'HomeLabel'
-			},
-			{
-				'text': '~Insert',
-				'id': '3',
-				'name': 'InsertLabel'
-			},
-			{
-				'text': '~Layout',
-				'id': '4',
-				'name': 'LayoutLabel'
-			},
-			{
-				'text': 'Reference~s',
-				'id': '5',
-				'name': 'ReferencesLabel'
-			},
-			{
-				'text': '~Review',
-				'id': '6',
-				'name': 'ReviewLabel'
-			},
-			{
-				'text': '~Table',
-				'id': '8',
-				'name': 'TableLabel'
-			}
-		];
+		// implement in child classes
+		return [];
 	},
 
 	// required, called by builder, not needed in this container
@@ -153,32 +95,4 @@ L.Control.Notebookbar = L.Control.extend({
 		$(window).resize(handler);
 		$('.notebookbar-scroll-wrapper').scroll(handler);
 	},
-
-	getHomeTab: function() {
-		return '';
-	},
-
-	getInsertTab: function() {
-		return '';
-	},
-
-	getLayoutTab: function() {
-		return '';
-	},
-
-	getReferencesTab: function() {
-		return '';
-	},
-
-	getTableTab: function() {
-		return '';
-	},
-
-	getReviewTab: function() {
-		return '';
-	}
 });
-
-L.control.notebookbar = function (options) {
-	return new L.Control.Notebookbar(options);
-};
diff --git a/loleaflet/src/control/Control.NotebookbarCalc.js b/loleaflet/src/control/Control.NotebookbarCalc.js
new file mode 100644
index 000000000..3b530d922
--- /dev/null
+++ b/loleaflet/src/control/Control.NotebookbarCalc.js
@@ -0,0 +1,52 @@
+/* -*- js-indent-level: 8 -*- */
+/*
+ * L.Control.NotebookbarCalc
+ */
+
+/* global */
+L.Control.NotebookbarCalc = L.Control.NotebookbarWriter.extend({
+
+	selectedTab: function(tabText) {
+		switch (tabText) {
+		case 'HomeLabel':
+			this.loadTab(this.getHomeTab());
+			break;
+
+		case 'InsertLabel':
+			this.loadTab(this.getInsertTab());
+			break;
+
+		case 'ReviewLabel':
+			this.loadTab(this.getReviewTab());
+			break;
+		}
+	},
+	
+	getTabs: function() {
+		return [
+			{
+				'text': '~Home',
+				'id': '2',
+				'name': 'HomeLabel'
+			},
+			{
+				'text': '~Insert',
+				'id': '3',
+				'name': 'InsertLabel'
+			},
+			{
+				'text': '~Review',
+				'id': '6',
+				'name': 'ReviewLabel'
+			}
+		];
+	},
+
+	getHomeTab: function() {
+		return '';
+	}
+});
+
+L.control.notebookbarCalc = function (options) {
+	return new L.Control.NotebookbarCalc(options);
+};
diff --git a/loleaflet/src/control/Control.NotebookbarWriter.js b/loleaflet/src/control/Control.NotebookbarWriter.js
new file mode 100644
index 000000000..17a443fee
--- /dev/null
+++ b/loleaflet/src/control/Control.NotebookbarWriter.js
@@ -0,0 +1,99 @@
+/* -*- js-indent-level: 8 -*- */
+/*
+ * L.Control.NotebookbarWriter
+ */
+
+/* global */
+L.Control.NotebookbarWriter = L.Control.Notebookbar.extend({
+
+	selectedTab: function(tabText) {
+		switch (tabText) {
+		case 'HomeLabel':
+			this.loadTab(this.getHomeTab());
+			break;
+
+		case 'InsertLabel':
+			this.loadTab(this.getInsertTab());
+			break;
+
+		case 'LayoutLabel':
+			this.loadTab(this.getLayoutTab());
+			break;
+		
+		case 'ReferencesLabel':
+			this.loadTab(this.getReferencesTab());
+			break;
+
+		case 'TableLabel':
+			this.loadTab(this.getTableTab());
+			break;
+
+		case 'ReviewLabel':
+			this.loadTab(this.getReviewTab());
+			break;
+		}
+	},
+	
+	getTabs: function() {
+		return [
+			{
+				'text': '~Home',
+				'id': '2',
+				'name': 'HomeLabel'
+			},
+			{
+				'text': '~Insert',
+				'id': '3',
+				'name': 'InsertLabel'
+			},
+			{
+				'text': '~Layout',
+				'id': '4',
+				'name': 'LayoutLabel'
+			},
+			{
+				'text': 'Reference~s',
+				'id': '5',
+				'name': 'ReferencesLabel'
+			},
+			{
+				'text': '~Review',
+				'id': '6',
+				'name': 'ReviewLabel'
+			},
+			{
+				'text': '~Table',
+				'id': '8',
+				'name': 'TableLabel'
+			}
+		];
+	},
+
+	getHomeTab: function() {
+		return '';
+	},
+
+	getInsertTab: function() {
+		return '';
+	},
+
+	getLayoutTab: function() {
+		return '';
+	},
+
+	getReferencesTab: function() {
+		return '';
+	},
+
+	getTableTab: function() {
+		return '';
+	},
+
+	getReviewTab: function() {
+		return '';
+	}
+});
+
+L.control.notebookbarWriter = function (options) {
+	return new L.Control.NotebookbarWriter(options);
+};
diff --git a/loleaflet/src/control/Control.UIManager.js b/loleaflet/src/control/Control.UIManager.js
index 6070ae26c..d613927a9 100644
--- a/loleaflet/src/control/Control.UIManager.js
+++ b/loleaflet/src/control/Control.UIManager.js
@@ -66,7 +66,11 @@ L.Control.UIManager = L.Control.extend({
 			this.map.addControl(L.control.mobileTopBar(docType));
 			this.map.addControl(L.control.searchBar());
 		} else if (window.enableNotebookbar) {
-			this.map.addControl(L.control.notebookbar({docType: docType}));
+			if (docType === 'spreadsheet') {
+				this.map.addControl(L.control.notebookbarCalc());
+			} else {
+				this.map.addControl(L.control.notebookbarWriter());
+			}
 
 			var additionalOffset = 0;
 			if (docType === 'spreadsheet') {


More information about the Libreoffice-commits mailing list