[Libreoffice-commits] online.git: Branch 'distro/collabora/collabora-online-1-0' - loleaflet/dist loleaflet/src
Pranav Kant
pranavk at collabora.com
Wed Jun 1 16:14:07 UTC 2016
loleaflet/dist/toolbar/toolbar.js | 51 +++++++++++++++++++++++-------
loleaflet/src/control/Toolbar.js | 7 +++-
loleaflet/src/map/handler/Map.Keyboard.js | 3 +
3 files changed, 48 insertions(+), 13 deletions(-)
New commits:
commit fde94cc4e2f555db94cced025b5d5f1829a24638
Author: Pranav Kant <pranavk at collabora.com>
Date: Wed Jun 1 13:18:22 2016 +0530
loleaflet: bccu#1777: bccu#1555: formula bar fixes
* Use new param DontCommit in .uno:EnterString to not trigger
recalculation until enter is pressed.
* On pressing 'ESC', reset the current content
* Range selection is now possible when formula is entered in
* formula bar
* Forward 'enter' key events to `map` from formula bar
Change-Id: I073eca2fa08520faa9f679b1c986e10805da0ad6
(cherry picked from commit 26d5614b897f68395567e9cfa0d727ef79208b65)
Reviewed-on: https://gerrit.libreoffice.org/25789
Reviewed-by: pranavk <pranavk at collabora.com>
Tested-by: pranavk <pranavk at collabora.com>
diff --git a/loleaflet/dist/toolbar/toolbar.js b/loleaflet/dist/toolbar/toolbar.js
index 58605f6..67f7ee3 100644
--- a/loleaflet/dist/toolbar/toolbar.js
+++ b/loleaflet/dist/toolbar/toolbar.js
@@ -185,11 +185,19 @@ function onClick(id) {
map.cellEnterString(L.DomUtil.get('formulaInput').value);
}
else if (id === 'cancelformula') {
- L.DomUtil.get('formulaInput').value = '';
- map.cellEnterString(L.DomUtil.get('formulaInput').value);
+ map.sendUnoCommand('.uno:Cancel');
+ w2ui['formulabar'].hide('acceptformula', 'cancelformula');
+ w2ui['formulabar'].show('sum', 'function');
}
else if (id === 'acceptformula') {
- map.cellEnterString(L.DomUtil.get('formulaInput').value);
+ // focus on map, and press enter
+ map.focus();
+ map._docLayer._postKeyboardEvent('input',
+ map.keyboard.keyCodes.enter,
+ map.keyboard._toUNOKeyCode(map.keyboard.keyCodes.enter));
+
+ w2ui['formulabar'].hide('acceptformula', 'cancelformula');
+ w2ui['formulabar'].show('sum', 'function');
}
else if (id === 'more') {
$('#toolbar-up-more').toggle();
@@ -397,7 +405,7 @@ $(function () {
{type: 'button', id: 'function', img: 'equal', hint: _('Function')},
{type: 'button', hidden: true, id: 'cancelformula', img: 'cancel', hint: _('Cancel')},
{type: 'button', hidden: true, id: 'acceptformula', img: 'accepttrackedchanges', hint: _('Accept')},
- {type: 'html', id: 'formula', html: '<input id="formulaInput" onkeyup="onFormulaInput()"' +
+ {type: 'html', id: 'formula', html: '<input id="formulaInput" onkeyup="onFormulaInput(event)"' +
'onblur="onFormulaBarBlur()" onfocus="onFormulaBarFocus()" type=text>'}
],
onClick: function (e) {
@@ -593,8 +601,23 @@ function onInsertFile() {
}
}
-function onFormulaInput() {
- map.cellEnterString(L.DomUtil.get('formulaInput').value);
+function onFormulaInput(e) {
+ // keycode = 13 is 'enter'
+ if (e.keyCode === 13) {
+ // formula bar should not have focus anymore
+ map.focus();
+
+ // forward the 'enter' keystroke to map to deal with the formula entered
+ var data = {
+ originalEvent: e
+ };
+ map.fire('keypress', data);
+ } else if (e.keyCode === 27) { // 27 = esc key
+ map.sendUnoCommand('.uno:Cancel');
+ map.focus();
+ } else {
+ map.cellEnterString(L.DomUtil.get('formulaInput').value);
+ }
}
function onFormulaBarFocus() {
@@ -606,11 +629,17 @@ function onFormulaBarFocus() {
}
function onFormulaBarBlur() {
- var formulabar = w2ui.formulabar;
- formulabar.show('sum');
- formulabar.show('function');
- formulabar.hide('cancelformula');
- formulabar.hide('acceptformula');
+ // 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 formulabar = w2ui.formulabar;
+ formulabar.show('sum');
+ formulabar.show('function');
+ formulabar.hide('cancelformula');
+ formulabar.hide('acceptformula');
+ }, 250);
}
map.on('updatepermission', function () {
diff --git a/loleaflet/src/control/Toolbar.js b/loleaflet/src/control/Toolbar.js
index aff5e3f..cee4561 100644
--- a/loleaflet/src/control/Toolbar.js
+++ b/loleaflet/src/control/Toolbar.js
@@ -123,9 +123,14 @@ L.Map.include({
'StringName': {
type: 'string',
value: string
+ },
+ 'DontCommit': {
+ type: 'boolean',
+ value: true
}
};
- this._socket.sendMessage('uno .uno:EnterString ' + JSON.stringify(command));
+
+ this.sendUnoCommand('.uno:EnterString ', command);
},
renderFont: function (fontName) {
diff --git a/loleaflet/src/map/handler/Map.Keyboard.js b/loleaflet/src/map/handler/Map.Keyboard.js
index e316e8e..9202e7a 100644
--- a/loleaflet/src/map/handler/Map.Keyboard.js
+++ b/loleaflet/src/map/handler/Map.Keyboard.js
@@ -141,7 +141,8 @@ L.Map.Keyboard = L.Handler.extend({
keyCodes: {
pageUp: 33,
- pageDown: 34
+ pageDown: 34,
+ enter: 13
},
navigationKeyCodes: {
More information about the Libreoffice-commits
mailing list