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@collabora.com>
Reviewed-by: Marco Cecchetti <marco.cecchetti@collabora.com>
distro/collabora/co-4-2-3
Marco Cecchetti 2020-04-21 18:08:13 +02:00
parent 7f105d02a8
commit 6037d52bca
5 changed files with 46 additions and 2 deletions

View File

@ -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; }

View File

@ -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);
};

View File

@ -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();
}
},

View File

@ -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();
}

View File

@ -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();
}
},