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

Iván Sánchez Ortega (via logerrit) logerrit at kemper.freedesktop.org
Thu Jan 2 17:18:34 UTC 2020


 loleaflet/src/control/Control.Toolbar.js     |   41 ++++++++++++++++++++-------
 loleaflet/src/layer/tile/CalcTileLayer.js    |    3 -
 loleaflet/src/layer/tile/ImpressTileLayer.js |    3 -
 loleaflet/src/layer/tile/WriterTileLayer.js  |    3 -
 4 files changed, 34 insertions(+), 16 deletions(-)

New commits:
commit a458fdcc0ba7a5cb10f5e5756c784717a4eec2ad
Author:     Iván Sánchez Ortega <ivan.sanchez at collabora.com>
AuthorDate: Wed Jun 26 14:17:51 2019 +0000
Commit:     Jan Holesovsky <kendy at collabora.com>
CommitDate: Thu Jan 2 18:18:12 2020 +0100

    There must be only one cursor - either in the search or in the document.
    
    Previously clicking into the search input field did not hide the cursor
    in the document.
    
    Change-Id: Ia524d39de0825190c51257a3c9a0a4257ca45150
    Reviewed-on: https://gerrit.libreoffice.org/c/online/+/83353
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
    Reviewed-by: Jan Holesovsky <kendy at collabora.com>

diff --git a/loleaflet/src/control/Control.Toolbar.js b/loleaflet/src/control/Control.Toolbar.js
index a854e6cde..f053d2b55 100644
--- a/loleaflet/src/control/Control.Toolbar.js
+++ b/loleaflet/src/control/Control.Toolbar.js
@@ -95,8 +95,8 @@ function _cancelSearch() {
 		// odd, but on mobile we need to invoke it twice
 		toolbar.hide('cancelsearch');
 	}
-	else
-		map.focus();
+
+	map._onGotFocus();
 }
 
 function onClick(e, id, item, subItem) {
@@ -1185,8 +1185,7 @@ function initNormalToolbar() {
 			},
 			onRefresh: function() {
 				$('#tb_actionbar_item_userlist .w2ui-tb-caption').addClass('loleaflet-font');
-				$('#search-input').off('input', onSearch).on('input', onSearch);
-				$('#search-input').off('keydown', onSearchKeyDown).on('keydown', onSearchKeyDown);
+				setupSearchInput();
 
 				var showInDesktop = map['wopi'].HideUserList !== null &&
 									map['wopi'].HideUserList !== undefined &&
@@ -1214,6 +1213,13 @@ function initNormalToolbar() {
 	});
 }
 
+function setupSearchInput() {
+	$('#search-input').off('input', onSearchInput).on('input', onSearchInput);
+	$('#search-input').off('keypress', onSearchKeyPress).on('keypress', onSearchKeyPress);
+	$('#search-input').off('focus', onSearchFocus).on('focus', onSearchFocus);
+	$('#search-input').off('blur', onSearchBlur).on('blur', onSearchBlur);
+}
+
 var userJoinedPopupMessage = '<div>' + _('%user has joined') + '</div>';
 var userLeftPopupMessage = '<div>' + _('%user has left') + '</div>';
 var userPopupTimeout = null;
@@ -1266,7 +1272,7 @@ function unoCmdToToolbarId(commandname)
 	return id;
 }
 
-function onSearch() {
+function updateSearchButtons() {
 	var toolbar = _inMobileMode() ? w2ui['searchbar'] : w2ui['actionbar'];
 	// conditionally disabling until, we find a solution for tdf#108577
 	if (L.DomUtil.get('search-input').value === '') {
@@ -1275,15 +1281,21 @@ function onSearch() {
 		toolbar.hide('cancelsearch');
 	}
 	else {
-		if (map.getDocType() === 'text')
-			map.search(L.DomUtil.get('search-input').value, false, '', 0, true /* expand search */);
 		toolbar.enable('searchprev');
 		toolbar.enable('searchnext');
 		toolbar.show('cancelsearch');
 	}
 }
 
-function onSearchKeyDown(e) {
+function onSearchInput() {
+	updateSearchButtons();
+	if (map.getDocType() === 'text') {
+		// perform the immediate search in Writer
+		map.search(L.DomUtil.get('search-input').value, false, '', 0, true /* expand search */);
+	}
+}
+
+function onSearchKeyPress(e) {
 	var entry = L.DomUtil.get('search-input');
 	if ((e.keyCode === 71 && e.ctrlKey) || e.keyCode === 114 || e.keyCode === 13) {
 		if (e.shiftKey) {
@@ -1301,6 +1313,16 @@ function onSearchKeyDown(e) {
 	}
 }
 
+function onSearchFocus() {
+	// hide the caret in the main document
+	map._onLostFocus();
+	updateSearchButtons();
+}
+
+function onSearchBlur() {
+	map._onGotFocus();
+}
+
 function documentNameConfirm() {
 	var value = $('#document-name-input').val();
 	if (value !== null && value != '' && value != map['wopi'].BaseFileName) {
@@ -2609,7 +2631,6 @@ global.insertTable = insertTable;
 global.insertShapes = insertShapes;
 global.createShapesPanel = createShapesPanel;
 global.onUpdatePermission = onUpdatePermission;
-global.onSearch = onSearch;
-global.onSearchKeyDown = onSearchKeyDown;
+global.setupSearchInput = setupSearchInput;
 
 }(window));
diff --git a/loleaflet/src/layer/tile/CalcTileLayer.js b/loleaflet/src/layer/tile/CalcTileLayer.js
index 1aaae8ad2..f753d1a51 100644
--- a/loleaflet/src/layer/tile/CalcTileLayer.js
+++ b/loleaflet/src/layer/tile/CalcTileLayer.js
@@ -242,8 +242,7 @@ L.CalcTileLayer = L.TileLayer.extend({
 				window.onClick(e, e.target, e.item, e.subItem);
 			},
 			onRefresh: function () {
-				$('#search-input').off('input', window.onSearch).on('input', window.onSearch);
-				$('#search-input').off('keydown', window.onSearchKeyDown).on('keydown', window.onSearchKeyDown);
+				window.setupSearchInput();
 			}
 		});
 
diff --git a/loleaflet/src/layer/tile/ImpressTileLayer.js b/loleaflet/src/layer/tile/ImpressTileLayer.js
index 485343cd1..ffa1f40af 100644
--- a/loleaflet/src/layer/tile/ImpressTileLayer.js
+++ b/loleaflet/src/layer/tile/ImpressTileLayer.js
@@ -227,8 +227,7 @@ L.ImpressTileLayer = L.TileLayer.extend({
 				window.onClick(e, e.target, e.item, e.subItem);
 			},
 			onRefresh: function () {
-				$('#search-input').off('input', window.onSearch).on('input', window.onSearch);
-				$('#search-input').off('keydown', window.onSearchKeyDown).on('keydown', window.onSearchKeyDown);
+				window.setupSearchInput();
 			}
 		});
 
diff --git a/loleaflet/src/layer/tile/WriterTileLayer.js b/loleaflet/src/layer/tile/WriterTileLayer.js
index ac343ff24..c90f8512e 100644
--- a/loleaflet/src/layer/tile/WriterTileLayer.js
+++ b/loleaflet/src/layer/tile/WriterTileLayer.js
@@ -164,8 +164,7 @@ L.WriterTileLayer = L.TileLayer.extend({
 				window.onClick(e, e.target, e.item, e.subItem);
 			},
 			onRefresh: function () {
-				$('#search-input').off('input', window.onSearch).on('input', window.onSearch);
-				$('#search-input').off('keydown', window.onSearchKeyDown).on('keydown', window.onSearchKeyDown);
+				window.setupSearchInput();
 			}
 		});
 


More information about the Libreoffice-commits mailing list