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

Szymon KÅ‚os (via logerrit) logerrit at kemper.freedesktop.org
Tue Apr 28 08:15:02 UTC 2020


 loleaflet/src/control/Control.JSDialogBuilder.js |   53 +++++++++++++++++++++++
 1 file changed, 53 insertions(+)

New commits:
commit b0faa3cf59cb58586fb6adfed33bd494d673897c
Author:     Szymon Kłos <szymon.klos at collabora.com>
AuthorDate: Wed Mar 4 15:50:29 2020 +0100
Commit:     Szymon Kłos <szymon.klos at collabora.com>
CommitDate: Tue Apr 28 10:14:44 2020 +0200

    jsdialog: tabcontrol widget
    
    Change-Id: Ibe72a382e767869f94db4f8b475dfe2169fcc702
    Reviewed-on: https://gerrit.libreoffice.org/c/online/+/93028
    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 9f500751f..8fe8c9c17 100644
--- a/loleaflet/src/control/Control.JSDialogBuilder.js
+++ b/loleaflet/src/control/Control.JSDialogBuilder.js
@@ -122,6 +122,7 @@ L.Control.JSDialogBuilder = L.Control.extend({
 		this._controlHandlers['frame'] = this._frameHandler;
 		this._controlHandlers['panel'] = this._panelHandler;
 		this._controlHandlers['calcfuncpanel'] = this._calcFuncListPanelHandler;
+		this._controlHandlers['tabcontrol'] = this._tabsControlHandler;
 		this._controlHandlers['paneltabs'] = this._panelTabsHandler;
 		this._controlHandlers['container'] = this._containerHandler;
 		this._controlHandlers['window'] = this._containerHandler;
@@ -598,6 +599,58 @@ L.Control.JSDialogBuilder = L.Control.extend({
 		};
 	},
 
+	_tabsControlHandler: function(parentContainer, data, builder) {
+		if (data.tabs) {
+			var tabsContainer = L.DomUtil.create('div', 'ui-tabs mobile-wizard ui-widget');
+			tabsContainer.id = data.id;
+			var contentsContainer = L.DomUtil.create('div', 'ui-tabs-content mobile-wizard ui-widget', parentContainer);
+
+			var tabs = [];
+			var contentDivs = [];
+			var labels = [];
+			for (var tabIdx = 0; tabIdx < data.tabs.length; tabIdx++) {
+				var item = data.tabs[tabIdx];
+
+				var title = builder._cleanText(item.text);
+
+				var tab = L.DomUtil.create('div', 'ui-tab mobile-wizard', tabsContainer);
+				tab.id = data.tabs[tabIdx].name;
+				if (data.selected == data.tabs[tabIdx].id)
+					$(tab).addClass('selected');
+				tabs[tabIdx] = tab;
+
+				var label = L.DomUtil.create('span', 'ui-tab-content mobile-wizard unolabel', tab);
+				label.innerHTML = title;
+				labels[tabIdx] = title;
+
+				var contentDiv = L.DomUtil.create('div', 'ui-content level-' + builder._currentDepth + ' mobile-wizard', contentsContainer);
+				contentDiv.title = title;
+
+				$(contentDiv).hide();
+				contentDivs[tabIdx] = contentDiv;
+			}
+
+			if (builder.wizard) {
+				builder.wizard.setTabs(tabsContainer);
+
+				for (var t = 0; t < tabs.length; t++) {
+					// to get capture of 't' right has to be a sub fn.
+					var fn = function(id) {
+						return function() {
+							builder._createTabClick(builder, id, tabs, contentDivs, labels)();
+							builder.callback('tabcontrol', 'selecttab', tabsContainer, id, builder);
+						};
+					};
+					$(tabs[t]).click(fn(t));
+				}
+			} else {
+				console.debug('Builder used outside of mobile wizard: please implement the click handler');
+			}
+		}
+
+		return true;
+	},
+
 	_panelTabsHandler: function(parentContainer, data, builder) {
 		var tabsContainer = L.DomUtil.create('div', 'ui-tabs mobile-wizard ui-widget');
 		var contentsContainer = L.DomUtil.create('div', 'ui-tabs-content mobile-wizard ui-widget', parentContainer);


More information about the Libreoffice-commits mailing list