[Libreoffice-commits] online.git: Branch 'distro/collabora/milestone-7' - loleaflet/src
Marco Cecchetti
marco.cecchetti at collabora.com
Thu Jan 21 02:02:04 PST 2016
loleaflet/src/control/Search.js | 27 ++++++---------------------
loleaflet/src/layer/tile/TileLayer.js | 14 +++++---------
2 files changed, 11 insertions(+), 30 deletions(-)
New commits:
commit 1a7fead463f742cb6bc072e2836f30c155f36e60
Author: Marco Cecchetti <marco.cecchetti at collabora.com>
Date: Thu Jan 21 10:54:24 2016 +0100
text doc - search - normal search does not discard highlighting
Improved search behavior for text documents:now when a normal search is
performed with the same search string utilized by a previous searchAll
action, search results highlighting is not removed.
diff --git a/loleaflet/src/control/Search.js b/loleaflet/src/control/Search.js
index 136f97b..5528a08 100644
--- a/loleaflet/src/control/Search.js
+++ b/loleaflet/src/control/Search.js
@@ -6,27 +6,9 @@ L.Map.include({
if (all === undefined) {
all = 0;
}
-
- // check if there is a cached searchAll result for this phrase
- // if there is update index for next/prev iteration
- if (this._docLayer._searchResults && text === this._docLayer._searchTerm) {
- if (backward) {
- if (this._docLayer._searchIndex > 0) {
- this._docLayer._searchIndex--;
- }
- else {
- this._docLayer._searchIndex = this._docLayer._searchResults.length - 1;
- }
- } else {
- if (this._docLayer._searchIndex < this._docLayer._searchResults.length - 1) {
- this._docLayer._searchIndex++;
- }
- else {
- this._docLayer._searchIndex = 0;
- }
- }
- this.setPart(this._docLayer._searchResults[this._docLayer._searchIndex].part);
- return;
+ if (this._docLayer._searchResults && text !== this._docLayer._searchTerm)
+ {
+ this._docLayer._clearSearchResults();
}
var searchCmd = {
@@ -61,6 +43,9 @@ L.Map.include({
},
searchAll: function (text, backward) {
+ if (this._docLayer._searchResults && text === this._docLayer._searchTerm) {
+ return;
+ }
this.search(text, backward, 1);
},
diff --git a/loleaflet/src/layer/tile/TileLayer.js b/loleaflet/src/layer/tile/TileLayer.js
index dcef8c7..bae33d6 100644
--- a/loleaflet/src/layer/tile/TileLayer.js
+++ b/loleaflet/src/layer/tile/TileLayer.js
@@ -482,7 +482,6 @@ L.TileLayer = L.GridLayer.extend({
},
_onSearchResultSelection: function (textMsg) {
- this._clearSearchResults();
textMsg = textMsg.substring(23);
var obj = JSON.parse(textMsg);
var originalPhrase = obj.searchString;
@@ -497,22 +496,19 @@ L.TileLayer = L.GridLayer.extend({
}
// do not cache search results if there is only one result.
// this way regular searches works fine
- if (this._docType === 'presentation' && count > 1)
+ if (count > 1)
{
- this._map._socket.sendMessage('resetselection');
+ this._clearSearchResults();
this._searchResults = results;
- this._searchTerm = originalPhrase;
- this._searchIndex = 0;
-
this._map.setPart(results[0].part); // go to first result.
}
+ this._searchTerm = originalPhrase;
this._map.fire('search', {originalPhrase: originalPhrase, count: count, results: results});
},
_clearSearchResults: function() {
this._searchResults = null;
this._searchTerm = null;
- this._searchIndex = null;
this._searchResultsLayer.clearLayers();
},
@@ -521,12 +517,12 @@ L.TileLayer = L.GridLayer.extend({
return;
}
this._searchResultsLayer.clearLayers();
- for (var k=0; k < this._searchResults.length; k++)
+ for (var k = 0; k < this._searchResults.length; k++)
{
var result = this._searchResults[k];
if (result.part === this._selectedPart)
{
- var _fillColor = (k === this._searchIndex) ? '#43ACE8' : '#CCCCCC';
+ var _fillColor = '#CCCCCC';
var strTwips = result.twipsRectangles.match(/\d+/g);
var rectangles = [];
for (var i = 0; i < strTwips.length; i += 4) {
More information about the Libreoffice-commits
mailing list