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

Michael Meeks (via logerrit) logerrit at kemper.freedesktop.org
Fri Jan 10 19:01:29 UTC 2020


 loleaflet/src/control/Control.JSDialogBuilder.js |   99 ++++++++++++-----------
 loleaflet/src/control/Control.MobileWizard.js    |    7 -
 2 files changed, 56 insertions(+), 50 deletions(-)

New commits:
commit 8dbbb2cd3398d1564c34b500530ab8e066c4c1d7
Author:     Michael Meeks <michael.meeks at collabora.com>
AuthorDate: Fri Jan 10 18:20:54 2020 +0000
Commit:     Michael Meeks <michael.meeks at collabora.com>
CommitDate: Fri Jan 10 20:01:09 2020 +0100

    panel/wizard: cleanup two-panel tabbed view.
    
    Hopefully it can be re-used for a single-tab view now.
    
    adapt to new panel naming re-using the UNO methods - cf.
    related core commit.
    
    Change-Id: I1312d3571ccb7cf3561f1661f73f860c56f002a4
    Reviewed-on: https://gerrit.libreoffice.org/c/online/+/86572
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
    Reviewed-by: Michael Meeks <michael.meeks at collabora.com>

diff --git a/loleaflet/src/control/Control.JSDialogBuilder.js b/loleaflet/src/control/Control.JSDialogBuilder.js
index d4f58b470..eaa414018 100644
--- a/loleaflet/src/control/Control.JSDialogBuilder.js
+++ b/loleaflet/src/control/Control.JSDialogBuilder.js
@@ -398,71 +398,76 @@ L.Control.JSDialogBuilder = L.Control.extend({
 		return false;
 	},
 
+	_createTabClick: function(builder, t, tabs, contentDivs, labels)
+	{
+		return function() {
+			$(tabs[t]).addClass('selected');
+			for (var i = 0; i < tabs.length; i++) {
+				if (i !== t)
+				{
+					$(tabs[i]).removeClass('selected');
+					$(contentDivs[i]).hide();
+				}
+			}
+			$(contentDivs[t]).show();
+			builder.wizard.selectedTab(labels[t]);
+		};
+	},
+
 	_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);
 
-		var title1 = builder._cleanText(data[0].text);
-
-		var tab1 = L.DomUtil.create('div', 'ui-tab mobile-wizard', tabsContainer);
-		tab1.id = title1;
-
-		var label = L.DomUtil.create('span', 'ui-tab-content mobile-wizard unolabel', tab1);
-		label.innerHTML = title1;
+		var tabs = [];
+		var contentDivs = [];
+		var labels = [];
+		for (var tabIdx = 0; tabIdx < data.length; tabIdx++) {
+			var item = data[tabIdx];
 
-		var contentDiv = L.DomUtil.create('div', 'ui-content level-' + builder._currentDepth + ' mobile-wizard', contentsContainer);
-		contentDiv.title = title1;
+			var title = builder._cleanText(item.text);
 
-		builder._currentDepth++;
-		for (var i = 0; i < data[0].children.length; i++) {
-			builder.build(contentDiv, [data[0].children[i]]);
-		}
-		builder._currentDepth--;
+			var tab = L.DomUtil.create('div', 'ui-tab mobile-wizard', tabsContainer);
+			tab.id = title;
+			tabs[tabIdx] = tab;
 
-		$(contentDiv).hide();
+			var label = L.DomUtil.create('span', 'ui-tab-content mobile-wizard unolabel', tab);
+			label.innerHTML = title;
+			labels[tabIdx] = title;
 
-		var title2 = builder._cleanText(data[1].text);
+			var contentDiv = L.DomUtil.create('div', 'ui-content level-' + builder._currentDepth + ' mobile-wizard', contentsContainer);
+			contentDiv.title = title;
 
-		var tab2 = L.DomUtil.create('div', 'ui-tab mobile-wizard', tabsContainer);
-		tab2.id = title2;
-
-		var label2 = L.DomUtil.create('span', 'ui-tab-content mobile-wizard unolabel', tab2);
-		label2.innerHTML = title2;
-
-		var contentDiv2 = L.DomUtil.create('div', 'ui-content level-' + builder._currentDepth + ' mobile-wizard', contentsContainer);
-		contentDiv2.title = title2;
+			builder._currentDepth++;
+			if (item.children)
+			{
+				for (var i = 0; i < item.children.length; i++) {
+					builder.build(contentDiv, [item.children[i]]);
+				}
+			}
+			else // build ourself inside there
+			{
+				builder.build(contentDiv, [item]);
+			}
+			builder._currentDepth--;
 
-		builder._currentDepth++;
-		for (i = 0; i < data[1].children.length; i++) {
-			builder.build(contentDiv2, [data[1].children[i]]);
+			$(contentDiv).hide();
+			contentDivs[tabIdx] = contentDiv;
 		}
-		builder._currentDepth--;
 
-		$(contentDiv2).hide();
 		if (builder.wizard) {
 			builder.wizard.setTabs(tabsContainer);
 
-			$(tab1).click(function() {
-				$(tab1).addClass('selected');
-				$(tab2).removeClass('selected');
-				$(contentDiv).show();
-				$(contentDiv2).hide();
-				builder.wizard.selectedTab(label.innerHTML);
-			});
-
-			$(tab2).click(function() {
-				$(tab2).addClass('selected');
-				$(tab1).removeClass('selected');
-				$(contentDiv).hide();
-				$(contentDiv2).show();
-				builder.wizard.selectedTab(label2.innerHTML);
-			});
+			for (var t = 0; t < tabs.length; t++) {
+				// to get capture of 't' right has to be a sub fn.
+				var fn = builder._createTabClick(
+					builder, t, tabs, contentDivs, labels);
+				$(tabs[t]).click(fn);
+			}
 		} else {
 			console.debug('Builder used outside of mobile wizard: please implement the click handler');
 		}
-
-		$(tab1).click();
-		builder.wizard.goLevelDown(contentDiv);
+		$(tabs[0]).click();
+		builder.wizard.goLevelDown(contentDivs[0]);
 
 		return false;
 	},
diff --git a/loleaflet/src/control/Control.MobileWizard.js b/loleaflet/src/control/Control.MobileWizard.js
index f07da4911..f186a2412 100644
--- a/loleaflet/src/control/Control.MobileWizard.js
+++ b/loleaflet/src/control/Control.MobileWizard.js
@@ -311,13 +311,14 @@ L.Control.MobileWizard = L.Control.extend({
 		if (deck)
 		{
 			// merge styles into text-panel for elegance
-			var stylesIdx = this._findIdxInParentById(deck, 'SidebarStylesPanel');
-			var textIdx = this._findIdxInParentById(deck, 'SidebarTextPanel');
+			var stylesIdx = this._findIdxInParentById(deck, 'StylesPropertyPanel');
+			var textName = 'TextPropertyPanel';
+			var textIdx = this._findIdxInParentById(deck, textName);
 			if (stylesIdx >= 0 && textIdx >= 0)
 			{
 				var moveContent = deck.children[stylesIdx].children;
 				deck.children.splice(stylesIdx, 1); // remove
-				textIdx = this._findIdxInParentById(deck, 'SidebarTextPanel'); // re-lookup
+				textIdx = this._findIdxInParentById(deck, textName); // re-lookup
 				deck.children[textIdx].children = moveContent.concat(deck.children[textIdx].children);
 			}
 		}


More information about the Libreoffice-commits mailing list