[Libreoffice-commits] online.git: 13 commits - loleaflet/README loleaflet/spec loleaflet/src
Mihai Varga
mihai.varga at collabora.com
Thu Aug 13 03:31:19 PDT 2015
loleaflet/README | 29 +++++++++++++----
loleaflet/spec/loadtest/LoadTestSpec.js | 9 -----
loleaflet/src/control/Control.Permission.js | 1
loleaflet/src/control/Control.Search.js | 8 ++--
loleaflet/src/control/Control.Selection.js | 1
loleaflet/src/control/Control.js | 17 ++++++----
loleaflet/src/control/Parts.js | 47 ++++++++++++++++++++++++++++
loleaflet/src/control/Scroll.js | 29 +++++++++++------
loleaflet/src/layer/tile/GridLayer.js | 25 ++++++++++----
loleaflet/src/layer/tile/TileLayer.js | 5 +-
loleaflet/src/map/Map.js | 9 +++++
loleaflet/src/map/handler/Map.Keyboard.js | 5 ++
loleaflet/src/map/handler/Map.Mouse.js | 13 +++++--
13 files changed, 150 insertions(+), 48 deletions(-)
New commits:
commit 5da0423ec3ba2c3d90613d28a235bca0550444a7
Author: Mihai Varga <mihai.varga at collabora.com>
Date: Thu Aug 13 13:18:56 2015 +0300
loleaflet: changed method name to getCurrent*Number
diff --git a/loleaflet/README b/loleaflet/README
index a25578b..0ce0f70 100644
--- a/loleaflet/README
+++ b/loleaflet/README
@@ -94,7 +94,7 @@ Parts (like slides in presentation, or sheets in spreadsheets):
+ maxWidth / maxHeight are the desired dimensions of the preview, a smaller
image might be returned in order to keep the original ratio of the document
map.getNumberOfParts()
- map.getCurrentPart()
+ map.getCurrentPartNumber()
- events:
map.on('updateparts', function (e) {}) where:
+ e.currentPart is the current part
@@ -159,7 +159,7 @@ Writer pages:
- API:
map.goToPage(page)
map.getNumberOfPages()
- map.getCurrentPart()
+ map.getCurrentPageNumber()
map.getDocPreview(id, maxWidth, maxHeight, x, y, width, height)
+ id = the ID of the request so that the response can be identified
+ maxWidth / maxHeight are the desired dimensions of the preview, a smaller
diff --git a/loleaflet/src/control/Parts.js b/loleaflet/src/control/Parts.js
index 1e0670f..e7ee57a 100644
--- a/loleaflet/src/control/Parts.js
+++ b/loleaflet/src/control/Parts.js
@@ -100,11 +100,11 @@ L.Map.include({
return this._docLayer._parts;
},
- getCurrentPage: function () {
+ getCurrentPageNumber: function () {
return this._docLayer._currentPage;
},
- getCurrentPart: function () {
+ getCurrentPartNumber: function () {
return this._docLayer._currentPart;
},
commit d7262c57e07e393d2d769829e841097c02811389
Author: Mihai Varga <mihai.varga at collabora.com>
Date: Thu Aug 13 12:58:59 2015 +0300
loleaflet: method to get a preview of the document
diff --git a/loleaflet/README b/loleaflet/README
index e73726c..a25578b 100644
--- a/loleaflet/README
+++ b/loleaflet/README
@@ -160,6 +160,12 @@ Writer pages:
map.goToPage(page)
map.getNumberOfPages()
map.getCurrentPart()
+ map.getDocPreview(id, maxWidth, maxHeight, x, y, width, height)
+ + id = the ID of the request so that the response can be identified
+ + maxWidth / maxHeight are the desired dimensions of the preview, a smaller
+ image might be returned in order to keep the original ratio of the document
+ + x/y = starting position, where to get the preview from
+
- events
map.on('pagenumberchanged', function (e) {}) where:
+ e.currentPage = the page on which the cursor lies
diff --git a/loleaflet/src/control/Parts.js b/loleaflet/src/control/Parts.js
index 9c6bfe3..1e0670f 100644
--- a/loleaflet/src/control/Parts.js
+++ b/loleaflet/src/control/Parts.js
@@ -56,6 +56,33 @@ L.Map.include({
'id=' + id);
},
+ getDocPreview: function (id, maxWidth, maxHeight, x, y, width, height) {
+ var docLayer = this._docLayer;
+ var docRatio = width / height;
+ var imgRatio = maxWidth / maxHeight;
+ // fit into the given rectangle while maintaining the ratio
+ if (imgRatio > docRatio) {
+ maxWidth = Math.round(width * maxHeight / height);
+ }
+ else {
+ maxHeight = Math.round(height * maxWidth / width);
+ }
+ x = Math.round(x / docLayer._tileSize * docLayer._tileWidthTwips);
+ width = Math.round(width / docLayer._tileSize * docLayer._tileWidthTwips);
+ y = Math.round(y / docLayer._tileSize * docLayer._tileHeightTwips);
+ height = Math.round(height / docLayer._tileSize * docLayer._tileHeightTwips);
+
+ docLayer.sendMessage('tile ' +
+ 'part=0 ' +
+ 'width=' + maxWidth + ' ' +
+ 'height=' + maxHeight + ' ' +
+ 'tileposx=' + x + ' ' +
+ 'tileposy=' + y + ' ' +
+ 'tilewidth=' + width + ' ' +
+ 'tileheight=' + height + ' ' +
+ 'id=' + id);
+ },
+
goToPage: function (page) {
var docLayer = this._docLayer;
if (page < 0 || page >= docLayer._pages) {
commit 038e0950ab7afe8498fede1dfe1ae1209828c650
Author: Mihai Varga <mihai.varga at collabora.com>
Date: Thu Aug 13 12:07:36 2015 +0300
loleaflet: don't fire statusIndicator 100% when all tiles are loaded
diff --git a/loleaflet/src/layer/tile/TileLayer.js b/loleaflet/src/layer/tile/TileLayer.js
index b4aa4d2..8d7191e 100644
--- a/loleaflet/src/layer/tile/TileLayer.js
+++ b/loleaflet/src/layer/tile/TileLayer.js
@@ -431,7 +431,6 @@ L.TileLayer = L.GridLayer.extend({
this._emptyTilesCount -= 1;
if (this._emptyTilesCount === 0) {
this._map.fire('statusindicator', {statusType: 'alltilesloaded'});
- this._map.fire('statusindicator', {statusType: 'setvalue', value: 100});
}
}
tile.el.src = img;
commit 381f7182a4d80b7c6de28b1eb475ae5849a3275d
Author: Mihai Varga <mihai.varga at collabora.com>
Date: Thu Aug 13 12:06:11 2015 +0300
loleaflet: updated the load test
diff --git a/loleaflet/spec/loadtest/LoadTestSpec.js b/loleaflet/spec/loadtest/LoadTestSpec.js
index bc4b624..e04350a 100644
--- a/loleaflet/spec/loadtest/LoadTestSpec.js
+++ b/loleaflet/spec/loadtest/LoadTestSpec.js
@@ -32,10 +32,7 @@ describe('LoadTest', function () {
});
after(function () {
- map.socket.onmessage = function () {};
- map.socket.onclose = function () {};
- map.socket.onerror = function () {};
- map.socket.close();
+ map.removeLayer(docLayer);
});
it('Load the document', function (done) {
@@ -46,10 +43,6 @@ describe('LoadTest', function () {
}
});
- if (docLayer) {
- map.removeLayer(docLayer);
- }
-
docLayer = new L.TileLayer('', {
doc: docPath + testDoc,
useSocket : true,
commit 0e807ac4594d1bf16c55d3c711090726535a3c33
Author: Mihai Varga <mihai.varga at collabora.com>
Date: Thu Aug 13 12:03:22 2015 +0300
loleaflet: forgot to remove an event listener
diff --git a/loleaflet/src/control/Scroll.js b/loleaflet/src/control/Scroll.js
index e84d02f..b3109b9 100644
--- a/loleaflet/src/control/Scroll.js
+++ b/loleaflet/src/control/Scroll.js
@@ -7,7 +7,6 @@ L.Map.include({
return;
}
this._setUpdateOffsetEvt(options);
- this.off('moveend', this._docLayer._updateScrollOffset, this._docLayer);
this.panBy(new L.Point(x, y), {animate: false});
},
commit bc0129cb7dc841a5864e5c0102962fd75937d6b8
Author: Mihai Varga <mihai.varga at collabora.com>
Date: Wed Aug 12 20:46:34 2015 +0300
loleaflet: map.remove clears timeouts, intervals and the toolbar
diff --git a/loleaflet/src/control/Control.js b/loleaflet/src/control/Control.js
index 8a53b2c..65640ac 100644
--- a/loleaflet/src/control/Control.js
+++ b/loleaflet/src/control/Control.js
@@ -89,6 +89,10 @@ L.Map.include({
var controlDiv = control.onAdd(this);
var controlContainer = L.DomUtil.get('toolbar');
controlContainer.appendChild(controlDiv);
+ if (!this._controls) {
+ this._controls = [];
+ }
+ this._controls.push({div: controlDiv});
return this;
},
@@ -97,6 +101,12 @@ L.Map.include({
return this;
},
+ removeControls: function () {
+ this._controls.forEach(function (control) {
+ L.DomUtil.remove(control.div);
+ });
+ },
+
_initControlPos: function () {
var corners = this._controlCorners = {},
l = 'leaflet-',
diff --git a/loleaflet/src/layer/tile/GridLayer.js b/loleaflet/src/layer/tile/GridLayer.js
index 55fe72a..c496296 100644
--- a/loleaflet/src/layer/tile/GridLayer.js
+++ b/loleaflet/src/layer/tile/GridLayer.js
@@ -40,14 +40,17 @@ L.GridLayer = L.Layer.extend({
this._viewReset();
this._map._docLayer = this;
- if (this._map.socket && !this._map.socket.onopen) {
- this._map.socket.onopen = L.bind(this._initDocument, this);
- }
- else if (this._map.socket && this._map.socket.readyState === 1) {
+ this._map.socket.onopen = L.bind(this._initDocument, this);
+ this._map.socket.onmessage = L.bind(this._onMessage, this);
+ if (this._map.socket && this._map.socket.readyState === 1) {
+ // the connection is already open
this._initDocument();
}
- if (this._map.socket && !this._map.socket.onmessage) {
- this._map.socket.onmessage = L.bind(this._onMessage, this);
+ else if (this._map.socket && this._map.socket.readyState > 1) {
+ // the connection is closing or is closed
+ var socket = this._map._initSocket();
+ socket.onopen = L.bind(this._initDocument, this);
+ socket.onmessage = L.bind(this._onMessage, this);
}
},
@@ -60,7 +63,12 @@ L.GridLayer = L.Layer.extend({
map._removeZoomLimit(this);
this._container = null;
this._tileZoom = null;
- this._map.socket.onmessage = null;
+ clearTimeout(this._preFetchIdle);
+ clearInterval(this._tilesPreFetcher);
+ this._map.socket.onmessage = function () {};
+ this._map.socket.onclose = function () {};
+ this._map.socket.onerror = function () {};
+ this._map.socket.close();
},
bringToFront: function () {
@@ -448,7 +456,7 @@ L.GridLayer = L.Layer.extend({
this._resetPreFetching();
},
- _move: function () {
+ _move: function (e) {
this._update();
this._resetPreFetching(true);
},
diff --git a/loleaflet/src/map/Map.js b/loleaflet/src/map/Map.js
index aec4334..5799ca7 100644
--- a/loleaflet/src/map/Map.js
+++ b/loleaflet/src/map/Map.js
@@ -249,6 +249,9 @@ L.Map = L.Evented.extend({
this.fire('unload');
}
+ this.removeLayer(this._docLayer._selections);
+ this.removeLayer(this._docLayer);
+ this.removeControls();
return this;
},
@@ -453,6 +456,7 @@ L.Map = L.Evented.extend({
this.socket.onerror = L.bind(this._onSocketError, this);
this.socket.onclose = L.bind(this._onSocketClose, this);
this.socket.binaryType = 'arraybuffer';
+ return this.socket;
},
diff --git a/loleaflet/src/map/handler/Map.Keyboard.js b/loleaflet/src/map/handler/Map.Keyboard.js
index 7217c5e..b98c495 100644
--- a/loleaflet/src/map/handler/Map.Keyboard.js
+++ b/loleaflet/src/map/handler/Map.Keyboard.js
@@ -122,6 +122,11 @@ L.Map.Keyboard = L.Handler.extend({
this._map.on('keydown keyup keypress', this._onKeyDown, this);
},
+ removeHooks: function () {
+ this._map.on('mousedown', this._onMouseDown, this);
+ this._map.off('keydown keyup keypress', this._onKeyDown, this);
+ },
+
_setPanOffset: function (pan) {
var keys = this._panKeys = {},
codes = this.navigationKeyCodes,
diff --git a/loleaflet/src/map/handler/Map.Mouse.js b/loleaflet/src/map/handler/Map.Mouse.js
index b12b405..9049084 100644
--- a/loleaflet/src/map/handler/Map.Mouse.js
+++ b/loleaflet/src/map/handler/Map.Mouse.js
@@ -18,6 +18,11 @@ L.Map.Mouse = L.Handler.extend({
this._onMouseEvent, this);
},
+ removeHooks: function () {
+ this._map.off('mousedown mouseup mouseover mouseout mousemove dblclick',
+ this._onMouseEvent, this);
+ },
+
_onMouseEvent: function (e) {
var docLayer = this._map._docLayer;
if (docLayer._graphicMarker && docLayer._graphicMarker.isDragged) {
commit 6994e4422208960436ddc85019ddfb0435c0a62c
Author: Mihai Varga <mihai.varga at collabora.com>
Date: Wed Aug 12 19:54:32 2015 +0300
loleaflet: getDocType method
diff --git a/loleaflet/README b/loleaflet/README
index 83650b9..e73726c 100644
--- a/loleaflet/README
+++ b/loleaflet/README
@@ -135,6 +135,8 @@ Scroll (the following are measured in pixels):
+ returns the scroll offset relative to the beginning of the document
map.getDocSize()
+ returns the document's size in pixels
+ map.getDocType()
+ + returns 'text' | 'spreadsheet' | 'presentation' | 'drawing' | 'other'
- events
map.on('docsize', function (e) {}) where:
+ e.x = document width
diff --git a/loleaflet/src/control/Parts.js b/loleaflet/src/control/Parts.js
index 12ba33e..9c6bfe3 100644
--- a/loleaflet/src/control/Parts.js
+++ b/loleaflet/src/control/Parts.js
@@ -83,5 +83,9 @@ L.Map.include({
getDocSize: function () {
return this._docLayer._docPixelSize;
+ },
+
+ getDocType: function () {
+ return this._docLayer._docType;
}
});
commit f8c0f0b14328e2116838671837c311328d5dc5b7
Author: Mihai Varga <mihai.varga at collabora.com>
Date: Wed Aug 12 19:43:15 2015 +0300
loleaflet: added option to fire 'updatescrolloffset' when scrolling
diff --git a/loleaflet/README b/loleaflet/README
index 7a97e35..83650b9 100644
--- a/loleaflet/README
+++ b/loleaflet/README
@@ -119,15 +119,17 @@ Save:
Scroll (the following are measured in pixels):
- API:
- map.scroll(x,y)
+ + options = An object with members: update (type: Boolean, default: false)
+ like {update: true}
+ map.scroll(x,y, options)
+ scroll right by 'x' and down by 'y' (or left and up if negative)
- map.scrollDown(y)
+ map.scrollDown(y, options)
+ scroll down by 'y' (or up if negative)
- map.scrollRight(x)
+ map.scrollRight(x, options)
+ scroll right by 'x' (or left if nevative)
- map.scrollTop(y)
+ map.scrollTop(y, options)
+ scroll to 'y' offset relative to the beginning of the document
- map.scrollLeft(x)
+ map.scrollLeft(x, options)
+ scroll to 'x' offset relative to the beginning of the document
map.scrollOffset()
+ returns the scroll offset relative to the beginning of the document
diff --git a/loleaflet/src/control/Scroll.js b/loleaflet/src/control/Scroll.js
index fab91bf..e84d02f 100644
--- a/loleaflet/src/control/Scroll.js
+++ b/loleaflet/src/control/Scroll.js
@@ -2,20 +2,21 @@
* Scroll methods
*/
L.Map.include({
- scroll: function (x, y) {
+ scroll: function (x, y, options) {
if (typeof (x) !== 'number' || typeof (y) !== 'number') {
return;
}
+ this._setUpdateOffsetEvt(options);
this.off('moveend', this._docLayer._updateScrollOffset, this._docLayer);
this.panBy(new L.Point(x, y), {animate: false});
},
- scrollDown: function (y) {
- this.scroll(0, y);
+ scrollDown: function (y, options) {
+ this.scroll(0, y, options);
},
- scrollRight: function (x) {
- this.scroll(x, 0);
+ scrollRight: function (x, options) {
+ this.scroll(x, 0, options);
},
scrollOffset: function () {
@@ -27,15 +28,24 @@ L.Map.include({
return offset;
},
- scrollTop: function (y) {
+ scrollTop: function (y, options) {
+ this._setUpdateOffsetEvt(options);
var offset = this.scrollOffset();
- this.off('moveend', this._docLayer._updateScrollOffset, this._docLayer);
this.panBy(new L.Point(0, y - offset.y), {animate: false});
},
- scrollLeft: function (x) {
+ scrollLeft: function (x, options) {
+ this._setUpdateOffsetEvt(options);
var offset = this.scrollOffset();
- this.off('moveend', this._docLayer._updateScrollOffset, this._docLayer);
this.panBy(new L.Point(x - offset.x, 0), {animate: false});
+ },
+
+ _setUpdateOffsetEvt: function (e) {
+ if (e && e.update === true) {
+ this.on('moveend', this._docLayer._updateScrollOffset, this._docLayer);
+ }
+ else {
+ this.off('moveend', this._docLayer._updateScrollOffset, this._docLayer);
+ }
}
});
commit e7cd3a75ef49ba0d1b61a48d70df77bbff010aa9
Author: Mihai Varga <mihai.varga at collabora.com>
Date: Wed Aug 12 19:22:26 2015 +0300
loleaflet: getDocSize method for getting the size in pixels
diff --git a/loleaflet/README b/loleaflet/README
index 9a0eebb..7a97e35 100644
--- a/loleaflet/README
+++ b/loleaflet/README
@@ -131,6 +131,8 @@ Scroll (the following are measured in pixels):
+ scroll to 'x' offset relative to the beginning of the document
map.scrollOffset()
+ returns the scroll offset relative to the beginning of the document
+ map.getDocSize()
+ + returns the document's size in pixels
- events
map.on('docsize', function (e) {}) where:
+ e.x = document width
diff --git a/loleaflet/src/control/Parts.js b/loleaflet/src/control/Parts.js
index eacc080..12ba33e 100644
--- a/loleaflet/src/control/Parts.js
+++ b/loleaflet/src/control/Parts.js
@@ -79,5 +79,9 @@ L.Map.include({
getCurrentPart: function () {
return this._docLayer._currentPart;
+ },
+
+ getDocSize: function () {
+ return this._docLayer._docPixelSize;
}
});
diff --git a/loleaflet/src/layer/tile/GridLayer.js b/loleaflet/src/layer/tile/GridLayer.js
index ecf4113..55fe72a 100644
--- a/loleaflet/src/layer/tile/GridLayer.js
+++ b/loleaflet/src/layer/tile/GridLayer.js
@@ -387,6 +387,7 @@ L.GridLayer = L.Layer.extend({
var scrollPixelLimits = new L.Point(this._docWidthTwips / this._tileWidthTwips,
this._docHeightTwips / this._tileHeightTwips);
scrollPixelLimits = scrollPixelLimits.multiplyBy(this._tileSize);
+ this._docPixelSize = {x: scrollPixelLimits.x, y: scrollPixelLimits.y};
this._map.fire('docsize', {x: scrollPixelLimits.x, y: scrollPixelLimits.y});
},
commit e3ae95bfc9b69c6b001bca26994ae2d054de4b21
Author: Mihai Varga <mihai.varga at collabora.com>
Date: Wed Aug 12 19:16:34 2015 +0300
loleaflet: get numberOfPages/Parts and getCurrentPart/Page mehtods
diff --git a/loleaflet/README b/loleaflet/README
index f201d0c..9a0eebb 100644
--- a/loleaflet/README
+++ b/loleaflet/README
@@ -93,6 +93,8 @@ Parts (like slides in presentation, or sheets in spreadsheets):
+ id = the ID of the request so that the response can be identified
+ maxWidth / maxHeight are the desired dimensions of the preview, a smaller
image might be returned in order to keep the original ratio of the document
+ map.getNumberOfParts()
+ map.getCurrentPart()
- events:
map.on('updateparts', function (e) {}) where:
+ e.currentPart is the current part
@@ -151,6 +153,7 @@ Writer pages:
- API:
map.goToPage(page)
map.getNumberOfPages()
+ map.getCurrentPart()
- events
map.on('pagenumberchanged', function (e) {}) where:
+ e.currentPage = the page on which the cursor lies
diff --git a/loleaflet/src/control/Parts.js b/loleaflet/src/control/Parts.js
index 23f856f..eacc080 100644
--- a/loleaflet/src/control/Parts.js
+++ b/loleaflet/src/control/Parts.js
@@ -67,5 +67,17 @@ L.Map.include({
getNumberOfPages: function () {
return this._docLayer._pages;
+ },
+
+ getNumberOfParts: function () {
+ return this._docLayer._parts;
+ },
+
+ getCurrentPage: function () {
+ return this._docLayer._currentPage;
+ },
+
+ getCurrentPart: function () {
+ return this._docLayer._currentPart;
}
});
diff --git a/loleaflet/src/layer/tile/TileLayer.js b/loleaflet/src/layer/tile/TileLayer.js
index 987242d..b4aa4d2 100644
--- a/loleaflet/src/layer/tile/TileLayer.js
+++ b/loleaflet/src/layer/tile/TileLayer.js
@@ -498,6 +498,7 @@ L.TileLayer = L.GridLayer.extend({
this._map.fire('setpart', {currentPart: this._currentPart});
}
else if (this._docType === 'text') {
+ this._currentPage = part;
this._map.fire('pagenumberchanged', {
currentPage: part,
pages: this._pages,
commit 6d12b870fb25b9ae5d5404a69dc3c040495c463d
Author: Mihai Varga <mihai.varga at collabora.com>
Date: Wed Aug 12 19:12:12 2015 +0300
loleaflet: removed an extra mouse down event
diff --git a/loleaflet/src/map/handler/Map.Mouse.js b/loleaflet/src/map/handler/Map.Mouse.js
index ba15651..b12b405 100644
--- a/loleaflet/src/map/handler/Map.Mouse.js
+++ b/loleaflet/src/map/handler/Map.Mouse.js
@@ -36,7 +36,7 @@ L.Map.Mouse = L.Handler.extend({
}
var mousePos = docLayer._latLngToTwips(e.latlng);
this._mouseEventsQueue.push(L.bind(function() {
- docLayer._postMouseEvent('buttondown', mousePos.x, mousePos.y, 1);}, docLayer));
+ this._postMouseEvent('buttondown', mousePos.x, mousePos.y, 1);}, docLayer));
this._holdMouseEvent = setTimeout(L.bind(this._executeMouseEvents, this), 500);
}
else if (e.type === 'mouseup') {
@@ -62,10 +62,10 @@ L.Map.Mouse = L.Handler.extend({
timeOut = 0;
}
this._mouseEventsQueue.push(L.bind(function() {
+ var docLayer = this._map._docLayer;
// if it's a click or mouseup after selecting
if (this._mouseEventsQueue.length > 1) {
- // it's a click, fire mousedown
- this._mouseEventsQueue[0]();
+ // it's a click
if (docLayer._permission === 'view') {
docLayer._map.setPermission('edit');
}
@@ -73,7 +73,7 @@ L.Map.Mouse = L.Handler.extend({
this._mouseEventsQueue = [];
docLayer._postMouseEvent('buttonup', mousePos.x, mousePos.y, 1);
docLayer._textArea.focus();
- }, this, docLayer));
+ }, this));
this._holdMouseEvent = setTimeout(L.bind(this._executeMouseEvents, this), timeOut);
if (docLayer._startMarker._icon) {
commit b11f4ca1d871a72ca56892d152983e9cbbf1624d
Author: Mihai Varga <mihai.varga at collabora.com>
Date: Wed Aug 12 18:23:15 2015 +0300
loleaflet: map focus methods
diff --git a/loleaflet/src/control/Control.Permission.js b/loleaflet/src/control/Control.Permission.js
index 240d1bb..2f67eec 100644
--- a/loleaflet/src/control/Control.Permission.js
+++ b/loleaflet/src/control/Control.Permission.js
@@ -26,6 +26,7 @@ L.Control.PermissionSwitch = L.Control.extend({
else {
this._map.setPermission('view');
}
+ this._refocusOnMap();
},
_onUpdatePermission: function (e) {
diff --git a/loleaflet/src/control/Control.Selection.js b/loleaflet/src/control/Control.Selection.js
index abe3237..524b187 100644
--- a/loleaflet/src/control/Control.Selection.js
+++ b/loleaflet/src/control/Control.Selection.js
@@ -26,6 +26,7 @@ L.Control.Selection = L.Control.extend({
else {
this._map.disableSelection();
}
+ this._refocusOnMap();
},
_onUpdatePermission: function (e) {
diff --git a/loleaflet/src/control/Control.js b/loleaflet/src/control/Control.js
index 2dd433b..8a53b2c 100644
--- a/loleaflet/src/control/Control.js
+++ b/loleaflet/src/control/Control.js
@@ -72,12 +72,7 @@ L.Control = L.Class.extend({
},
_refocusOnMap: function () {
- if (this._map._docLayer._editMode) {
- this._map._docLayer._textArea.focus();
- }
- else {
- this._map.getContainer().focus();
- }
+ this._map.focus();
}
});
diff --git a/loleaflet/src/map/Map.js b/loleaflet/src/map/Map.js
index 500ffae..aec4334 100644
--- a/loleaflet/src/map/Map.js
+++ b/loleaflet/src/map/Map.js
@@ -436,6 +436,11 @@ L.Map = L.Evented.extend({
return this.layerPointToLatLng(this.mouseEventToLayerPoint(e));
},
+ focus: function () {
+ if (this._docLayer) {
+ this._docLayer._textArea.focus();
+ }
+ },
// map initialization methods
_initSocket: function () {
commit cd83b92370423c0cd9ca7886d428c646b1383002
Author: Mihai Varga <mihai.varga at collabora.com>
Date: Wed Aug 12 18:06:49 2015 +0300
loleaflet: rename 'searchnotfound' event to 'search'
Also added 'originalPhrase' and 'count' members to the event
diff --git a/loleaflet/README b/loleaflet/README
index 2b1c2f8..f201d0c 100644
--- a/loleaflet/README
+++ b/loleaflet/README
@@ -58,7 +58,9 @@ Search:
- API:
map.search(text, [backward])
- events:
- map.on('searchnotfound', function)
+ map.on('search', function (e) {}) (currently only fired when no search result is found) where:
+ + e.originalPhrase = the phrase that has been searched for
+ + e.count = number of results
Zoom:
- API:
diff --git a/loleaflet/src/control/Control.Search.js b/loleaflet/src/control/Control.Search.js
index c383e02..0154ad0 100644
--- a/loleaflet/src/control/Control.Search.js
+++ b/loleaflet/src/control/Control.Search.js
@@ -30,17 +30,17 @@ L.Control.Search = L.Control.extend({
this._disabled = true;
this._updateDisabled();
- map.on('clearnotfound searchnotfound', this._searchResultFound, this);
+ map.on('clearnotfound search', this._searchResultFound, this);
return container;
},
onRemove: function (map) {
- map.on('clearnotfound searchnotfound', this._searchResultFound, this);
+ map.on('clearnotfound search', this._searchResultFound, this);
},
_searchStart: function (e) {
- if (e.keyCode === 13 && this._searchBar.value !== '') {
+ if (e.keyCode === 13) {
this._map.search(this._searchBar.value);
this._disabled = false;
this._updateDisabled();
@@ -55,7 +55,7 @@ L.Control.Search = L.Control.extend({
if (e.type === 'clearnotfound') {
L.DomUtil.removeClass(this._searchBar, 'search-not-found');
}
- else if (e.type === 'searchnotfound') {
+ else if (e.type === 'search' && e.count === 0) {
L.DomUtil.addClass(this._searchBar, 'search-not-found');
setTimeout(L.bind(this._map.fire, this._map, 'clearnotfound'), 500);
}
diff --git a/loleaflet/src/layer/tile/TileLayer.js b/loleaflet/src/layer/tile/TileLayer.js
index a7b0d4a..987242d 100644
--- a/loleaflet/src/layer/tile/TileLayer.js
+++ b/loleaflet/src/layer/tile/TileLayer.js
@@ -506,7 +506,8 @@ L.TileLayer = L.GridLayer.extend({
}
}
else if (textMsg.startsWith('searchnotfound:')) {
- this._map.fire('searchnotfound');
+ var originalPhrase = textMsg.substring(16);
+ this._map.fire('search', {originalPhrase: originalPhrase, count: 0});
}
else if (textMsg.startsWith('error:')) {
command = this._parseServerCmd(textMsg);
More information about the Libreoffice-commits
mailing list