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

Marco Cecchetti (via logerrit) logerrit at kemper.freedesktop.org
Wed Apr 29 11:28:12 UTC 2020


 loleaflet/css/toolbar.css                     |    1 +
 loleaflet/src/control/Control.FormulaBar.js   |   24 ++++++++++++++++++++++++
 loleaflet/src/control/Control.LokDialog.js    |    3 ++-
 loleaflet/src/control/Control.MobileTopBar.js |   19 ++++++++++++++++++-
 loleaflet/src/map/Map.js                      |    1 +
 5 files changed, 46 insertions(+), 2 deletions(-)

New commits:
commit 6037d52bca434189af9ee72fb70b8a316e6a8abc
Author:     Marco Cecchetti <marco.cecchetti at collabora.com>
AuthorDate: Tue Apr 21 18:08:13 2020 +0200
Commit:     Marco Cecchetti <marco.cecchetti at collabora.com>
CommitDate: Wed Apr 29 13:27:53 2020 +0200

    loleaflet: mobile: remove sum and equal buttons from the formula bar
    
    The sum and equal buttons has been removed from the formula bar.
    Now, in the mobile case, the accept/cancel buttons are shown in place
    of undo/redo buttons when the formula input bar gets focus.
    
    Change-Id: I378059396df3566d5bf3c83b2defa99fc669054d
    Reviewed-on: https://gerrit.libreoffice.org/c/online/+/89454
    Tested-by: Marco Cecchetti <marco.cecchetti at collabora.com>
    Reviewed-by: Marco Cecchetti <marco.cecchetti at collabora.com>

diff --git a/loleaflet/css/toolbar.css b/loleaflet/css/toolbar.css
index fd903aa5a..a1eca0bd8 100644
--- a/loleaflet/css/toolbar.css
+++ b/loleaflet/css/toolbar.css
@@ -661,6 +661,7 @@ button.leaflet-control-search-next
 
 .w2ui-icon.functiondialog{ background: url('images/lc_functiondialog.svg') no-repeat center !important; }
 .w2ui-icon.accepttrackedchanges{ background: url('images/lc_accepttrackedchanges.svg') no-repeat center !important; }
+.w2ui-icon.ok{ background: url('images/lc_ok.svg') no-repeat center !important; }
 .w2ui-icon.cancel{ background: url('images/lc_cancel.svg') no-repeat center !important; }
 .w2ui-icon.color{ background: url('images/lc_color.svg') no-repeat center !important; }
 .w2ui-icon.deletepage{ background: url('images/lc_deletepage.svg') no-repeat center !important; }
diff --git a/loleaflet/src/control/Control.FormulaBar.js b/loleaflet/src/control/Control.FormulaBar.js
index 48d8a4f2d..e62bd2c86 100644
--- a/loleaflet/src/control/Control.FormulaBar.js
+++ b/loleaflet/src/control/Control.FormulaBar.js
@@ -144,6 +144,30 @@ L.Control.FormulaBar = L.Control.extend({
 	}
 });
 
+L.Map.include({
+	onFormulaBarFocus: function() {
+		var mobileTopBar = w2ui['actionbar'];
+		mobileTopBar.hide('undo');
+		mobileTopBar.hide('redo');
+		mobileTopBar.show('cancelformula');
+		mobileTopBar.show('acceptformula');
+	},
+
+	onFormulaBarBlur: function() {
+		// The timeout is needed because we want 'click' event on 'cancel',
+		// 'accept' button to act before we hide these buttons because
+		// once hidden, click event won't be processed.
+		// TODO: Some better way to do it ?
+		setTimeout(function() {
+			var mobileTopBar = w2ui['actionbar'];
+			mobileTopBar.show('undo');
+			mobileTopBar.show('redo');
+			mobileTopBar.hide('cancelformula');
+			mobileTopBar.hide('acceptformula');
+		}, 250);
+	}
+});
+
 L.control.formulaBar = function (options) {
 	return new L.Control.FormulaBar(options);
 };
diff --git a/loleaflet/src/control/Control.LokDialog.js b/loleaflet/src/control/Control.LokDialog.js
index 0a372e3a2..7a12317e2 100644
--- a/loleaflet/src/control/Control.LokDialog.js
+++ b/loleaflet/src/control/Control.LokDialog.js
@@ -826,7 +826,7 @@ L.Control.LokDialog = L.Control.extend({
 		L.DomUtil.setStyle(handles, 'position', 'absolute');
 		L.DomUtil.setStyle(handles, 'background', 'transparent');
 		this._setCanvasWidthHeight(handles, width, height);
-		handles.offsetX = 48;
+		handles.offsetX = window.mode.isMobile() ? 0 : 48;   // 48 with sigma and equal buttons
 		handles.offsetY = 0;
 		var startHandle = document.createElement('div');
 		L.DomUtil.addClass(startHandle, 'leaflet-selection-marker-start');
@@ -1316,6 +1316,7 @@ L.Control.LokDialog = L.Control.extend({
 			this._onEditorGotFocus();
 		} else {
 			this.focus(e.winId, e.acceptInput);
+			this._map.onFormulaBarFocus();
 		}
 	},
 
diff --git a/loleaflet/src/control/Control.MobileTopBar.js b/loleaflet/src/control/Control.MobileTopBar.js
index 8543a3221..ba727279f 100644
--- a/loleaflet/src/control/Control.MobileTopBar.js
+++ b/loleaflet/src/control/Control.MobileTopBar.js
@@ -3,7 +3,7 @@
  * L.Control.SearchBar
  */
 
-/* global $ w2ui _UNO */
+/* global $ w2ui _UNO _ */
 L.Control.MobileTopBar = L.Control.extend({
 
 	options: {
@@ -41,6 +41,8 @@ L.Control.MobileTopBar = L.Control.extend({
 				{type: 'spacer'},
 				{type: 'button',  id: 'undo',  img: 'undo', hint: _UNO('.uno:Undo'), uno: 'Undo', disabled: true},
 				{type: 'button',  id: 'redo',  img: 'redo', hint: _UNO('.uno:Redo'), uno: 'Redo', disabled: true},
+				{type: 'button', hidden: true, id: 'acceptformula',  img: 'ok', hint: _('Accept')},
+				{type: 'button', hidden: true, id: 'cancelformula',  img: 'cancel', hint: _('Cancel')},
 				{type: 'button',  id: 'mobile_wizard', img: 'mobile_wizard', disabled: true},
 				{type: 'button',  id: 'insertion_mobile_wizard', img: 'insertion_mobile_wizard', disabled: true},
 //				{type: 'button',  id: 'insertcomment', img: 'insertcomment', disabled: true},
@@ -108,6 +110,21 @@ L.Control.MobileTopBar = L.Control.extend({
 				this.map.toggleCommandState(window.getUNOCommand(item.uno));
 			}
 		}
+		else if (id === 'cancelformula') {
+			this.map.sendUnoCommand('.uno:Cancel');
+			w2ui['actionbar'].hide('acceptformula', 'cancelformula');
+			w2ui['actionbar'].show('undo', 'redo');
+		}
+		else if (id === 'acceptformula') {
+			// focus on map, and press enter
+			this.map.focus();
+			this.map._docLayer.postKeyboardEvent('input',
+				this.map.keyboard.keyCodes.enter,
+				this.map.keyboard._toUNOKeyCode(this.map.keyboard.keyCodes.enter));
+
+			w2ui['actionbar'].hide('acceptformula', 'cancelformula');
+			w2ui['actionbar'].show('undo', 'redo');
+		}
 		else if (id === 'insertcomment') {
 			this.map.insertComment();
 		}
diff --git a/loleaflet/src/map/Map.js b/loleaflet/src/map/Map.js
index bf331537e..982cde654 100644
--- a/loleaflet/src/map/Map.js
+++ b/loleaflet/src/map/Map.js
@@ -1401,6 +1401,7 @@ L.Map = L.Evented.extend({
 		if (this.dialog._calcInputBar) {
 			var inputBarId = this.dialog._calcInputBar.id;
 			this.dialog._updateTextSelection(inputBarId);
+			this.onFormulaBarBlur();
 		}
 	},
 


More information about the Libreoffice-commits mailing list