[Libreoffice-commits] online.git: Branch 'distro/collabora/milestone-4' - 12 commits - loleaflet/README loleaflet/src
Mihai Varga
mihai.varga at collabora.com
Thu Aug 13 03:51:53 PDT 2015
loleaflet/README | 29 +++++++++++++----
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 | 24 ++++++++++++--
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 +++++--
12 files changed, 153 insertions(+), 35 deletions(-)
New commits:
commit 805aab8c9e2e9e5f27b38042c5683a106b7e3f3c
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 3d603bf..f465f2c 100644
--- a/loleaflet/src/control/Parts.js
+++ b/loleaflet/src/control/Parts.js
@@ -96,11 +96,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 464f47f6430c49deb123f709144afe7f7ccda964
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 7264789..3d603bf 100644
--- a/loleaflet/src/control/Parts.js
+++ b/loleaflet/src/control/Parts.js
@@ -52,6 +52,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 8018c536a6fdaf205cb57390097c8ae83403ce5a
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 afee5b3..76404e9 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 658849f3bd673993929ec5e80b90fa3733194341
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 51eecaf7795ae44c93186130920958d32115cd75
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
Conflicts:
loleaflet/src/layer/tile/GridLayer.js
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 119c674..e19035b 100644
--- a/loleaflet/src/layer/tile/GridLayer.js
+++ b/loleaflet/src/layer/tile/GridLayer.js
@@ -29,6 +29,7 @@ L.GridLayer = L.Layer.extend({
onAdd: function () {
this._initContainer();
+ this._map._docLayer = this;
this._selections = new L.LayerGroup();
this._map.addLayer(this._selections);
@@ -38,8 +39,18 @@ L.GridLayer = L.Layer.extend({
this._map._fadeAnimated = false;
this._viewReset();
- this._update();
- this._map._docLayer = this;
+ 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();
+ }
+ 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);
+ }
},
beforeAdd: function (map) {
@@ -51,6 +62,12 @@ L.GridLayer = L.Layer.extend({
map._removeZoomLimit(this);
this._container = null;
this._tileZoom = 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 () {
@@ -438,7 +455,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 ad24b2888d204325924e6b2543be58d6b8fa3458
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 480c1d1..7264789 100644
--- a/loleaflet/src/control/Parts.js
+++ b/loleaflet/src/control/Parts.js
@@ -79,5 +79,9 @@ L.Map.include({
getDocSize: function () {
return this._docLayer._docPixelSize;
+ },
+
+ getDocType: function () {
+ return this._docLayer._docType;
}
});
commit d5cbb5c79802aed8054f2a4f4db14a2353c98d01
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 e3cfbbc7dd5e2d0de6fac3bdd111149cf0466128
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 1d3ce3e..480c1d1 100644
--- a/loleaflet/src/control/Parts.js
+++ b/loleaflet/src/control/Parts.js
@@ -75,5 +75,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 3b38029..119c674 100644
--- a/loleaflet/src/layer/tile/GridLayer.js
+++ b/loleaflet/src/layer/tile/GridLayer.js
@@ -377,6 +377,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 9472e46c509e6c88b3d90083e675bb8405bc643e
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 689ec4a..1d3ce3e 100644
--- a/loleaflet/src/control/Parts.js
+++ b/loleaflet/src/control/Parts.js
@@ -63,5 +63,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 6e5a56e..afee5b3 100644
--- a/loleaflet/src/layer/tile/TileLayer.js
+++ b/loleaflet/src/layer/tile/TileLayer.js
@@ -499,6 +499,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 a796f74b2ca300a30ea2c449780dffbf8cf9d7b5
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 5e086fb9b4d927bd9604fc0b3711cc62cb6ee995
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 347173cfed97b706ff4216ec28d33f327969a992
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 01e9e7f..6e5a56e 100644
--- a/loleaflet/src/layer/tile/TileLayer.js
+++ b/loleaflet/src/layer/tile/TileLayer.js
@@ -507,7 +507,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