[Libreoffice-commits] online.git: Branch 'feature/jsdialogs' - loleaflet/src

Szymon Kłos (via logerrit) logerrit at kemper.freedesktop.org
Thu Sep 26 16:01:52 UTC 2019


 loleaflet/src/control/Control.JSDialogBuilder.js |   12 -----
 loleaflet/src/control/Control.MobileWizard.js    |   49 +++++++++++++++++------
 2 files changed, 39 insertions(+), 22 deletions(-)

New commits:
commit 11da071e7fec17f17cdc58b31546ddffdc838045
Author:     Szymon Kłos <szymon.klos at collabora.com>
AuthorDate: Thu Sep 26 17:34:20 2019 +0200
Commit:     Szymon Kłos <szymon.klos at collabora.com>
CommitDate: Thu Sep 26 18:00:11 2019 +0200

    jsdialogs: refactor mobile wizard
    
    Change-Id: Id6ab9a0265e8d80bce4c446ec3b9526af6f95cf8

diff --git a/loleaflet/src/control/Control.JSDialogBuilder.js b/loleaflet/src/control/Control.JSDialogBuilder.js
index 6f19136f5..3d19a5430 100644
--- a/loleaflet/src/control/Control.JSDialogBuilder.js
+++ b/loleaflet/src/control/Control.JSDialogBuilder.js
@@ -138,22 +138,14 @@ L.Control.JSDialogBuilder = L.Control.extend({
 		sectionTitle.innerHTML = title;
 
 		var contentDiv = L.DomUtil.create('div', 'ui-content level-' + builder._currentDepth + ' mobile-wizard', parentContainer);
+		contentDiv.title = title;
 
 		builder._currentDepth++;
 		builder.build(contentDiv, [contentNode]);
 		builder._currentDepth--;
 
 		$(contentDiv).hide();
-		$(sectionTitle).click(function() {
-			var titles = '.ui-header.level-' + builder.wizard._currentDepth + '.mobile-wizard';
-
-			$(titles).hide('slide', { direction: 'left' }, 'fast', function() {});
-			$(contentDiv).show('slide', { direction: 'right' }, 'fast');
-
-			builder.wizard._currentDepth++;
-			builder.wizard._setTitle(title);
-			builder.wizard._inMainMenu = false;
-		});
+		$(sectionTitle).click(function() { builder.wizard.goLevelDown(contentDiv); });
 	},
 
 	_frameHandler: function(parentContainer, data, builder) {
diff --git a/loleaflet/src/control/Control.MobileWizard.js b/loleaflet/src/control/Control.MobileWizard.js
index 90f567e27..c1e8a2b14 100644
--- a/loleaflet/src/control/Control.MobileWizard.js
+++ b/loleaflet/src/control/Control.MobileWizard.js
@@ -21,18 +21,7 @@ L.Control.MobileWizard = L.Control.extend({
 	_setupBackButton: function() {
 		var that = this;
 		var backButton = $('#mobile-wizard-back');
-		backButton.click(function() {
-			if (that._inMainMenu) {
-				that._hideWizard();
-				that._currentDepth = 0;
-			} else {
-				that._currentDepth--;
-				$('.ui-content.level-' + that._currentDepth + '.mobile-wizard').hide('slide', { direction: 'right' }, 'fast', function() {});
-				$('.ui-header.level-' + that._currentDepth + '.mobile-wizard').show('slide', { direction: 'left' }, 'fast');
-				if (that._currentDepth == 0)
-					that._inMainMenu = true;
-			}
-		});
+		backButton.click(function() { that.goLevelUp(); });
 	},
 
 	_showWizard: function() {
@@ -49,6 +38,42 @@ L.Control.MobileWizard = L.Control.extend({
 		document.activeElement.blur();
 	},
 
+	getCurrentLevel: function() {
+		return this._currentDepth;
+	},
+
+	goLevelDown: function(contentToShow) {
+		var titles = '.ui-header.level-' + this.getCurrentLevel() + '.mobile-wizard';
+
+		$(titles).hide('slide', { direction: 'left' }, 'fast');
+		$(contentToShow).show('slide', { direction: 'right' }, 'fast');
+
+		this._currentDepth++;
+		this._setTitle(contentToShow.title);
+		this._inMainMenu = false;
+	},
+
+	goLevelUp: function() {
+		if (this._inMainMenu) {
+			this._hideWizard();
+			this._currentDepth = 0;
+		} else {
+			this._currentDepth--;
+
+			var parent = $('.ui-content.mobile-wizard:visible');
+			if (this._currentDepth > 0 && parent)
+				this._setTitle(parent.get(0).title);
+			else
+				this._setTitle('');
+
+			$('.ui-content.level-' + this._currentDepth + '.mobile-wizard').hide('slide', { direction: 'right' }, 'fast');
+			$('.ui-header.level-' + this._currentDepth + '.mobile-wizard').show('slide', { direction: 'left' }, 'fast');
+
+			if (this._currentDepth == 0)
+				this._inMainMenu = true;
+		}
+	},
+
 	_setTitle: function(title) {
 		var right = $('#mobile-wizard-title');
 		right.text(title);


More information about the Libreoffice-commits mailing list